import { useState, useEffect } from 'react'; import { useNotifications } from '../contexts/NotificationContext'; // Enhanced confetti component for celebrations function ConfettiEffect() { const [particles, setParticles] = useState>([]); useEffect(() => { // Generate colorful paper-roll confetti particles const colors = [ '#ff7a00', '#ffdd00', '#ff3366', '#33ff66', '#3366ff', '#ff6633', '#9933ff', '#ff3399', '#33ffdd', '#ffaa33', '#aa33ff', '#33aaff' ]; const newParticles = Array.from({length: 50}, (_, i) => ({ id: i, left: Math.random() * 100, color: colors[Math.floor(Math.random() * colors.length)], delay: Math.random() * 1.5, size: 6 + Math.random() * 6, // 6-12px shape: ['rectangle', 'circle', 'curl'][Math.floor(Math.random() * 3)] as 'rectangle' | 'circle' | 'curl', rotation: Math.random() * 360, duration: 3 + Math.random() * 1.5 // 3-4.5 seconds })); setParticles(newParticles); // Clean up after animation completes setTimeout(() => setParticles([]), 5000); }, []); return (
{particles.map(particle => (
))}
); } interface NotificationItemProps { id: string; type: 'success' | 'warning' | 'info' | 'flag'; title: string; message: string; flag?: string; duration?: number; vulnerabilityType?: string; points?: number; onRemove: (id: string) => void; } function NotificationItem({ id, type, title, message, flag, duration = 60000, vulnerabilityType, points, onRemove }: NotificationItemProps) { const [timeLeft, setTimeLeft] = useState(duration); const [isVisible, setIsVisible] = useState(false); const [showConfetti, setShowConfetti] = useState(false); useEffect(() => { // Animation entrance setTimeout(() => setIsVisible(true), 100); // Show confetti for flag discoveries if (type === 'flag') { setShowConfetti(true); setTimeout(() => setShowConfetti(false), 5000); } const interval = setInterval(() => { setTimeLeft(prev => { if (prev <= 1000) { onRemove(id); return 0; } return prev - 1000; }); }, 1000); return () => clearInterval(interval); }, [id, onRemove, type]); const progressPercentage = (timeLeft / duration) * 100; const secondsLeft = Math.ceil(timeLeft / 1000); const getIcon = () => { switch (type) { case 'flag': return ( ); case 'success': return ( ); case 'warning': return ( ); case 'info': return ( ); default: return ( ); } }; const getColorClasses = () => { switch (type) { case 'flag': return 'bg-hacksmith-gray/95 border-hacksmith-orange/50 text-white'; case 'success': return 'bg-hacksmith-gray/95 border-green-400/50 text-green-100'; case 'warning': return 'bg-hacksmith-gray/95 border-yellow-400/50 text-yellow-100'; case 'info': return 'bg-hacksmith-gray/95 border-blue-400/50 text-blue-100'; default: return 'bg-hacksmith-gray/95 border-gray-400/50 text-gray-100'; } }; return ( <> {/* Confetti effect for flag discoveries */} {showConfetti && }
{/* Header with enhanced styling */}
{/* Background accent */}
{getIcon()}

{title}

{vulnerabilityType && (
{vulnerabilityType} VULNERABILITY
)}
{/* Enhanced Content */}

{message}

{flag && (
{/* Subtle background pattern */}
YOUR FLAG:
{flag}
)}
{/* Simple Progress bar - reverse loading */}
); } export default function NotificationContainer() { const { notifications, removeNotification } = useNotifications(); return (
{notifications.map((notification) => ( ))}
); }