// src/components/cart/CartNotification.tsx 'use client'; import { useEffect, useState } from 'react'; import { formatPrice } from '@/lib/woocommerce'; import { Button } from '@/components/ui/button'; import { X, CheckCircle, ShoppingBag } from 'lucide-react'; import Image from 'next/image'; import Link from 'next/link'; import { cn } from '@/lib/utils'; interface CartNotificationProps { isVisible: boolean; onClose: () => void; item?: { name: string; price: string; image: string; quantity: number; }; } export function CartNotification({ isVisible, onClose, item }: CartNotificationProps) { const [isAnimating, setIsAnimating] = useState(false); useEffect(() => { if (isVisible) { setIsAnimating(true); // Auto-fermeture après 4 secondes const timer = setTimeout(() => { onClose(); }, 4000); return () => clearTimeout(timer); } else { setIsAnimating(false); } }, [isVisible, onClose]); if (!isVisible || !item) return null; return (
{/* Header */}
Ajouté au panier
{/* Product */}
{item.name}

{item.name}

Quantité: {item.quantity}

{formatPrice(parseFloat(item.price) * item.quantity)}

{/* Actions */}
); } // Hook pour gérer les notifications export function useCartNotification() { const [notification, setNotification] = useState<{ isVisible: boolean; item?: { name: string; price: string; image: string; quantity: number; }; }>({ isVisible: false }); const showNotification = (item: { name: string; price: string; image: string; quantity: number; }) => { console.log('📢 Affichage notification pour:', item.name); setNotification({ isVisible: true, item }); }; const hideNotification = () => { console.log('❌ Fermeture notification'); setNotification({ isVisible: false }); }; return { notification, showNotification, hideNotification }; }