46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import { Account } from "@/interface/Account";
|
|
import api from "@/util/AxiosUtil";
|
|
import { useMutation } from "@tanstack/react-query";
|
|
|
|
|
|
export function useSignup(){
|
|
return useMutation({
|
|
mutationKey: ["signup"],
|
|
mutationFn: async (account: Account) => {
|
|
await api.post("/auth/signup", account);
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
export function useConfirm(){
|
|
return useMutation({
|
|
mutationKey: ["confirm"],
|
|
mutationFn: async (confirmToken: string) => {
|
|
await api.post(`/auth/confirm/${confirmToken}`);
|
|
}
|
|
});
|
|
}
|
|
|
|
export function useForgotPassword(){
|
|
return useMutation({
|
|
mutationKey: ["forgotPassword"],
|
|
mutationFn: async (username: string) => {
|
|
const params = new URLSearchParams();
|
|
params.append("username", username);
|
|
|
|
|
|
await api.post(`/auth/forgot?${params}`);
|
|
}
|
|
});
|
|
}
|
|
|
|
export function useForgotResetPassword(forgotToken: string){
|
|
return useMutation({
|
|
mutationKey: ["forgotResetPassword"],
|
|
mutationFn: async (password: string) => {
|
|
await api.post(`/auth/forgot/${forgotToken}`, {password});
|
|
}
|
|
});
|
|
}
|