"use client"; import { X } from "lucide-react"; import { useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { cn } from "@/lib/utils"; interface Purchase { id: string; customerName: string; customerLocation: string; customerAvatar?: string; productName: string; productImage: string; timeAgo: string; } const DEFAULT_PURCHASES: Purchase[] = [ { id: "1", customerName: "سارا محمدی", customerLocation: "تهران", productName: "هدفون بیسیم", productImage: "/block-media/shadcnblocks/block/ecommerce/electronics/Modern-White-Headphones-1.png", timeAgo: "۲ دقیقه پیش", }, { id: "2", customerName: "علی رضایی", customerLocation: "اصفهان", productName: "کیف چرم دوشی", productImage: "/block-media/shadcnblocks/block/ecommerce/clothes/maroon-leather-handbag.png", timeAgo: "۵ دقیقه پیش", }, { id: "3", customerName: "مریم حسینی", customerLocation: "شیراز", productName: "هودی نخی", productImage: "/block-media/shadcnblocks/block/ecommerce/clothes/black-hoodie-against-light-background.png", timeAgo: "۸ دقیقه پیش", }, ]; interface LivePurchase1Props { purchases?: Purchase[]; autoRotate?: boolean; rotateInterval?: number; className?: string; } const LivePurchase1 = ({ purchases = DEFAULT_PURCHASES, autoRotate = true, rotateInterval = 5000, className, }: LivePurchase1Props) => { const [currentIndex, setCurrentIndex] = useState(0); const [isVisible, setIsVisible] = useState(true); const [isAnimating, setIsAnimating] = useState(false); useEffect(() => { if (!autoRotate || purchases.length <= 1) return; const timer = setInterval(() => { setIsAnimating(true); setTimeout(() => { setCurrentIndex((prev) => (prev + 1) % purchases.length); setIsAnimating(false); }, 300); }, rotateInterval); return () => clearInterval(timer); }, [autoRotate, rotateInterval, purchases.length]); if (!isVisible) return null; const current = purchases[currentIndex]; return (
{current.customerName}{" "} از{" "} {current.customerLocation}
همین الان{" "} {current.productName} {" "} را خرید کرد
{current.timeAgo}