Мелкие правки

This commit is contained in:
Халимов Рустам
2026-03-13 00:46:40 +03:00
parent 9daafae9c5
commit 7670a3b787
82 changed files with 725 additions and 114 deletions
+36
View File
@@ -100,6 +100,26 @@ class ApiClient {
return response.json() as Promise<User>;
}
async cropAvatar(file: File, cropData: { x: number; y: number; width: number; height: number }) {
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());
const response = await fetch(`${API_BASE}/users/avatar/crop`, {
method: 'POST',
headers: {
...(this.token ? { Authorization: `Bearer ${this.token}` } : {}),
},
body: formData,
});
if (!response.ok) throw new Error('Ошибка кропа аватара');
return response.json() as Promise<User>;
}
async removeAvatar() {
return this.request<User>('/users/avatar', { method: 'DELETE' });
}
@@ -229,6 +249,22 @@ class ApiClient {
});
}
async uploadVideoToStory(file: File) {
const formData = new FormData();
formData.append('file', file);
const response = await fetch(`${API_BASE}/stories/video`, {
method: 'POST',
headers: {
...(this.token ? { Authorization: `Bearer ${this.token}` } : {}),
},
body: formData,
});
if (!response.ok) throw new Error('Ошибка загрузки видео истории');
return response.json() as Promise<{ url: string }>;
}
async viewStory(storyId: string) {
return this.request<{ message: string }>(`/stories/${storyId}/view`, { method: 'POST' });
}