fixed modals to clear after adding users / tasks / availabilities / events
This commit is contained in:
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user