import { useQuery } from '@tanstack/react-query'; import { getNotifications } from '../api/client'; import PageHeader from '../components/PageHeader'; import DataTable from '../components/DataTable'; import type { Column } from '../components/DataTable'; import StatusBadge from '../components/StatusBadge'; import ErrorState from '../components/ErrorState'; import { formatDateTime } from '../api/utils'; import type { Notification } from '../api/types'; export default function NotificationsPage() { const { data, isLoading, error, refetch } = useQuery({ queryKey: ['notifications'], queryFn: () => getNotifications(), refetchInterval: 30000, }); const columns: Column[] = [ { key: 'type', label: 'Type', render: (n) => {n.type.replace(/([A-Z])/g, ' $1').trim()}, }, { key: 'status', label: 'Status', render: (n) => }, { key: 'channel', label: 'Channel', render: (n) => {n.channel} }, { key: 'recipient', label: 'Recipient', render: (n) => {n.recipient} }, { key: 'message', label: 'Message', render: (n) => {n.message || n.subject}, }, { key: 'cert', label: 'Certificate', render: (n) => {n.certificate_id || '—'} }, { key: 'created', label: 'Sent', render: (n) => {formatDateTime(n.created_at)} }, ]; return ( <>
{error ? ( refetch()} /> ) : ( )}
); }