'use client'; import { useEffect } from 'react'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { User, Package, MapPin, Phone, Mail, LogOut, Heart } from 'lucide-react'; import Button from '@/components/ui/Button'; import { useAuth } from '@/presentation/hooks/useAuth'; import { formatPrice, formatDate, getFormatLocale } from '@/lib/utils'; import { useTranslation } from '@/hooks/useTranslation'; import { localizeProduct } from '@/lib/product-i18n'; export default function AccountPage() { const router = useRouter(); const { user, isAuthenticated, orders, logout } = useAuth(); const { t, locale } = useTranslation(); useEffect(() => { if (!isAuthenticated) { router.push('/login'); } }, [isAuthenticated, router]); if (!isAuthenticated || !user) { return null; } const handleLogout = () => { logout(); router.push('/'); }; const fmt = (n: number) => formatPrice(n, getFormatLocale(locale)); return (

{t('account.title')}

{t('account.welcome', { name: user.name })}

{user.name}

{t('account.memberSince', { date: formatDate(user.createdAt) })}

{user.email}
{user.phone}
{user.address.street}, {user.address.city}, {user.address.state}{' '} {user.address.zip}
{t('account.myWishlist')}

{t('account.orderHistory')}

{orders.length === 0 ? (

{t('account.noOrders')}

) : (
{orders.map((order) => (

{order.id}

{formatDate(order.createdAt)}

{fmt(order.total)}

{t(`orderStatus.${order.status}`)}
{order.items.map((item) => { const localized = localizeProduct(item.product, t); return (
{localized.name} × {item.quantity} ({item.customizationLabel}) {fmt(item.product.price * item.quantity)}
); })}
))}
)}
); }