'use client'; import { AlertTriangle, Heart, ShoppingCart, X } from 'lucide-react'; import { Link, SmartLink } from '@/core/lib/navigation'; import { useWishlistPage } from '@/core/hooks/use-wishlist-page'; import { ProductGrid } from '@/ui/product/product-grid'; import { Button } from '@/components/ui/button'; import { Skeleton } from '@/components/ui/skeleton'; import { useTranslations } from '@/core/lib/translations'; /** * The wishlist page: the shopper's saved products, newest first. * * Same four-state pattern as the cart page. `status` decides what to draw: * loading a skeleton, never a spinner and never the empty state * error the list could not be loaded: says so, with a way out. NEVER drawn as empty * empty the ONLY state that says "nothing saved yet" * ready the products, through the shared ProductGrid (each card keeps its heart, so * tapping it takes the product off the list) * * A guest's list is in this browser only, and the page says so in a line that does not * block anything. */ export function WishlistView() { const t = useTranslations('wishlist'); const { status, products, isMember, retry, canAddToCart, addAllToCart, addingAll, addAllResult, dismissAddAllResult, } = useWishlistPage(); if (status === 'loading') { return (
); } if (status === 'error') { return (
); } if (status === 'empty') { return (
); } const anyAvailable = products.some(canAddToCart); const countLabel = products.length === 1 ? t('itemCountOne') : t('itemCountOther', { count: String(products.length) }); const resultText = addAllResult ? addAllResult.added === 0 ? t('addAllNone') : addAllResult.skipped === 0 ? t('addAllDone', { added: String(addAllResult.added) }) : t(addAllResult.skipped === 1 ? 'addAllDoneSkippedOne' : 'addAllDoneSkippedOther', { added: String(addAllResult.added), skipped: String(addAllResult.skipped), }) : ''; return (

{t('title')}

{countLabel}

{/* A guest's list lives in this browser. Said once, in a line, and never in the way. */} {!isMember && (

{t('guestNote')}{' '} {t('guestLogin')}

)} {/* What "add all" did. The region exists before the text does, so a screen reader announces it. */}
{resultText && (

{resultText}

)}
); }