import { useEffect, useState } from 'react' import { Container } from 'react-bootstrap' import { useParams } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { getUserProfile } from '../api/client' export default function Profile() { const { id } = useParams() const { t } = useTranslation() const [profile, setProfile] = useState(null) const [error, setError] = useState('') const [loading, setLoading] = useState(true) useEffect(() => { let active = true setLoading(true) setError('') getUserProfile(id) .then((data) => { if (!active) return setProfile(data) }) .catch((err) => { if (!active) return setError(err.message) }) .finally(() => { if (active) setLoading(false) }) return () => { active = false } }, [id]) return (
{t('profile.title')}
{loading &&

{t('profile.loading')}

} {error &&

{error}

} {profile && (
{profile.avatar_url ? ( ) : (