Adds profile and settings pages
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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<UserListItem, Error, UpdateProfilePayload>({
|
||||
mutationFn: (data) => api.put<UserListItem>('/api/v1/Users/me', data),
|
||||
onSuccess: () => {
|
||||
// Sync AuthContext with updated name/email via token refresh
|
||||
void refresh();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useChangePassword() {
|
||||
return useMutation<void, Error, ChangePasswordPayload>({
|
||||
mutationFn: (data) => api.post<void>('/api/v1/Auth/change-password', data),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user