import { useEffect, useState } from 'react' import { Container, Form, Row, Col, Button } from 'react-bootstrap' import { getCurrentUser, updateCurrentUser, uploadAvatar } from '../api/client' import { useAuth } from '../context/AuthContext' import { useTranslation } from 'react-i18next' export default function Ucp({ theme, setTheme, accentOverride, setAccentOverride }) { const { t, i18n } = useTranslation() const { token } = useAuth() const accentMode = accentOverride ? 'custom' : 'system' const [avatarError, setAvatarError] = useState('') const [avatarUploading, setAvatarUploading] = useState(false) const [avatarPreview, setAvatarPreview] = useState('') const [location, setLocation] = useState('') const [profileError, setProfileError] = useState('') const [profileSaving, setProfileSaving] = useState(false) const [profileSaved, setProfileSaved] = useState(false) useEffect(() => { if (!token) return let active = true getCurrentUser() .then((data) => { if (!active) return setAvatarPreview(data?.avatar_url || '') setLocation(data?.location || '') }) .catch(() => { if (active) setAvatarPreview('') }) return () => { active = false } }, [token]) const handleLanguageChange = (event) => { const locale = event.target.value i18n.changeLanguage(locale) localStorage.setItem('speedbb_lang', locale) } return (
{t('ucp.profile')}

{t('ucp.profile_hint')}

{avatarPreview ? ( ) : (