Raid groups page working

This commit is contained in:
2025-03-06 23:54:26 -05:00
parent 6c80becf71
commit 61789d7ca2
8 changed files with 307 additions and 17 deletions

View File

@@ -102,6 +102,56 @@ export function useGetRaidGroupsByGameCount(gameId: string, searchTerm?: string)
});
}
export function useGetRaidGroupsByAccount(accountId: string, page: number, pageSize: number, searchTerm?: string){
return useQuery({
queryKey: ["raidGroups", accountId, { page, pageSize, searchTerm }],
queryFn: async () => {
const params = new URLSearchParams();
params.append("page", page.toString());
params.append("pageSize", pageSize.toString());
if(searchTerm){
params.append("searchTerm", searchTerm);
}
const response = await api.get(`/raidGroup/account/${accountId}?${params}`);
if(response.status !== 200){
throw new Error("Failed to get raid groups");
}
else if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
return response.data as RaidGroup[];
}
});
}
export function useGetRaidGroupsCountByAccount(accountId: string, searchTerm?: string){
const searchParams = new URLSearchParams();
if(searchTerm){
searchParams.append("searchTerm", searchTerm);
}
return useQuery({
queryKey: ["raidGroups", accountId, "count", searchTerm],
queryFn: async () => {
const response = await api.get(`/raidGroup/account/${accountId}/count?${searchParams}`);
if(response.status !== 200){
throw new Error("Failed to get raid groups count");
}
else if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
return response.data.count as number;
}
});
}
export function useGetRaidGroupCalendar(raidGroupId: string){
return useQuery({
queryKey: ["raidGroups", raidGroupId, "calendar"],