diff --git a/ApiCore-Frontend/src/app/(app)/layout.tsx b/ApiCore-Frontend/src/app/(app)/layout.tsx index 9fbbdbd..b765a3a 100644 --- a/ApiCore-Frontend/src/app/(app)/layout.tsx +++ b/ApiCore-Frontend/src/app/(app)/layout.tsx @@ -34,6 +34,9 @@ export default function AppLayout({ children }: { children: ReactNode }) { Königinnen + + Aufgaben + {user.role === "ADMIN" ? ( ("NORMAL"); + const [dueDate, setDueDate] = useState(""); + const [error, setError] = useState(null); + + const mutation = useMutation({ + mutationFn: createTask, + onSuccess: () => { + void queryClient.invalidateQueries({ queryKey: ["tasks"] }); + router.push("/tasks"); + }, + onError: () => { + setError("Aufgabe konnte nicht angelegt werden."); + }, + }); + + function handleSubmit(event: FormEvent) { + event.preventDefault(); + setError(null); + mutation.mutate({ + title, + description: description || undefined, + priority, + dueDate: dueDate ? new Date(dueDate).toISOString() : undefined, + }); + } + + return ( +
+ + + Neue Aufgabe + + +
+
+ + setTitle(event.target.value)} + /> +
+
+ + +
+
+ + setDueDate(event.target.value)} + /> +
+
+ +