fixed modals to clear after adding users / tasks / availabilities / events

This commit is contained in:
z1glr
2025-02-07 12:41:42 +01:00
parent feb68ecd78
commit 9acab1ad09
6 changed files with 30 additions and 4 deletions

View File

@@ -2,23 +2,30 @@ import { apiCall, Task } from "@/lib";
import TaskEditor from "./TaskEditor";
import { Button } from "@heroui/react";
import { AddLarge } from "@carbon/icons-react";
import { useState } from "react";
export default function AddTask(props: {
isOpen?: boolean;
onOpenChange?: (isOpen: boolean) => void;
onSuccess?: () => void;
}) {
const [addTaskKey, setAddTaskKey] = useState<number>(0);
async function addTask(a: Task) {
const result = await apiCall("POST", "tasks", undefined, a);
if (result.ok) {
props.onSuccess?.();
props.onOpenChange?.(false);
setAddTaskKey(addTaskKey);
props.onSuccess?.();
}
}
return (
<TaskEditor
key={addTaskKey}
header="Add Task"
footer={
<Button type="submit" color="primary" startContent={<AddLarge />}>