'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.welcome', { name: user.name })}
{t('account.memberSince', { date: formatDate(user.createdAt) })}
{t('account.noOrders')}
{order.id}
{formatDate(order.createdAt)}
{fmt(order.total)}
{t(`orderStatus.${order.status}`)}