/** * @component RecentlyLaunched * @purpose Section matching Electronics05 demo dynamically loaded from live DB 2 catalog products. * @dependencies catalogService, lucide-react */ 'use client'; import { useState, useEffect } from 'react'; import Link from 'next/link'; import Image from 'next/image'; import { ArrowRight, Star } from 'lucide-react'; import { catalogService, ProductResponse } from '@/services/api/catalogService'; import { formatCurrency, getCatalogPriceInfo, getImageUrl } from '@/lib/utils'; export function RecentlyLaunched() { const [products, setProducts] = useState([]); useEffect(() => { catalogService.getProducts().then((res) => { if (res && res.length > 0) { setProducts(res.slice(0, 4)); } }); }, []); if (products.length === 0) return null; return (
{/* Left Promo Card (1/4 col) */}
Recently Launched

Electronics Prodigy Collection

Next-generation high performance tech gadgets and flagship repairs

Shop All
{/* Right Product Grid (3/4 col -> 4 Cards) */}
{products.map((prod) => { const image = getImageUrl(prod.images && prod.images[0] ? prod.images[0].image_url : ''); return (
{/* Image Box */}
{prod.name}
{/* Info */}

{prod.name}

{'★'.repeat(5)}
{(() => { const { price, oldPrice } = getCatalogPriceInfo(prod); return ( <> {formatCurrency(price)} {oldPrice != null && oldPrice > price && ( {formatCurrency(oldPrice)} )} ); })()}
); })}
); }