Fix user profile dialog

This commit is contained in:
2025-09-03 22:47:03 +03:00
Unverified
parent 7796e9577e
commit 182fe88db4
6 changed files with 169 additions and 48 deletions
+21
View File
@@ -1,5 +1,6 @@
import { getAuthHeaders } from "../../auth/api";
import { API_BASE_URL } from "../../core/config";
import type { UserProfile } from "../../core/types";
export interface ProfileData {
profile_picture?: string;
@@ -90,3 +91,23 @@ export async function updateBio(token: string, bio: string): Promise<boolean> {
return false;
}
}
/**
* Fetches user profile data by username
*/
export async function fetchUserProfile(token: string, username: string): Promise<UserProfile | null> {
try {
const response = await fetch(`${API_BASE_URL}/user/${username}`, {
headers: getAuthHeaders(token)
});
if (response.ok) {
return await response.json();
}
return null;
} catch (error) {
console.error('Error fetching user profile:', error);
return null;
}
}