import { useState } from 'react'; import { SectionHeader, Button } from '@cameleer/design-system'; import { PageLoader } from '../../components/PageLoader'; import { useAlerts, type AlertDto } from '../../api/queries/alerts'; import { AlertRow } from './AlertRow'; import css from './alerts-page.module.css'; type AlertState = NonNullable; const STATE_FILTERS: Array<{ label: string; values: AlertState[] }> = [ { label: 'Open', values: ['PENDING', 'FIRING', 'ACKNOWLEDGED'] }, { label: 'Firing', values: ['FIRING'] }, { label: 'Acked', values: ['ACKNOWLEDGED'] }, { label: 'All', values: ['PENDING', 'FIRING', 'ACKNOWLEDGED', 'RESOLVED'] }, ]; export default function AllAlertsPage() { const [filterIdx, setFilterIdx] = useState(0); const filter = STATE_FILTERS[filterIdx]; const { data, isLoading, error } = useAlerts({ state: filter.values, limit: 200 }); if (isLoading) return ; if (error) return
Failed to load alerts: {String(error)}
; const rows = data ?? []; return (
All alerts
{STATE_FILTERS.map((f, i) => ( ))}
{rows.length === 0 ? (
No alerts match this filter.
) : ( rows.map((a) => ) )}
); }