import { Avatar, Box, Typography } from "@mui/material"; import api from "../api/axios"; import { useState,useEffect } from "react"; interface UserAvatarProps { username: string|null; src?: string; size?: number | string; } export default function UserAvatar({ username, size = 40 }: UserAvatarProps) { const[pb, setPb] = useState(); useEffect(() => { (async () => { try { const res = await api.get(`/profile/getProfilePicture/${username}`) setPb(res.data.url); } catch (error) { console.log(error); } })(); }, [username]); return ( username[0]; {username} ); }