/** * @component SalesNotification * @purpose Live purchase toast notification popup matching Screenshots 1, 4 & reference specs. * @a11y Accessible dismissal button */ 'use client'; import { useState, useEffect } from 'react'; import Image from 'next/image'; import { X, CheckCircle } from 'lucide-react'; export function SalesNotification() { const [visible, setVisible] = useState(false); const [currentNotification, setCurrentNotification] = useState({ name: 'Swaraa (California)', item: 'HP LaserJet P1108 Mono Single Function Laser Printer', time: '46 minutes ago', image: '', }); const notifications = [ { name: 'Swaraa (California)', item: 'HP LaserJet P1108 Mono Single Function Laser Printer', time: '46 minutes ago', image: '', }, { name: 'Nia (London)', item: 'Apple Airpods Pro (2nd Gen) with MagSafe Charging Case', time: '25 minutes ago', image: '', }, { name: 'Liam (New York)', item: 'Sony WH-1000XM5 Wireless Headphones', time: '12 minutes ago', image: '', }, ]; useEffect(() => { let index = 0; const interval = setInterval(() => { index = (index + 1) % notifications.length; setCurrentNotification(notifications[index]); setVisible(true); setTimeout(() => setVisible(false), 5000); }, 12000); // Initial show after 3 seconds const initialTimer = setTimeout(() => { setVisible(true); setTimeout(() => setVisible(false), 5000); }, 3000); return () => { clearInterval(interval); clearTimeout(initialTimer); }; }, []); if (!visible) return null; return (
{currentNotification.item}
{currentNotification.name} purchased
{currentNotification.item}
{currentNotification.time} Verified
); }