"use client"; import { CheckCircle2, ShoppingBag, Users, 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 { customerInitial: string; productName: string; timeAgo: string; } interface LivePurchase3Props { purchases?: Purchase[]; viewerCount?: number; purchasesToday?: number; className?: string; } const DEFAULT_PURCHASES: Purchase[] = [ { customerInitial: "س", productName: "هندزفری بیسیم", timeAgo: "همین الان", }, { customerInitial: "م", productName: "ساعت هوشمند پرو", timeAgo: "۱ دقیقه پیش", }, { customerInitial: "ع", productName: "پایه لپتاپ", timeAgo: "۲ دقیقه پیش", }, ]; const formatCount = (value: number) => new Intl.NumberFormat("fa-IR").format(value); const LivePurchase3 = ({ purchases = DEFAULT_PURCHASES, viewerCount = 47, purchasesToday = 156, className, }: LivePurchase3Props) => { const [currentIndex, setCurrentIndex] = useState(0); const [isVisible, setIsVisible] = useState(true); const [showNotification, setShowNotification] = useState(true); useEffect(() => { if (purchases.length <= 1) return; const timer = setInterval(() => { setShowNotification(false); setTimeout(() => { setCurrentIndex((prev) => (prev + 1) % purchases.length); setShowNotification(true); }, 300); }, 4000); return () => clearInterval(timer); }, [purchases.length]); if (!isVisible) return null; const current = purchases[currentIndex]; return (
خرید جدید!
یک نفر {current.productName} را خرید
{current.timeAgo}