import React, { useMemo } from 'react'; import { useTranslation } from '../../i18n'; import type { InAppNotification } from '../../store/inAppNotificationStore'; import InAppNotificationItem from './InAppNotificationItem'; import { groupByDay } from './notificationModel'; interface NotificationDayListProps { notifications: InAppNotification[]; /** Closes the bell's panel after a notification led somewhere. */ onClose?: () => void; /** The bell's panel: headings stick to its top and the days need no cards of their own. */ compact?: boolean; } /** * The notifications cut into days, each under its heading (Today, Yesterday, * a weekday, then the date). On the page every day is a card of its own; in * the bell's panel the headings stay at the top while the day scrolls by. */ export default function NotificationDayList({ notifications, onClose, compact = false, }: NotificationDayListProps): React.ReactElement { const { locale } = useTranslation(); const groups = useMemo(() => groupByDay(notifications, locale), [notifications, locale]); return (
{groups.map((group) => (

{group.label}

{group.items.map((n) => ( ))}
))}
); }