story-research-zapwall/components/NotificationPanel.tsx
2026-01-06 14:17:55 +01:00

70 lines
2.0 KiB
TypeScript

import type { Notification } from '@/types/notifications'
import { NotificationItem } from './NotificationItem'
import { NotificationPanelHeader } from './NotificationPanelHeader'
import { t } from '@/lib/i18n'
interface NotificationPanelProps {
notifications: Notification[]
unreadCount: number
onNotificationClick: (notification: Notification) => void
onDelete: (id: string) => void
onMarkAllAsRead: () => void
onClose: () => void
}
function NotificationList({ notifications, onNotificationClick, onDelete }: {
notifications: Notification[]
onNotificationClick: (notification: Notification) => void
onDelete: (id: string) => void
}): React.ReactElement {
if (notifications.length === 0) {
return (
<div className="p-8 text-center text-gray-500">
<p>{t('notification.empty')}</p>
</div>
)
}
return (
<div className="divide-y divide-gray-100">
{notifications.map((notification) => (
<NotificationItem
key={notification.id}
notification={notification}
onNotificationClick={onNotificationClick}
onDelete={onDelete}
/>
))}
</div>
)
}
export function NotificationPanel({
notifications,
unreadCount,
onNotificationClick,
onDelete,
onMarkAllAsRead,
onClose,
}: NotificationPanelProps): React.ReactElement {
return (
<>
<div className="fixed inset-0 z-40 bg-black bg-opacity-50" onClick={onClose} />
<div className="absolute right-0 mt-2 w-96 bg-white rounded-lg shadow-xl border border-gray-200 z-50 max-h-[600px] flex flex-col">
<NotificationPanelHeader
unreadCount={unreadCount}
onMarkAllAsRead={onMarkAllAsRead}
onClose={onClose}
/>
<div className="overflow-y-auto flex-1">
<NotificationList
notifications={notifications}
onNotificationClick={onNotificationClick}
onDelete={onDelete}
/>
</div>
</div>
</>
)
}