Raid Group calendar working

This commit is contained in:
2025-03-07 21:54:17 -05:00
parent 61789d7ca2
commit 0dfb971bc2
8 changed files with 213 additions and 30 deletions

View File

@@ -1,9 +1,27 @@
import { CalendarEvent } from "@/interface/Calendar";
import { RaidGroup } from "@/interface/RaidGroup";
import { api } from "@/util/AxiosUtil";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
export function useGetRaidGroup(raidGroupId: string, disabled: boolean){
return useQuery({
queryKey: ["raidGroups", raidGroupId],
queryFn: async () => {
const response = await api.get(`/raidGroup/${raidGroupId}`);
if(response.status !== 200){
throw new Error("Failed to get raid group");
}
else if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
return response.data?.raidGroupId ? response.data as RaidGroup : undefined;
},
enabled: !disabled
});
}
export function useGetRaidGroups(page: number, pageSize: number, searchTerm?: string){
return useQuery({
queryKey: ["raidGroups", { page, pageSize, searchTerm }],
@@ -152,24 +170,6 @@ export function useGetRaidGroupsCountByAccount(accountId: string, searchTerm?: s
}
export function useGetRaidGroupCalendar(raidGroupId: string){
return useQuery({
queryKey: ["raidGroups", raidGroupId, "calendar"],
queryFn: async () => {
const response = await api.get(`/raidGroup/${raidGroupId}/calendar`);
if(response.status !== 200){
throw new Error("Failed to get raid group calendar");
}
else if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
return response.data as CalendarEvent[];
}
});
}
export function useCreateRaidGroup(){
const queryClient = useQueryClient();