Фронт

This commit is contained in:
Халимов Рустам
2026-03-27 16:04:46 +03:00
parent 28fb8c25de
commit 030ae1e4e4
19 changed files with 234 additions and 174 deletions
@@ -3,46 +3,52 @@ import type { User, UserPresence } from '../../../core/domain/types';
export class UserApi {
static async searchUsers(query: string) {
return httpClient.request<UserPresence[]>(`/users/search?q=${encodeURIComponent(query)}`);
// Конечная точка в новом бэкенде: GET /api/profiles/search?q=...
return httpClient.request<UserPresence[]>(`/profiles/search?q=${encodeURIComponent(query)}`);
}
static async getUser(id: string) {
return httpClient.request<User>(`/users/${id}`);
// Конечная точка в новом бэкенде: GET /api/profiles/{id}
return httpClient.request<User>(`/profiles/${id}`);
}
static async updateProfile(data: { displayName?: string; bio?: string; birthday?: string }) {
return httpClient.request<User>('/users/profile', {
// Конечная точка в новом бэкенде: PUT /api/profiles/profile
return httpClient.request<User>('/profiles/profile', {
method: 'PUT',
body: JSON.stringify(data),
});
}
static async updateSettings(settings: any) {
return httpClient.request('/users/settings', {
// Конечная точка в новом бэкенде: PUT /api/profiles/settings
return httpClient.request('/profiles/settings', {
method: 'PUT',
body: JSON.stringify(settings),
});
}
static async uploadAvatar(file: File) {
// Конечная точка в новом бэкенде: POST /api/profiles/avatar
const formData = new FormData();
formData.append('avatar', file);
return httpClient.request<User>('/users/avatar', {
return httpClient.request<User>('/profiles/avatar', {
method: 'POST',
body: formData,
timeout: 120_000,
timeout: 120_000, // Аватар может быть большим, даем время на обработку
});
}
static async cropAvatar(file: File, cropData: { x: number; y: number; width: number; height: number }) {
// Конечная точка в новом бэкенде: POST /api/profiles/avatar/crop
const formData = new FormData();
formData.append('avatar', file);
formData.append('cropX', cropData.x.toString());
formData.append('cropY', cropData.y.toString());
formData.append('cropWidth', cropData.width.toString());
formData.append('cropHeight', cropData.height.toString());
formData.append('x', cropData.x.toString());
formData.append('y', cropData.y.toString());
formData.append('width', cropData.width.toString());
formData.append('height', cropData.height.toString());
return httpClient.request<User>('/users/avatar/crop', {
return httpClient.request<User>('/profiles/avatar/crop', {
method: 'POST',
body: formData,
timeout: 120_000,
@@ -50,10 +56,13 @@ export class UserApi {
}
static async removeAvatar() {
return httpClient.request<User>('/users/avatar', { method: 'DELETE' });
// Конечная точка в новом бэкенде: DELETE /api/profiles/avatar
return httpClient.request<User>('/profiles/avatar', { method: 'DELETE' });
}
static async getIceServers() {
// Конфигурация WebRTC теперь возвращается через эндпоинт админки или настроек,
// но если бэк не меняли в этой части, оставляем старый путь.
return httpClient.request<{ iceServers: RTCIceServer[] }>('/webrtc/ice-servers');
}
}