'use client'; import * as React from 'react'; import { useTranslation } from 'react-i18next'; import { Card, CardHeader, CardTitle, CardContent, CardFooter, CardAction } from '../../ui/card'; import { Avatar, AvatarFallback, AvatarImage } from '../../ui/avatar'; import { Badge } from '../../ui/badge'; import { Button } from '../../ui/button'; import { cn } from '../../shared/utils'; export type NotificationType = 'info' | 'warning' | 'success' | 'error' | 'default'; export interface NotificationItem { id: string; title: string; message: string; time: string; read?: boolean; type?: NotificationType; user?: { name: string; initials: string; avatar?: string }; } export interface NotificationCardProps extends React.HTMLAttributes { title?: string; items: NotificationItem[]; unreadCount?: number; onMarkAllRead?: () => void; onViewAll?: () => void; maxItems?: number; } const typeVariant: Record['variant']> = { info: 'info', warning: 'warning', success: 'success', error: 'destructive', default: 'secondary', }; export function NotificationCard({ title, items, unreadCount, onMarkAllRead, onViewAll, maxItems = 4, className, ...props }: NotificationCardProps) { const { t } = useTranslation(); const visible = items.slice(0, maxItems); const count = unreadCount ?? items.filter(i => !i.read).length; const cardTitle = title ?? t('notificationCard.title'); return (
{cardTitle} {count > 0 && ( {count} )}
{onMarkAllRead && count > 0 && ( )}
    {visible.map(item => (
  • {item.user ? ( {item.user.avatar && } {item.user.initials} ) : (
    )}

    {item.title}

    {item.type && item.type !== 'default' && ( {item.type} )}

    {item.message}

    {item.time}

    {!item.read &&
    }
  • ))}
{onViewAll && ( )}
); }