import { Bell, ChevronRight, RefreshCcw } from "lucide-react"; import * as React from "react"; import { useTranslation } from "react-i18next"; import { Link, useMatches, useRevalidator } from "react-router"; import { NotificationItem, NotificationItemDivider, NotificationsList, } from "~/features/notifications/components/NotificationList"; import { NOTIFICATIONS } from "~/features/notifications/notifications-contants"; import type { RootLoaderData } from "~/root"; import { NOTIFICATIONS_URL } from "~/utils/urls"; import { useMarkNotificationsAsSeen } from "../../features/notifications/notifications-hooks"; import { SendouButton } from "../elements/Button"; import styles from "./NotificationPopover.module.css"; export type LoaderNotification = NonNullable< RootLoaderData["notifications"] >[number]; export function useNotifications() { const [root] = useMatches(); const notifications = (root.data as RootLoaderData | undefined) ?.notifications; const unseenIds = React.useMemo( () => notifications ?.filter((notification) => !notification.seen) .map((notification) => notification.id) ?? [], [notifications], ); return { notifications, unseenIds }; } export function NotificationContent({ notifications, unseenIds, onClose, }: { notifications: LoaderNotification[]; unseenIds: number[]; onClose?: () => void; }) { const { t } = useTranslation(["common"]); const { revalidate, state } = useRevalidator(); useMarkNotificationsAsSeen(unseenIds); return ( <>