mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-04 19:32:06 +00:00
Adds a My Account page, reachable from the sidebar, with the signed-in user's read-only details and a Change Password section. The new password is checked live against the shared password rules (6+ characters, an uppercase letter, a number and a special character), which the invite registration flow reuses. The current password is still verified by the server first, and its rejection is shown on the current password field.
14 lines
599 B
TypeScript
14 lines
599 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";
|
|
|
|
/** Errors are rendered inline by the form that initiated the change. */
|
|
export function useChangePassword(): UseMutationResult<unknown, Error, ChangePasswordPayload> {
|
|
return useMutation({
|
|
mutationFn: (data: ChangePasswordPayload) => authApi.changePassword(data),
|
|
onSuccess: () => {
|
|
toast.success("Password updated");
|
|
},
|
|
});
|
|
}
|