'use client' import { useState } from 'react' import { Bell, CheckCheck, Trash2, Inbox } from 'lucide-react' import { cn } from '@/lib/utils' import { useFinanzasStore } from '@/lib/store' import { AlertItem } from './AlertItem' import { AlertBadge } from './AlertBadge' type TabType = 'all' | 'unread' export function AlertPanel() { const [activeTab, setActiveTab] = useState('all') const alerts = useFinanzasStore((state) => state.alerts) const markAlertAsRead = useFinanzasStore((state) => state.markAlertAsRead) const deleteAlert = useFinanzasStore((state) => state.deleteAlert) const clearAllAlerts = useFinanzasStore((state) => state.clearAllAlerts) const unreadAlerts = alerts.filter((alert) => !alert.isRead) const unreadCount = unreadAlerts.length const displayedAlerts = activeTab === 'unread' ? unreadAlerts : alerts const handleMarkAllRead = () => { unreadAlerts.forEach((alert) => { markAlertAsRead(alert.id) }) } const handleClearAll = () => { clearAllAlerts() } return (
{/* Header */}
{unreadCount > 0 && }

Alertas

{unreadCount > 0 && ( ({unreadCount}) )}
{unreadCount > 0 && ( )} {alerts.length > 0 && ( )}
{/* Tabs */} {alerts.length > 0 && (
)} {/* Alert List */}
{displayedAlerts.length === 0 ? (

{activeTab === 'unread' ? 'No tienes alertas sin leer' : 'No tienes alertas'}

Las alertas aparecerán cuando haya pagos próximos o eventos importantes

) : (
{displayedAlerts.map((alert) => ( markAlertAsRead(alert.id)} onDelete={() => deleteAlert(alert.id)} /> ))}
)}
) }