Password reset working

This commit is contained in:
2025-03-15 21:27:15 -04:00
parent 49243a71a1
commit d42f625540
6 changed files with 169 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ import { AccountTutorialStatus } from "@/interface/AccountTutorialStatus";
import { RaidGroupPermissionType } from "@/interface/RaidGroup";
import { api } from "@/util/AxiosUtil";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { AxiosError } from "axios";
export function useGetAccounts(page: number, pageSize: number, searchTerm?: string){
@@ -160,6 +161,28 @@ export function useUpdateTutorialsStatus(){
});
}
export function useUpdatePassword(){
return useMutation({
mutationKey: ["updatePassword"],
mutationFn: async ({currentPassword, newPassword}:{currentPassword: string; newPassword: string;}) => {
try{
await api.post("/auth/resetPassword", {
currentPassword,
newPassword
});
}
catch(error){
if(error instanceof AxiosError && error.response?.data.errors){
throw new Error(error.response?.data.errors.join(", "));
}
else{
throw error;
}
}
}
});
}
export function useForcePasswordReset(accountId: string){