feat(28-02): create profile page with account management, separate from settings
Adds /profile route with four sections: profile info (reuses ProfileSection), account info (email + member since), security (password change/set), and danger zone (account deletion with typed confirmation). Removes ProfileSection from settings page per D-01. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
37
src/client/hooks/useAccount.ts
Normal file
37
src/client/hooks/useAccount.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { apiGet, apiPost } from "../lib/api";
|
||||
|
||||
export function useHasPassword() {
|
||||
return useQuery({
|
||||
queryKey: ["account", "hasPassword"],
|
||||
queryFn: () =>
|
||||
apiGet<{ hasPassword: boolean }>("/api/account/has-password"),
|
||||
});
|
||||
}
|
||||
|
||||
export function useChangePassword() {
|
||||
return useMutation({
|
||||
mutationFn: (data: { currentPassword: string; newPassword: string }) =>
|
||||
apiPost<{ ok: boolean }>("/api/account/password", data),
|
||||
});
|
||||
}
|
||||
|
||||
export function useChangeEmail() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (data: { newEmail: string }) =>
|
||||
apiPost<{ ok: boolean }>("/api/account/email", data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["auth"] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteAccount() {
|
||||
return useMutation({
|
||||
mutationFn: () =>
|
||||
apiPost<{ ok: boolean; redirectTo: string }>("/api/account/delete", {
|
||||
confirmation: "DELETE",
|
||||
}),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user