Raid Instances showing up on calendar
This commit is contained in:
@@ -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 !== ""
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 (<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 (
|
||||
<div>
|
||||
Loading...
|
||||
@@ -31,7 +35,7 @@ export default function RaidGroupCalendarLoader({
|
||||
return (
|
||||
<CalendarDisplay
|
||||
raidGroupId={raidGroupId}
|
||||
calendarEvents={[...raidGroupCalendarQuery.data, ...gameCalendarQuery.data]}
|
||||
calendarEvents={[...raidGroupCalendarQuery.data, ...gameCalendarQuery.data, ...raidInstanceCalendarQuery.data]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user