refacto : board player header

This commit is contained in:
GuillaumeSD
2025-05-08 00:43:55 +02:00
parent 8167b9b621
commit 8c934ab3b0
15 changed files with 219 additions and 154 deletions

View File

@@ -39,3 +39,15 @@ export const getChessComUserRecentGames = async (
return gamesToReturn;
};
export const getChessComUserAvatar = async (
username: string
): Promise<string | null> => {
const usernameParam = encodeURIComponent(username.trim().toLowerCase());
const res = await fetch(`https://api.chess.com/pub/player/${usernameParam}`);
const data = await res.json();
const avatarUrl = data?.avatar;
return typeof avatarUrl === "string" ? avatarUrl : null;
};