'use client'; import { useState, useEffect } from 'react'; import { useRouter } from 'next/navigation'; import type { Notification, NotificationAction } from '@gridpilot/notifications/application'; import { Bell, AlertTriangle, Shield, Vote, Trophy, Users, Flag, AlertCircle, Clock, } from 'lucide-react'; import Button from '@/components/ui/Button'; interface ModalNotificationProps { notification: Notification; onAction: (notification: Notification, actionId?: string) => void; } const notificationIcons: Record = { protest_filed: AlertTriangle, protest_defense_requested: Shield, protest_vote_required: Vote, penalty_issued: AlertTriangle, race_results_posted: Trophy, league_invite: Users, race_reminder: Flag, }; const notificationColors: Record = { protest_filed: { bg: 'bg-red-500/10', border: 'border-red-500/50', text: 'text-red-400', glow: 'shadow-[0_0_60px_rgba(239,68,68,0.3)]', }, protest_defense_requested: { bg: 'bg-warning-amber/10', border: 'border-warning-amber/50', text: 'text-warning-amber', glow: 'shadow-[0_0_60px_rgba(245,158,11,0.3)]', }, protest_vote_required: { bg: 'bg-primary-blue/10', border: 'border-primary-blue/50', text: 'text-primary-blue', glow: 'shadow-[0_0_60px_rgba(25,140,255,0.3)]', }, penalty_issued: { bg: 'bg-red-500/10', border: 'border-red-500/50', text: 'text-red-400', glow: 'shadow-[0_0_60px_rgba(239,68,68,0.3)]', }, }; export default function ModalNotification({ notification, onAction, }: ModalNotificationProps) { const [isVisible, setIsVisible] = useState(false); const router = useRouter(); useEffect(() => { // Animate in const timeout = setTimeout(() => setIsVisible(true), 10); return () => clearTimeout(timeout); }, []); const handleAction = (action: NotificationAction) => { onAction(notification, action.actionId); if (action.href) { router.push(action.href); } }; const handlePrimaryAction = () => { onAction(notification, 'primary'); if (notification.actionUrl) { router.push(notification.actionUrl); } }; const Icon = notificationIcons[notification.type] || AlertCircle; const colors = notificationColors[notification.type] || { bg: 'bg-warning-amber/10', border: 'border-warning-amber/50', text: 'text-warning-amber', glow: 'shadow-[0_0_60px_rgba(245,158,11,0.3)]', }; // Check if there's a deadline const deadline = notification.data?.deadline; const hasDeadline = deadline instanceof Date; return (
{/* Header with pulse animation */}
{/* Animated pulse ring */}

Action Required

{notification.title}

{/* Body */}

{notification.body}

{/* Deadline warning */} {hasDeadline && (

Response Required

Please respond by {deadline.toLocaleDateString()} at {deadline.toLocaleTimeString()}

)} {/* Additional context from data */} {notification.data?.protestId && (

Related Protest

{notification.data.protestId}

)}
{/* Actions */}
{notification.actions && notification.actions.length > 0 ? (
{notification.actions.map((action, index) => ( ))}
) : (
)}
{/* Cannot dismiss warning */} {notification.requiresResponse && (

⚠️ This notification requires your action and cannot be dismissed

)}
); }