Person page working
This commit is contained in:
@@ -21,6 +21,58 @@ export function useGetPersonCharactersByPersonId(personId: string, raidGroupId:
|
||||
});
|
||||
}
|
||||
|
||||
export function useGetPersonCharactersByPersonIdSearch(personId: string, raidGroupId: string, page: number, pageSize: number, searchTerm?: string){
|
||||
const params = new URLSearchParams();
|
||||
params.append("page", page.toString());
|
||||
params.append("pageSize", pageSize.toString());
|
||||
if(searchTerm){
|
||||
params.append("searchTerm", searchTerm);
|
||||
}
|
||||
|
||||
|
||||
return useQuery({
|
||||
queryKey: ["personCharacters", personId, { page, pageSize, searchTerm }],
|
||||
queryFn: async () => {
|
||||
const response = await api.get(`/raidGroup/${raidGroupId}/person/${personId}/character/page?${params}`);
|
||||
|
||||
if(response.status !== 200){
|
||||
throw new Error("Failed to get person characters");
|
||||
}
|
||||
else if(response.data.errors){
|
||||
throw new Error(response.data.errors.join(", "));
|
||||
}
|
||||
|
||||
console.log("person characters");
|
||||
console.log(response.data);
|
||||
|
||||
return response.data as PersonCharacter[];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function useGetPersonCharactersCountByPersonIdSearch(personId: string, raidGroupId: string, searchTerm?: string){
|
||||
const params = new URLSearchParams();
|
||||
if(searchTerm){
|
||||
params.append("searchTerm", searchTerm);
|
||||
}
|
||||
|
||||
return useQuery({
|
||||
queryKey: ["personCharactersCount", personId, { searchTerm }],
|
||||
queryFn: async () => {
|
||||
const response = await api.get(`/raidGroup/${raidGroupId}/person/${personId}/character/count?${params}`);
|
||||
|
||||
if(response.status !== 200){
|
||||
throw new Error("Failed to get person characters count");
|
||||
}
|
||||
else if(response.data.errors){
|
||||
throw new Error(response.data.errors.join(", "));
|
||||
}
|
||||
|
||||
return response.data.count as number;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreatePersonCharacter(raidGroupId: string, personId: string){
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user