import { Link } from 'react-router-dom'; import { formatDistanceToNow } from 'date-fns'; import Layout from '../components/Layout'; import { useNotifications, useMarkNotificationsRead } from '../api/queries'; import type { Notification } from '../../../shared/types'; const KIND_LABELS: Record = { ASSIGNED: 'assigned to you', MENTION: 'mentioned you', RESOLVED: 'was resolved', TICKET_CREATED: 'was created', STATUS_CHANGED: 'status changed', COMMENT: 'new comment', }; interface NotifData { displayId?: string; title?: string; byName?: string; } function summary(n: Notification): { label: string; href: string } { const data = (n.data ?? {}) as NotifData; const action = KIND_LABELS[n.kind] ?? n.kind.toLowerCase(); const label = data.title ? `${data.title} — ${action}` : `Ticket ${action}`; const href = data.displayId ? `/${data.displayId}` : '/notifications'; return { label, href }; } export default function Notifications() { const { data: notifications = [], isLoading } = useNotifications(); const markRead = useMarkNotificationsRead(); const unread = notifications.filter((n) => !n.readAt); return ( 0 ? ( ) : null } > {isLoading ? (

Loading…

) : notifications.length === 0 ? (

You're all caught up

) : ( )}
); }