Update eslint to type check

This commit is contained in:
2025-05-25 13:34:23 -04:00
parent c4265bbcad
commit 8b5efb0879
68 changed files with 2420 additions and 2015 deletions

View File

@@ -1,30 +1,16 @@
import { Counter } from "@/interface/Counters";
import { RaidGroup } from "@/interface/RaidGroup";
import { api } from "@/util/AxiosUtil";
import api from "@/util/AxiosUtil";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { AxiosError } from "axios";
export function useGetRaidGroup(raidGroupId: string, disabled: boolean){
return useQuery({
queryKey: ["raidGroups", raidGroupId],
queryFn: async () => {
try{
const response = await api.get(`/raidGroup/${raidGroupId}`);
const response = await api.get(`/raidGroup/${raidGroupId}`);
if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
return response.data?.raidGroupId ? response.data as RaidGroup : undefined;
}
catch(error){
if(error instanceof AxiosError && error.response?.data.errors){
throw new Error(error.response?.data.errors.join(", "));
}
else{
throw error;
}
}
return (response.data as RaidGroup)?.raidGroupId ? response.data as RaidGroup : undefined;
},
enabled: !disabled
});
@@ -41,23 +27,9 @@ export function useGetRaidGroups(page: number, pageSize: number, searchTerm?: st
params.append("searchTerm", searchTerm);
}
try{
const response = await api.get(`/raidGroup?${params}`);
const response = await api.get(`/raidGroup?${params}`);
if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
return response.data as RaidGroup[];
}
catch(error){
if(error instanceof AxiosError && error.response?.data.errors){
throw new Error(error.response?.data.errors.join(", "));
}
else{
throw error;
}
}
return response.data as RaidGroup[];
}
});
}
@@ -72,23 +44,9 @@ export function useGetRaidGroupsCount(searchTerm?: string){
return useQuery({
queryKey: ["raidGroups", "count", searchTerm],
queryFn: async () => {
try{
const response = await api.get(`/raidGroup/count?${searchParams}`);
const response = await api.get(`/raidGroup/count?${searchParams}`);
if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
return response.data.count as number;
}
catch(error){
if(error instanceof AxiosError && error.response?.data.errors){
throw new Error(error.response?.data.errors.join(", "));
}
else{
throw error;
}
}
return (response.data as Counter).count;
}
});
}
@@ -104,23 +62,9 @@ export function useGetRaidGroupsByGame(gameId: string, page: number, pageSize: n
params.append("searchTerm", searchTerm);
}
try{
const response = await api.get(`/raidGroup/game/${gameId}?${params}`);
const response = await api.get(`/raidGroup/game/${gameId}?${params}`);
if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
return response.data as RaidGroup[];
}
catch(error){
if(error instanceof AxiosError && error.response?.data.errors){
throw new Error(error.response?.data.errors.join(", "));
}
else{
throw error;
}
}
return response.data as RaidGroup[];
}
});
}
@@ -135,23 +79,9 @@ export function useGetRaidGroupsByGameCount(gameId: string, searchTerm?: string)
return useQuery({
queryKey: ["raidGroups", gameId, "count", searchTerm],
queryFn: async () => {
try{
const response = await api.get(`/raidGroup/game/${gameId}/count?${searchParams}`);
const response = await api.get(`/raidGroup/game/${gameId}/count?${searchParams}`);
if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
return response.data.count as number;
}
catch(error){
if(error instanceof AxiosError && error.response?.data.errors){
throw new Error(error.response?.data.errors.join(", "));
}
else{
throw error;
}
}
return (response.data as Counter).count;
}
});
}
@@ -167,23 +97,9 @@ export function useGetRaidGroupsByAccount(accountId: string, page: number, pageS
params.append("searchTerm", searchTerm);
}
try{
const response = await api.get(`/raidGroup/account/${accountId}?${params}`);
const response = await api.get(`/raidGroup/account/${accountId}?${params}`);
if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
return response.data as RaidGroup[];
}
catch(error){
if(error instanceof AxiosError && error.response?.data.errors){
throw new Error(error.response?.data.errors.join(", "));
}
else{
throw error;
}
}
return response.data as RaidGroup[];
}
});
}
@@ -198,23 +114,9 @@ export function useGetRaidGroupsCountByAccount(accountId: string, searchTerm?: s
return useQuery({
queryKey: ["raidGroups", accountId, "count", searchTerm],
queryFn: async () => {
try{
const response = await api.get(`/raidGroup/account/${accountId}/count?${searchParams}`);
const response = await api.get(`/raidGroup/account/${accountId}/count?${searchParams}`);
if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
return response.data.count as number;
}
catch(error){
if(error instanceof AxiosError && error.response?.data.errors){
throw new Error(error.response?.data.errors.join(", "));
}
else{
throw error;
}
}
return (response.data as Counter).count;
}
});
@@ -235,27 +137,13 @@ export function useCreateRaidGroup(){
formData.append("raidGroupName", raidGroupName);
formData.append("gameId", gameId);
try{
const response = await api.post(
"/raidGroup",
formData
);
if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
}
catch(error){
if(error instanceof AxiosError && error.response?.data.errors){
throw new Error(error.response?.data.errors.join(", "));
}
else{
throw error;
}
}
await api.post(
"/raidGroup",
formData
);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["raidGroups"] });
void queryClient.invalidateQueries({ queryKey: ["raidGroups"] });
}
});
}
@@ -277,24 +165,10 @@ export function useUpdateRaidGroup(){
formData.append("raidGroupIcon", raidGroup.raidGroupIcon);
}
try{
const response = await api.put(`/raidGroup/${raidGroup.raidGroupId}`, formData);
if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
}
catch(error){
if(error instanceof AxiosError && error.response?.data.errors){
throw new Error(error.response?.data.errors.join(", "));
}
else{
throw error;
}
}
await api.put(`/raidGroup/${raidGroup.raidGroupId}`, formData);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["raidGroups"] });
void queryClient.invalidateQueries({ queryKey: ["raidGroups"] });
}
});
}
@@ -306,24 +180,10 @@ export function useDeleteRaidGroup(){
return useMutation({
mutationKey: ["deleteRaidGroup"],
mutationFn: async (raidGroupId: string) => {
try{
const response = await api.delete(`/raidGroup/${raidGroupId}`);
if(response.data.errors){
throw new Error(response.data.errors.join(", "));
}
}
catch(error){
if(error instanceof AxiosError && error.response?.data.errors){
throw new Error(error.response?.data.errors.join(", "));
}
else{
throw error;
}
}
await api.delete(`/raidGroup/${raidGroupId}`);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["raidGroups"] });
void queryClient.invalidateQueries({ queryKey: ["raidGroups"] });
}
});
}