mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-05 14:12:05 +00:00
17 lines
645 B
TypeScript
17 lines
645 B
TypeScript
|
|
import { useMutation, type UseMutationResult } from "@tanstack/react-query";
|
||
|
|
import { toast } from "react-toastify";
|
||
|
|
import * as authApi from "@/domain/auth/api/auth-api";
|
||
|
|
import type { ChangePasswordPayload } from "@/domain/auth/types/auth-user";
|
||
|
|
|
||
|
|
export function useChangePassword(): UseMutationResult<unknown, Error, ChangePasswordPayload> {
|
||
|
|
return useMutation({
|
||
|
|
mutationFn: (data: ChangePasswordPayload) => authApi.changePassword(data),
|
||
|
|
onSuccess: () => {
|
||
|
|
toast.success("Password changed successfully!");
|
||
|
|
},
|
||
|
|
onError: (error: Error) => {
|
||
|
|
toast.error(error.message || "Failed to change password");
|
||
|
|
},
|
||
|
|
});
|
||
|
|
}
|