Fix profile

This commit is contained in:
2025-09-06 12:19:21 +03:00
Unverified
parent 7f0d2b66f4
commit ca3336b0cc
4 changed files with 95 additions and 8 deletions
+18 -3
View File
@@ -22,7 +22,13 @@ export async function loadProfile(token: string): Promise<ProfileData | null> {
});
if (response.ok) {
return await response.json();
const data = await response.json();
// Map backend fields to frontend fields
return {
profile_picture: data.profile_picture,
nickname: data.username,
description: data.bio
};
}
return null;
@@ -61,10 +67,19 @@ export async function uploadProfilePicture(token: string, file: Blob): Promise<U
*/
export async function updateProfile(token: string, data: Partial<ProfileData>): Promise<boolean> {
try {
// Map frontend fields to backend fields
const backendData = {
nickname: data.nickname,
description: data.description
};
const response = await fetch(`${API_BASE_URL}/user/profile`, {
method: 'PUT',
headers: getAuthHeaders(token),
body: JSON.stringify(data)
headers: {
...getAuthHeaders(token),
'Content-Type': 'application/json'
},
body: JSON.stringify(backendData)
});
return response.ok;