"use client"; import Image from "next/image"; import Link from "next/link"; import { useRef } from "react"; type Product = { title: string; enName: string; price: string; image: string; href?: string; }; type SaleBanner = { image?: string | null; linkUrl?: string | null; ariaLabel?: string; }; function ProductPrice({ price }: { price: string }) { const trimmed = price.trim(); const match = trimmed.match(/^([\d٬,.\s]+)\s*(تومان)$/); if (match) { return (

{match[1].trim()} تومان

); } return

{trimmed}

; } function ProductCard({ product }: { product: Product }) { return ( {product.title}

{product.enName}

{product.title}

); } function SaleBannerCard({ banner }: { banner?: SaleBanner | null }) { const style = banner?.image ? { backgroundImage: `linear-gradient(90deg, rgba(136, 63, 63, 0.55), rgba(0, 35, 75, 0.5)), url(${banner.image})`, backgroundSize: "cover", backgroundPosition: "center", } : undefined; const className = "sale sale-promo-card"; const label = banner?.ariaLabel || "فروش ویژه"; if (banner?.linkUrl) { return ( ); } return ( ); } export function ProductCarousel({ products, ariaLabel, withSaleBanner = false, saleBanner, }: { products: Product[]; ariaLabel: string; withSaleBanner?: boolean; saleBanner?: SaleBanner | null; }) { const carouselRef = useRef(null); const scrollCarousel = (direction: "next" | "previous") => { const amount = 300; carouselRef.current?.scrollBy({ left: direction === "next" ? -amount : amount, behavior: "smooth", }); }; return (
{withSaleBanner ? : null} {products.map((product) => ( ))}
); }