Update eslint to type check
This commit is contained in:
@@ -1,28 +1,13 @@
|
||||
import { Account } from "@/interface/Account";
|
||||
import { api } from "@/util/AxiosUtil";
|
||||
import api from "@/util/AxiosUtil";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { AxiosError } from "axios";
|
||||
|
||||
|
||||
export function useSignup(){
|
||||
return useMutation({
|
||||
mutationKey: ["signup"],
|
||||
mutationFn: async (account: Account) => {
|
||||
try{
|
||||
const response = await api.post("/auth/signup", account);
|
||||
|
||||
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("/auth/signup", account);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -32,21 +17,7 @@ export function useConfirm(){
|
||||
return useMutation({
|
||||
mutationKey: ["confirm"],
|
||||
mutationFn: async (confirmToken: string) => {
|
||||
try{
|
||||
const response = await api.post(`/auth/confirm/${confirmToken}`);
|
||||
|
||||
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(`/auth/confirm/${confirmToken}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -59,21 +30,7 @@ export function useForgotPassword(){
|
||||
params.append("username", username);
|
||||
|
||||
|
||||
try{
|
||||
const response = await api.post(`/auth/forgot?${params}`);
|
||||
|
||||
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(`/auth/forgot?${params}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -82,21 +39,7 @@ export function useForgotResetPassword(forgotToken: string){
|
||||
return useMutation({
|
||||
mutationKey: ["forgotResetPassword"],
|
||||
mutationFn: async (password: string) => {
|
||||
try{
|
||||
const response = await api.post(`/auth/forgot/${forgotToken}`, {password});
|
||||
|
||||
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(`/auth/forgot/${forgotToken}`, {password});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user