import { useMutation } from '@tanstack/react-query'; import { api } from '@/lib/api-client'; import { useAuth } from '@/contexts/auth-context'; import type { UserListItem } from './types'; export interface UpdateProfilePayload { name: string; email: string; } export interface ChangePasswordPayload { currentPassword: string; newPassword: string; } export function useUpdateProfile() { const { refresh } = useAuth(); return useMutation({ mutationFn: (data) => api.put('/api/v1/Users/me', data), onSuccess: () => { // Sync AuthContext with updated name/email via token refresh void refresh(); }, }); } export function useChangePassword() { return useMutation({ mutationFn: (data) => api.post('/api/v1/Auth/change-password', data), }); }