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,6 +2,7 @@ import { Button } from "@heroui/react";
import { apiCall } from "@/lib";
import { AddLarge } from "@carbon/icons-react";
import EventEditor, { EventSubmitData } from "./EventEditor";
import { useState } from "react";
export default function AddEvent(props: {
className?: string;
@@ -9,18 +10,23 @@ export default function AddEvent(props: {
onOpenChange: (isOpen: boolean) => void;
onSuccess?: () => void;
}) {
const [addEventKey, setAddEventKey] = useState<number>(0);
async function addEvent(data: EventSubmitData) {
const result = await apiCall("POST", "events", undefined, data);
if (result.ok) {
props.onOpenChange(false);
setAddEventKey(addEventKey + 1);
props.onSuccess?.();
}
}
return (
<EventEditor
key={addEventKey}
{...props}
header="Add Event"
onSubmit={(data) => void addEvent(data)}