"use client"; import { useParams } from "next/navigation"; import Link from "next/link"; import { ArrowLeft, Mail, MessageSquare, Terminal } from "lucide-react"; import { SeverityBadge } from "@/components/ui/badge"; import { useAlert, useMarkAlertRead, useResolveAlert } from "@/hooks/use-alerts"; import { useCompany } from "@/hooks/use-companies"; import { formatDateTime } from "@/lib/format"; import type { NotificationDeliveryStatus } from "@/lib/types"; const DELIVERY_STATUS_CLASSES: Record = { sent: "bg-green-100 text-green-800", failed: "bg-red-100 text-red-800", pending: "bg-slate-200 text-slate-700", }; const PROVIDER_ICON = { smtp: Mail, twilio_sms: MessageSquare, console: Terminal, } as const; export default function AlertDetailPage() { const params = useParams<{ id: string }>(); const { data: alert, isLoading } = useAlert(params.id); const { data: company } = useCompany(alert?.company_id); const markRead = useMarkAlertRead(); const resolve = useResolveAlert(); if (isLoading || !alert) { return

Loading…

; } return (
Back to alerts
{!alert.read && ( Unread )} {alert.resolved && ( Resolved )} {Math.round(alert.confidence * 100)}% confidence

{alert.title}

{company ? ( {company.name} ) : ( "—" )}{" "} · {formatDateTime(alert.created_at)}

What changed

{alert.summary}

Why it matters

{alert.why_it_matters}

{!alert.read && ( )} {!alert.resolved && ( )}

Notification deliveries

{alert.deliveries.length === 0 ? (

No destinations were notified for this alert.

) : (
    {alert.deliveries.map((delivery) => { const Icon = PROVIDER_ICON[delivery.provider as keyof typeof PROVIDER_ICON] ?? Terminal; return (
  • {delivery.provider.replace("_", " ")} {delivery.error_message && ( {delivery.error_message} )}
    {delivery.status}
  • ); })}
)}
); }