diff --git a/Net.Vatprc.Uniapi.UI.Event/src/components/delete-slot.tsx b/Net.Vatprc.Uniapi.UI.Event/src/components/delete-slot.tsx new file mode 100644 index 0000000..3a170c2 --- /dev/null +++ b/Net.Vatprc.Uniapi.UI.Event/src/components/delete-slot.tsx @@ -0,0 +1,51 @@ +import { invalidatePath, useApi, useApiDelete } from "@/client"; +import { useUser } from "@/services/auth"; +import { Button, Group, Popover, Stack, Text } from "@mantine/core"; +import { useDisclosure } from "@mantine/hooks"; +import { useRouter } from "@tanstack/react-router"; + +export const DeleteSlot = ({ eventId, slotId }: { eventId: string; slotId: string }) => { + const user = useUser(); + const { data: slot, isLoading } = useApi("/api/events/{eid}/slots/{sid}", { + path: { eid: eventId, sid: slotId }, + enabled: !!eventId, + }); + const { navigate } = useRouter(); + const { mutate, isPending } = useApiDelete( + "/api/events/{eid}/slots/{sid}", + { path: { eid: eventId, sid: slotId } }, + async () => { + await invalidatePath("/api/events/{eid}/slots", { eid: eventId }); + close(); + await navigate({ to: "/events/" + eventId }); + }, + ); + const [opened, { toggle, close }] = useDisclosure(false); + + if (!user?.roles.includes("ec")) return null; + + return ( + + + + + + + + Do you want to delete slot entering {slot?.airspace?.name} at {slot?.enter_at}? + + + + + + + + + ); +}; diff --git a/Net.Vatprc.Uniapi.UI.Event/src/routes/events/$event_id.tsx b/Net.Vatprc.Uniapi.UI.Event/src/routes/events/$event_id.tsx index a2eff55..268028d 100644 --- a/Net.Vatprc.Uniapi.UI.Event/src/routes/events/$event_id.tsx +++ b/Net.Vatprc.Uniapi.UI.Event/src/routes/events/$event_id.tsx @@ -4,6 +4,7 @@ import { CreateEvent } from "@/components/create-event"; import { CreateSlot } from "@/components/create-slot"; import { DeleteAirspace } from "@/components/delete-airspace"; import { DeleteEvent } from "@/components/delete-event"; +import { DeleteSlot } from "@/components/delete-slot"; import { useUser } from "@/services/auth"; import { ActionIcon, @@ -67,6 +68,7 @@ const EventBookingButtons = ({ Unbook )} + ); };