"use client"; import React, { useState, useEffect } from 'react'; import Image from 'next/image'; import { AnimatePresence, motion } from 'framer-motion'; import { CheckCircle2, X } from 'lucide-react'; interface Purchase { name: string; location: string; product: string; time: string; image: string; } const mockPurchases: Purchase[] = [ { name: 'Ben', location: 'New York', product: 'HP (23.8 Inch) with IPS Panel Technology', time: '3 hours ago', image: '' }, { name: 'Swaraa', location: 'California', product: 'HP LaserJet P1108 Mono Single Function Laser Printer', time: '46 minutes ago', image: '' }, { name: 'Alex', location: 'London', product: 'SwapME Braided Nylon Woven Smart Watch', time: '12 minutes ago', image: '' }, { name: 'Hiroshi', location: 'Tokyo', product: 'Ceptics India to Europe Travel Adapter Plug', time: '5 minutes ago', image: '' } ]; export const LiveToast: React.FC = () => { const [currentIndex, setCurrentIndex] = useState(0); const [isVisible, setIsVisible] = useState(false); useEffect(() => { const initialTimeout = setTimeout(() => { setIsVisible(true); }, 4000); const interval = setInterval(() => { setIsVisible(false); setTimeout(() => { setCurrentIndex((prev) => (prev + 1) % mockPurchases.length); setIsVisible(true); }, 1000); }, 15000); return () => { clearTimeout(initialTimeout); clearInterval(interval); }; }, []); if (!mockPurchases.length) return null; const currentPurchase = mockPurchases[currentIndex]; return ( {isVisible && ( {currentPurchase.image ? ( {currentPurchase.product} ) : (
iF
)}

{currentPurchase.name} from{' '} {currentPurchase.location}

{currentPurchase.product}

{currentPurchase.time}
Verified
)}
); };