--- import type { Sneaker } from '../data/mock'; import WatchlistButtonStatic from './WatchlistButtonStatic.astro'; function getDiscountPercent(sneaker: { originalPrice: number; lowestPrice: number }): number { return Math.round(((sneaker.originalPrice - sneaker.lowestPrice) / sneaker.originalPrice) * 100); } interface Props { sneaker: Sneaker; index?: number; } const { sneaker, index = 0 } = Astro.props; const displayName = sneaker.displayName || `${sneaker.brand} ${sneaker.name}`; const discount = getDiscountPercent(sneaker); // Build model page URL for color variants link const modelSlug = sneaker.model ? sneaker.model.replace(/[^a-zA-Z0-9]+/g, '-').replace(/(^-|-$)/g, '').toLowerCase() : null; const modelPageUrl = modelSlug ? `/merken/${sneaker.brandSlug}/${modelSlug}` : null; const colorCount = sneaker.colorVariantCount || 0; const isPopular = (sneaker.popularityScore || 0) >= 50; // Deal Score calculation const shops = sneaker.offers.filter(o => o.inStock).length; const discountPts = discount >= 40 ? 4 : discount >= 30 ? 3 : discount >= 20 ? 2 : discount >= 10 ? 1 : 0; const shopPts = shops >= 5 ? 2 : shops >= 3 ? 1 : 0; const rawScore = discountPts + shopPts; // max 6 const dealScore = rawScore > 0 ? Math.round((rawScore / 6) * 9 + 1) : 1; // normalize to 1-10 const dealScoreLabel = dealScore >= 8 ? 'Top deal' : dealScore >= 5 ? 'Goed' : 'Check prijs'; const showScore = rawScore > 0; // show when any scoring factor is present const dealScoreClass = dealScore >= 8 ? 'bg-green-500/15 text-green-400 border border-green-500/30' : dealScore >= 5 ? 'bg-yellow-500/15 text-yellow-400 border border-yellow-500/30' : 'bg-red-500/10 text-red-400/70 border border-red-500/20'; ---
{discount > 0 && (
-{discount}%
)} {isPopular && (
0 ? 'top-11' : 'top-3']}> Populair
)}
{`${displayName}
{sneaker.brand}

{sneaker.displayName || sneaker.name}

{sneaker.colorway}

{colorCount > 1 && modelPageUrl && ( {colorCount} kleuren )}
vanaf €{sneaker.lowestPrice.toFixed(2).replace('.', ',')} {sneaker.originalPrice > sneaker.lowestPrice && ( €{sneaker.originalPrice.toFixed(2).replace('.', ',')} )}
{sneaker.offers.filter(o => o.inStock).length} shops {showScore && ( 0 ? `${discount}% korting (+${discountPts}pt)` : 'geen korting'}${shopPts > 0 ? `, ${sneaker.offers.filter(o => o.inStock).length} shops (+${shopPts}pt)` : ''}`} > {dealScore} {dealScoreLabel} )}