Adds profile and settings pages

This commit is contained in:
2026-06-22 23:59:04 +02:00
parent 6976eb4337
commit 2544e20b3c
49 changed files with 2741 additions and 34 deletions
+31
View File
@@ -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),
});
}