Raid Instance Creator working
This commit is contained in:
@@ -24,7 +24,8 @@ export function useGetClassGroups(raidGroupId: string, page: number, pageSize: n
|
||||
}
|
||||
|
||||
return response.data as ClassGroup[];
|
||||
}
|
||||
},
|
||||
enabled: !!raidGroupId
|
||||
});
|
||||
}
|
||||
|
||||
@@ -67,7 +68,7 @@ export function useGetClassGroupsByRaidLayout(raidGroupId: string, raidLayoutId:
|
||||
|
||||
return response.data as (ClassGroup | null)[];
|
||||
},
|
||||
enabled: !!raidLayoutId
|
||||
enabled: !!raidGroupId && !!raidLayoutId
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export function useGetGameClasses(gameId: string, page: number, pageSize: number
|
||||
});
|
||||
}
|
||||
|
||||
export function useGetGameClassesByClassGroup(classGroupId: string){
|
||||
export function useGetGameClassesByClassGroup(classGroupId?: string){
|
||||
return useQuery({
|
||||
queryKey: ["gameClasses", "classGroups", classGroupId],
|
||||
queryFn: async () => {
|
||||
|
||||
@@ -73,6 +73,25 @@ export function useGetPersonCharactersCountByPersonIdSearch(personId: string, ra
|
||||
});
|
||||
}
|
||||
|
||||
export function useGetPersonCharactersByRaidGroup(raidGroupId: string){
|
||||
return useQuery({
|
||||
queryKey: ["personCharacters", raidGroupId],
|
||||
queryFn: async () => {
|
||||
const response = await api.get(`/raidGroup/${raidGroupId}/person/character`);
|
||||
|
||||
if(response.status !== 200){
|
||||
throw new Error("Failed to get person characters");
|
||||
}
|
||||
else if(response.data.errors){
|
||||
throw new Error(response.data.errors.join(", "));
|
||||
}
|
||||
|
||||
return response.data as PersonCharacter[];
|
||||
},
|
||||
enabled: !!raidGroupId
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreatePersonCharacter(raidGroupId: string, personId: string){
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { RaidInstance } from "@/interface/RaidInstance";
|
||||
import { RaidInstancePersonCharacterXref } from "@/interface/RaidInstancePersonCharacterXref";
|
||||
import { api } from "@/util/AxiosUtil";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
@@ -100,8 +101,6 @@ export function useUpdateRaidInstance(raidGroupId: string){
|
||||
return useMutation({
|
||||
mutationKey: ["updateRaidInstance", raidGroupId],
|
||||
mutationFn: async (raidInstance: RaidInstance) => {
|
||||
console.log("raidInstance");
|
||||
console.log(raidInstance);
|
||||
const response = await api.put(`/raidGroup/${raidGroupId}/raidInstance/${raidInstance.raidInstanceId}`, raidInstance);
|
||||
|
||||
if(response.status !== 200){
|
||||
@@ -117,6 +116,22 @@ export function useUpdateRaidInstance(raidGroupId: string){
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateRaidInstanceNoInvalidation(raidGroupId: string){
|
||||
return useMutation({
|
||||
mutationKey: ["updateRaidInstance", raidGroupId],
|
||||
mutationFn: async (raidInstance: RaidInstance) => {
|
||||
const response = await api.put(`/raidGroup/${raidGroupId}/raidInstance/${raidInstance.raidInstanceId}`, raidInstance);
|
||||
|
||||
if(response.status !== 200){
|
||||
throw new Error("Failed to update raid instance");
|
||||
}
|
||||
else if(response.data.errors){
|
||||
throw new Error(response.data.errors.join(", "));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteRaidInstance(raidGroupId: string, raidInstanceId: string){
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -138,3 +153,46 @@ export function useDeleteRaidInstance(raidGroupId: string, raidInstanceId: strin
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export function useGetRaidInstancePersonCharacterXrefs(raidGroupId?: string, raidInstanceId?: string){
|
||||
return useQuery({
|
||||
queryKey: ["raidInstancePersonCharacterXrefs", raidGroupId, raidInstanceId],
|
||||
queryFn: async () => {
|
||||
const response = await api.get(`/raidGroup/${raidGroupId}/raidInstance/${raidInstanceId}/personCharacterXref`);
|
||||
|
||||
if(response.status !== 200){
|
||||
throw new Error("Failed to get raid instance person character xrefs");
|
||||
}
|
||||
else if(response.data.errors){
|
||||
throw new Error(response.data.errors.join(", "));
|
||||
}
|
||||
|
||||
return response.data as RaidInstancePersonCharacterXref[];
|
||||
},
|
||||
enabled: !!raidGroupId && !!raidInstanceId
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateRaidInstancePersonCharacterXrefs(raidGroupId?: string, raidInstanceId?: string){
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
|
||||
return useMutation({
|
||||
mutationKey: ["updateRaidInstancePersonCharacterXrefs", raidGroupId, raidInstanceId],
|
||||
mutationFn: async (raidInstancePersonCharacterXrefs: RaidInstancePersonCharacterXref[]) => {
|
||||
const response = await api.post(`/raidGroup/${raidGroupId}/raidInstance/${raidInstanceId}/personCharacterXref`, raidInstancePersonCharacterXrefs);
|
||||
|
||||
if(response.status !== 200){
|
||||
throw new Error("Failed to update raid instance person character xrefs");
|
||||
}
|
||||
else if(response.data.errors){
|
||||
throw new Error(response.data.errors.join(", "));
|
||||
}
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["raidInstancePersonCharacterXrefs", raidGroupId, raidInstanceId] });
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,25 @@ import { api } from "@/util/AxiosUtil";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
|
||||
export function useGetRaidLayout(raidGroupId?: string, raidLayoutId?: string){
|
||||
return useQuery({
|
||||
queryKey: ["raidLayout", raidGroupId, raidLayoutId],
|
||||
queryFn: async () => {
|
||||
const response = await api.get(`/raidGroup/${raidGroupId}/raidLayout/${raidLayoutId}`);
|
||||
|
||||
if(response.status !== 200){
|
||||
throw new Error("Failed to get raid layout");
|
||||
}
|
||||
else if(response.data.errors){
|
||||
throw new Error(response.data.errors.join(", "));
|
||||
}
|
||||
|
||||
return response.data as RaidLayout;
|
||||
},
|
||||
enabled: !!raidGroupId && !!raidLayoutId
|
||||
});
|
||||
}
|
||||
|
||||
export function useGetRaidLayoutsByRaidGroup(raidGroupId: string, page: number, pageSize: number, searchTerm?: string){
|
||||
return useQuery({
|
||||
queryKey: ["raidLayouts", raidGroupId, {page, pageSize, searchTerm}],
|
||||
@@ -127,4 +146,3 @@ export function useDeleteRaidLayout(raidGroupId: string, raidLayoutId: string){
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user