From 0eeedf1e3be2d7e4ecaa22a28a8e5d74dd1e1aed Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Sat, 15 Mar 2025 18:37:57 -0400 Subject: [PATCH] Raid Instances showing up on calendar --- src/hooks/CalendarHooks.ts | 19 +++++++++++++++++++ src/ui/calendar/CalendarDisplay.tsx | 5 +++++ src/ui/calendar/RaidGroupCalendarLoader.tsx | 10 +++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/hooks/CalendarHooks.ts b/src/hooks/CalendarHooks.ts index b28982d..c96ca43 100644 --- a/src/hooks/CalendarHooks.ts +++ b/src/hooks/CalendarHooks.ts @@ -165,3 +165,22 @@ export function useDeleteRaidGroupCalendarEvent(raidGroupId: string){ } }); } + +export function useGetRaidInstanceCalendarEvents(raidGroupId?: string){ + return useQuery({ + queryKey: ["raidInstanceCalendarEvents", raidGroupId], + queryFn: async () => { + const response = await api.get(`/calendar/raidGroup/${raidGroupId}/raidInstance`); + + if(response.status !== 200){ + throw new Error("Failed to get raid instance calendar events"); + } + else if(response.data.errors){ + throw new Error(response.data.errors.join(", ")); + } + + return response.data as CalendarEvent[]; + }, + enabled: !!raidGroupId && raidGroupId !== "" + }); +} diff --git a/src/ui/calendar/CalendarDisplay.tsx b/src/ui/calendar/CalendarDisplay.tsx index 7c1aa3b..687234f 100644 --- a/src/ui/calendar/CalendarDisplay.tsx +++ b/src/ui/calendar/CalendarDisplay.tsx @@ -56,6 +56,8 @@ export default function CalendarDisplay({ const showEditCalendarEventModal = (eventClickArg: EventClickArg) => { const calendarEvent = calendarEvents.find((calEvent) => calEvent.calendarEventId === eventClickArg.event.id); + console.log("calendarEvent"); + console.log(calendarEvent); if(raidGroupId && calendarEvent?.gameId){ setDisableModal(true); } @@ -65,6 +67,9 @@ export default function CalendarDisplay({ else if(calendarEvent?.raidGroupId && !isRaidGroupAdmin(calendarEvent?.raidGroupId, raidGroupPermissions, accountPermissions) && !isRaidGroupLeader(calendarEvent?.raidGroupId, raidGroupPermissions, accountPermissions)){ setDisableModal(true); } + else if(calendarEvent?.raidInstanceId){ + setDisableModal(true); + } setAlterCalendarEvent(calendarEvent); setDisplayCalendarEventModal(true); diff --git a/src/ui/calendar/RaidGroupCalendarLoader.tsx b/src/ui/calendar/RaidGroupCalendarLoader.tsx index 6b95a6e..296f65d 100644 --- a/src/ui/calendar/RaidGroupCalendarLoader.tsx +++ b/src/ui/calendar/RaidGroupCalendarLoader.tsx @@ -1,5 +1,5 @@ import DangerMessage from "@/components/message/DangerMessage"; -import { useGetGameCalendar, useGetRaidGroupCalendar } from "@/hooks/CalendarHooks"; +import { useGetGameCalendar, useGetRaidGroupCalendar, useGetRaidInstanceCalendarEvents } from "@/hooks/CalendarHooks"; import CalendarDisplay from "./CalendarDisplay"; @@ -12,6 +12,7 @@ export default function RaidGroupCalendarLoader({ }){ const gameCalendarQuery = useGetGameCalendar(gameId); const raidGroupCalendarQuery = useGetRaidGroupCalendar(raidGroupId); + const raidInstanceCalendarQuery = useGetRaidInstanceCalendarEvents(raidGroupId); if(raidGroupCalendarQuery.status === "error"){ @@ -20,7 +21,10 @@ export default function RaidGroupCalendarLoader({ else if(gameCalendarQuery.status === "error"){ return (Error {gameCalendarQuery.error.message}); } - else if((raidGroupCalendarQuery.status === "pending") || (gameCalendarQuery.status === "pending")){ + else if(raidInstanceCalendarQuery.status === "error"){ + return (Error {raidInstanceCalendarQuery.error.message}); + } + else if((raidGroupCalendarQuery.status === "pending") || (gameCalendarQuery.status === "pending") || (raidInstanceCalendarQuery.status === "pending")){ return (
Loading... @@ -31,7 +35,7 @@ export default function RaidGroupCalendarLoader({ return ( ); }