import { useState, useEffect } from 'react'; interface RecommendedItem { id: number; name: string; brand: string; slug: string; image_url: string; cutout_image_url: string | null; colorway: string; lowest_price: number | null; shop_count: number; original_price: number | null; } export default function ForYouSection() { const [items, setItems] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { fetch('/api/user/recommendations') .then(r => r.json()) .then(data => { setItems(data.items || []); setLoading(false); }) .catch(() => setLoading(false)); }, []); if (loading) return null; if (items.length === 0) return null; return (

Voor jou

Gebaseerd op je watchlist en voorkeuren

{items.map(item => { const lowestPrice = item.lowest_price ? parseFloat(String(item.lowest_price)) : null; const originalPrice = item.original_price ? parseFloat(String(item.original_price)) : null; const hasDiscount = originalPrice && lowestPrice && lowestPrice < originalPrice; const discountPct = hasDiscount ? Math.round((1 - lowestPrice / originalPrice) * 100) : 0; return ( {item.name} { (e.target as HTMLImageElement).src = '/img/sneaker-placeholder.svg'; }} />

{item.brand}

{item.name}

{lowestPrice ? ( €{lowestPrice.toFixed(2).replace('.', ',')} ) : ( N/A )} {discountPct > 0 && ( -{discountPct}% )}
); })}
); }