Raid Instances showing up on calendar

This commit is contained in:
2025-03-15 18:37:57 -04:00
parent ea0018bae2
commit 0eeedf1e3b
3 changed files with 31 additions and 3 deletions

View File

@@ -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 !== ""
});
}

View File

@@ -56,6 +56,8 @@ export default function CalendarDisplay({
const showEditCalendarEventModal = (eventClickArg: EventClickArg) => { const showEditCalendarEventModal = (eventClickArg: EventClickArg) => {
const calendarEvent = calendarEvents.find((calEvent) => calEvent.calendarEventId === eventClickArg.event.id); const calendarEvent = calendarEvents.find((calEvent) => calEvent.calendarEventId === eventClickArg.event.id);
console.log("calendarEvent");
console.log(calendarEvent);
if(raidGroupId && calendarEvent?.gameId){ if(raidGroupId && calendarEvent?.gameId){
setDisableModal(true); setDisableModal(true);
} }
@@ -65,6 +67,9 @@ export default function CalendarDisplay({
else if(calendarEvent?.raidGroupId && !isRaidGroupAdmin(calendarEvent?.raidGroupId, raidGroupPermissions, accountPermissions) && !isRaidGroupLeader(calendarEvent?.raidGroupId, raidGroupPermissions, accountPermissions)){ else if(calendarEvent?.raidGroupId && !isRaidGroupAdmin(calendarEvent?.raidGroupId, raidGroupPermissions, accountPermissions) && !isRaidGroupLeader(calendarEvent?.raidGroupId, raidGroupPermissions, accountPermissions)){
setDisableModal(true); setDisableModal(true);
} }
else if(calendarEvent?.raidInstanceId){
setDisableModal(true);
}
setAlterCalendarEvent(calendarEvent); setAlterCalendarEvent(calendarEvent);
setDisplayCalendarEventModal(true); setDisplayCalendarEventModal(true);

View File

@@ -1,5 +1,5 @@
import DangerMessage from "@/components/message/DangerMessage"; import DangerMessage from "@/components/message/DangerMessage";
import { useGetGameCalendar, useGetRaidGroupCalendar } from "@/hooks/CalendarHooks"; import { useGetGameCalendar, useGetRaidGroupCalendar, useGetRaidInstanceCalendarEvents } from "@/hooks/CalendarHooks";
import CalendarDisplay from "./CalendarDisplay"; import CalendarDisplay from "./CalendarDisplay";
@@ -12,6 +12,7 @@ export default function RaidGroupCalendarLoader({
}){ }){
const gameCalendarQuery = useGetGameCalendar(gameId); const gameCalendarQuery = useGetGameCalendar(gameId);
const raidGroupCalendarQuery = useGetRaidGroupCalendar(raidGroupId); const raidGroupCalendarQuery = useGetRaidGroupCalendar(raidGroupId);
const raidInstanceCalendarQuery = useGetRaidInstanceCalendarEvents(raidGroupId);
if(raidGroupCalendarQuery.status === "error"){ if(raidGroupCalendarQuery.status === "error"){
@@ -20,7 +21,10 @@ export default function RaidGroupCalendarLoader({
else if(gameCalendarQuery.status === "error"){ else if(gameCalendarQuery.status === "error"){
return (<DangerMessage>Error {gameCalendarQuery.error.message}</DangerMessage>); return (<DangerMessage>Error {gameCalendarQuery.error.message}</DangerMessage>);
} }
else if((raidGroupCalendarQuery.status === "pending") || (gameCalendarQuery.status === "pending")){ else if(raidInstanceCalendarQuery.status === "error"){
return (<DangerMessage>Error {raidInstanceCalendarQuery.error.message}</DangerMessage>);
}
else if((raidGroupCalendarQuery.status === "pending") || (gameCalendarQuery.status === "pending") || (raidInstanceCalendarQuery.status === "pending")){
return ( return (
<div> <div>
Loading... Loading...
@@ -31,7 +35,7 @@ export default function RaidGroupCalendarLoader({
return ( return (
<CalendarDisplay <CalendarDisplay
raidGroupId={raidGroupId} raidGroupId={raidGroupId}
calendarEvents={[...raidGroupCalendarQuery.data, ...gameCalendarQuery.data]} calendarEvents={[...raidGroupCalendarQuery.data, ...gameCalendarQuery.data, ...raidInstanceCalendarQuery.data]}
/> />
); );
} }