"use client"; import Link from "next/link"; import { useEffect, useState } from "react"; import type { Product } from "@/lib/catalog"; import { slotImages, type StaticImageSlot } from "@/lib/static-images"; import { Carousel } from "./Carousel"; import { ProductCard } from "./ProductCard"; import { SectionHeading } from "./SectionHeading"; import { SlotImage } from "./SlotImage"; type Props = { id?: string; english: string; title: string; products: Product[]; countdown?: boolean; leadBanner?: boolean; bannerSlot?: StaticImageSlot; href?: string; }; export function ProductCarousel({ id, english, title, products, countdown, leadBanner, bannerSlot, href, }: Props) { const saleBanner = slotImages(bannerSlot)[0]; if (!products.length && !leadBanner) return null; return (
{countdown ? : null} {href ? ( مشاهده همه ) : null} {leadBanner ? (
) : null} {products.map((product) => ( ))}
); } function SaleTimer() { const [left, setLeft] = useState({ h: 11, m: 42, s: 18 }); useEffect(() => { const timer = window.setInterval(() => { setLeft((current) => { let { h, m, s } = current; if (s > 0) s -= 1; else if (m > 0) { s = 59; m -= 1; } else if (h > 0) { s = 59; m = 59; h -= 1; } else { h = 11; m = 59; s = 59; } return { h, m, s }; }); }, 1000); return () => window.clearInterval(timer); }, []); const cells = [ { label: "ساعت", value: left.h }, { label: "دقیقه", value: left.m }, { label: "ثانیه", value: left.s }, ]; return (
{cells.map((cell, index) => (
{index > 0 ? ( : ) : null}

{String(cell.value).padStart(2, "0")}

{cell.label}

))}
); }