"use client"; import { ChevronLeft, ChevronRight } from "lucide-react"; import { useEffect, useState } from "react"; import { Rating } from "@/components/shadcnblocks/rating"; import { AspectRatio } from "@/components/ui/aspect-ratio"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardTitle, } from "@/components/ui/card"; import type { CarouselApi } from "@/components/ui/carousel"; import { Carousel, CarouselContent, CarouselItem, } from "@/components/ui/carousel"; import { cn } from "@/lib/utils"; type ReviewType = { rate: number; title: string; comment?: string; verifiedBuyer?: boolean; author: string; image?: string; type?: "text" | "image"; }; interface Reviews8Props { reviews?: ReviewType[]; title?: string; className?: string; } type ReviewCardProps = ReviewType; const customerRoleLabel = (verified?: boolean) => verified ? "خریدار تأییدشده" : "مشتری"; const REVIEWS: ReviewType[] = [ { rate: 4, title: "طراحی آگاهانه که حس می‌شود", comment: "هر قطعه ظرافت آرامی دارد. معلوم است برای ساخت و جزئیات وقت گذاشته‌اند. ظریف، کاربردی و با کیفیت ساخت عالی.", author: "لوکا مرادی", verifiedBuyer: false, type: "text", }, { rate: 5, title: "مینیمال، ولی پر از شخصیت", author: "ژوان احمدی", image: "/block-media/shadcnblocks/block/ecommerce/clothes/Man-in-White-Hoodie-1.png", type: "image", }, { rate: 4, title: "تعادل کامل میان سبک و کارایی", comment: "دوست دارم همه‌چیز عمدی به نظر برسد؛ نه اضافه، نه کم. این آیتم‌ها بدون شلوغ کردن فضا، به خانه‌ام شخصیت می‌دهند.", author: "لوکا مرادی", verifiedBuyer: false, type: "text", }, { rate: 5, title: "جاودانه و عکاسی زیبا", author: "ژوان احمدی", image: "/block-media/shadcnblocks/block/ecommerce/accessories/Elegant-Jewelry-Portrait-1.png", type: "image", }, { rate: 4, title: "روزمره را ارتقا می‌دهد", comment: "کم پیش می‌آید دکوری پیدا کنید که هم هنری باشد هم کاربردی. این محصولات هم در زندگی روزمره جا می‌گیرند و هم توجه را جلب می‌کنند.", author: "لوکا مرادی", verifiedBuyer: false, type: "text", }, { rate: 5, title: "ظریف، مدرن و خیره‌کننده", author: "ژوان احمدی", image: "/block-media/shadcnblocks/block/ecommerce/accessories/Elegant-Gold-Earrings-1.png", type: "image", }, { rate: 4, title: "با نیت واقعی ساخته شده", comment: "هیچ‌چیز حس تولید انبوه نمی‌دهد. بافت، وزن و پرداخت کار همه گرم و منحصربه‌فردند؛ چیزی که کمتر جایی می‌بینید.", author: "لوکا مرادی", verifiedBuyer: false, type: "text", }, { rate: 5, title: "زیبایی بدون تلاش", author: "ژوان احمدی", image: "/block-media/shadcnblocks/block/ecommerce/accessories/Elegant-Watch-on-Womans-Wrist-1.png", type: "image", }, ]; const Reviews8 = ({ reviews = REVIEWS, title = "صداهای واقعی، نظرات صادقانه", className, }: Reviews8Props) => { const [api, setApi] = useState(); const [scrollSnaps, setScrollSnaps] = useState([]); const [current, setCurrent] = useState(0); 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 (

{title}

{reviews.map(({ type, ...review }, index) => ( {type === "image" ? ( ) : ( )} ))}
{scrollSnaps.map((_, index) => (
); }; const TextReviewCard = ({ rate, title, comment, author, verifiedBuyer, }: ReviewCardProps) => { return ( {title} {comment && ( {comment} )}

{author}

{customerRoleLabel(verifiedBuyer)}

); }; const ImageReviewCard = ({ image, title, rate, author, verifiedBuyer, }: ReviewCardProps) => { return ( {`تصویر {title}

{author}

{customerRoleLabel(verifiedBuyer)}

); }; export { Reviews8 };