'use client' import { useState } from 'react' import { useTranslations } from 'next-intl' import { useAuth } from '@/hooks/use-auth' import { ProtectedRoute } from '@/components/auth/protected-route' import { Container, Paper, Box, Typography, TextField, Button, Avatar, Grid, Card, CardContent, Divider, Alert, CircularProgress } from '@mui/material' import { Person, Email, AdminPanelSettings, Save, Edit } from '@mui/icons-material' export default function ProfilePage() { const { user } = useAuth() const t = useTranslations('profile') const [isEditing, setIsEditing] = useState(false) const [name, setName] = useState(user?.name || '') const [loading, setLoading] = useState(false) const [message, setMessage] = useState('') const handleSave = async () => { setLoading(true) setMessage('') try { // TODO: Implement profile update API await new Promise(resolve => setTimeout(resolve, 1000)) // Placeholder setMessage(t('profileUpdated')) setIsEditing(false) } catch (error) { setMessage(t('updateError')) } finally { setLoading(false) } } const handleCancel = () => { setName(user?.name || '') setIsEditing(false) } const getRoleTranslation = (role: string) => { switch (role) { case 'admin': return t('admin') case 'moderator': return t('moderator') default: return t('user') } } return ( {/* Header */} {user?.name ? user.name.charAt(0).toUpperCase() : } {t('title')} {t('subtitle')} {/* Profile Information */} {/* Personal Information Card */} {t('personalInfo')} {!isEditing && ( )} setName(e.target.value)} disabled={!isEditing || loading} variant="outlined" margin="normal" InputProps={{ startAdornment: }} /> }} helperText={t('emailCannotChange')} /> {isEditing && ( )} {/* Account Details Card */} {t('accountDetails')} {t('role')} {getRoleTranslation(user?.role || 'user')} {t('memberSince')} {new Date().toLocaleDateString()} {/* TODO: Use actual creation date */} {/* Success/Error Message */} {message && ( setMessage('')} > {message} )} ) }