"use client"; import { useEffect, useState } from "react"; import { Price, type PriceType, PriceValue, } from "@/components/shadcnblocks/price"; import { Rating } from "@/components/shadcnblocks/rating"; import { Card, CardContent, CardDescription } from "@/components/ui/card"; import type { CarouselApi } from "@/components/ui/carousel"; import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, } from "@/components/ui/carousel"; import { cn } from "@/lib/utils"; type Product = { name: string; image: string; price: PriceType; link: string; }; type ReviewType = { image: string; rate: number; comment: string; author: string; product: Product; }; interface Reviews6Props { title?: string; overline?: string; reviews?: ReviewType[]; className?: string; } type ReviewCardProps = ReviewType; type ProductCardProps = Product; const REVIEWS: ReviewType[] = [ { image: "/block-media/shadcnblocks/block/ecommerce/electronics/Serene-Listening-2.png", rate: 5, comment: "«این هدفون روتین روزمره‌ام را عوض کرد. صدا غنی است، آهنگ کامل است و حذف نویز چشمگیر است. واقعاً از استفاده روزانه لذت می‌برم.»", author: "امیر رضایی", product: { name: "هدفون بی‌سیم آئروتون", image: "/block-media/shadcnblocks/block/ecommerce/electronics/Modern-White-Headphones-1.png", price: { regular: 566000, currency: "ریال", }, link: "#", }, }, { image: "/block-media/shadcnblocks/block/ecommerce/electronics/Woman-Smiling-Indoors-2.png", rate: 5, comment: "«این گوشی واقعاً یک ارتقا حس می‌شود. دوربین واضح است، صفحه‌نمایش زیباست و عملکرد بی‌نقص است. هر روز از کار با آن لذت می‌برم.»", author: "سوفیا لطفی", product: { name: "گوشی هوشمند لومااج پرو", image: "/block-media/shadcnblocks/block/ecommerce/electronics/Sleek-Smartphone-Close-Up-1.png", price: { regular: 1566000, currency: "ریال", }, link: "#", }, }, ]; const Reviews6 = ({ reviews = REVIEWS, title = "بیش از ۱۰٬۰۰۰ مشتری راضی", overline = "نظر مشتریان ما", className, }: Reviews6Props) => { const [api, setApi] = useState(); const [current, setCurrent] = useState(0); const [scrollSnaps, setScrollSnaps] = useState([]); const onButtonClick = (index: number) => { if (!api) return; api.scrollTo(index); }; useEffect(() => { if (!api) return; const updateCurrent = (carouselApi: CarouselApi) => { setCurrent(carouselApi?.selectedScrollSnap() ?? 0); }; const updateScrollSnaps = (carouselApi: CarouselApi) => { setScrollSnaps(carouselApi?.scrollSnapList() ?? []); }; updateCurrent(api); updateScrollSnaps(api); api .on("reInit", updateCurrent) .on("select", updateCurrent) .on("resize", updateScrollSnaps); return () => { api .off("reInit", updateCurrent) .off("select", updateCurrent) .off("resize", updateScrollSnaps); }; }, [api]); return (
{overline && (

{overline}

)}

{title}

{reviews.map((review, index) => ( ))}
{scrollSnaps.map((_, index) => ( ))}
); }; const ReviewCard = ({ image, product, rate, comment, author, }: ReviewCardProps) => { return (
{`تصویر
{comment}

{author}

); }; const ProductCard = ({ image, name, price }: ProductCardProps) => { const { regular, sale, currency } = price; return (
{name}

{name}

); }; export { Reviews6 };