'use client'; import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Save } from 'lucide-react'; import { useToast } from '@/hooks/use-toast'; import { Textarea } from '@/components/ui/textarea'; import { useI18n } from '@/locales/client'; const mockUserProfile = { name: 'Alice Wonderland', email: 'alice@example.com', avatarUrl: 'https://placehold.co/100x100.png?text=AW', bio: "Lover of imaginative play and sharing joy. I have a collection of classic storybooks and dress-up costumes.", phone: '555-123-4567', location: 'Springfield Gardens, USA', }; export default function ProfilePage() { const { toast } = useToast(); const t = useI18n(); const [name, setName] = useState(mockUserProfile.name); const [email, setEmail] = useState(mockUserProfile.email); const [avatarUrl, setAvatarUrl] = useState(mockUserProfile.avatarUrl); const [bio, setBio] = useState(mockUserProfile.bio); const [phone, setPhone] = useState(mockUserProfile.phone); const [location, setLocation] = useState(mockUserProfile.location); const [currentPassword, setCurrentPassword] = useState(''); const [newPassword, setNewPassword] = useState(''); const [confirmNewPassword, setConfirmNewPassword] = useState(''); const [isLoading, setIsLoading] = useState(false); const [isPasswordLoading, setIsPasswordLoading] = useState(false); const handleProfileUpdate = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); await new Promise(resolve => setTimeout(resolve, 1000)); console.log("Updating profile:", { name, avatarUrl, bio, phone, location }); toast({ title: "Profile Updated", description: "Your profile information has been saved." }); // Translate setIsLoading(false); }; const handlePasswordChange = async (e: React.FormEvent) => { e.preventDefault(); if (newPassword !== confirmNewPassword) { toast({ title: "Password Mismatch", description: "New passwords do not match.", variant: "destructive" }); // Translate return; } if (newPassword.length < 6) { toast({ title: "Password Too Short", description: "Password must be at least 6 characters.", variant: "destructive" }); // Translate return; } setIsPasswordLoading(true); await new Promise(resolve => setTimeout(resolve, 1000)); console.log("Changing password"); toast({ title: "Password Updated", description: "Your password has been changed successfully." }); // Translate setCurrentPassword(''); setNewPassword(''); setConfirmNewPassword(''); setIsPasswordLoading(false); }; return (

{t('dashboard.profile.title')}

{t('dashboard.profile.description')}

{t('dashboard.profile.personal_info_title')} {t('dashboard.profile.personal_info_description')}
{name.split(' ').map(n => n[0]).join('').toUpperCase()}
setAvatarUrl(e.target.value)} placeholder="https://example.com/avatar.png" disabled={isLoading} />
setName(e.target.value)} placeholder="Your Name" disabled={isLoading} />