Signup page (mostly) working
This commit is contained in:
20
src/hooks/AuthHooks.ts
Normal file
20
src/hooks/AuthHooks.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
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) => {
|
||||
const response = await api.post("/auth/signup", account);
|
||||
|
||||
if(response.status !== 200){
|
||||
throw new Error("Failed to signup");
|
||||
}
|
||||
else if(response.data.errors){
|
||||
throw new Error(response.data.errors.join(", "));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user