import { useEffect, useMemo, useState } from 'react'; import type { Dispatch, SetStateAction } from 'react'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { Card } from '../components/Card'; import { Badge } from '../components/Badge'; import { IncidentCenterSkeleton } from '../components/Skeleton'; import { useConfig, externalApiFetch } from '../hooks/useApi'; import { useNotify } from '../hooks/useNotify'; type IncidentStatus = 'draft' | 'investigating' | 'ready_to_report' | 'reported' | 'closed'; type IncidentPriority = 'critical' | 'high' | 'medium' | 'low'; type DeadlineState = 'ok' | 'warning' | 'overdue'; type NotificationType = 'early_warning' | 'vulnerability_notification' | 'final_report'; interface IncidentListItem { id: string; status: IncidentStatus; priority: IncidentPriority; product_name: string; completeness_score: number; report_deadline_at: string | null; created_at: string; minutes_remaining: number | null; deadline_state: DeadlineState; } interface IncidentCase extends IncidentListItem { first_awareness_at: string; early_warning_deadline_at: string | null; vuln_notification_deadline_at: string | null; final_report_deadline_at: string | null; early_warning_submitted_at: string | null; vuln_notification_submitted_at: string | null; final_report_submitted_at: string | null; reported_at: string | null; product_version: string; impact_summary: string; mitigation_summary: string; affected_scope: string; contact_name: string; contact_email: string; } interface IncidentNotification { id: string; notification_type: NotificationType; submitted_at: string | null; created_at: string; content: Record | null; } interface IncidentAudit { id: string; action: string; field_name: string | null; created_at: string; } interface IncidentDetailResponse { incident: IncidentCase; notifications: IncidentNotification[]; audit_log: IncidentAudit[]; } interface IncidentDraft { product_name: string; product_version: string; contact_name: string; contact_email: string; impact_summary: string; mitigation_summary: string; affected_scope: string; } const NOTIFICATION_LABELS: Record = { early_warning: 'Early Warning', vulnerability_notification: 'Vulnerability Notification', final_report: 'Final Report', }; const NOTIFICATION_DEADLINES: Record = { early_warning: 'Due within 24h of discovery', vulnerability_notification: 'Due within 72h of discovery', final_report: 'Due within 14 days of discovery', }; const NOTIFICATION_GUIDANCE: Record = { early_warning: { who: 'ENISA (via the single reporting platform) and the CSIRT of the EU member state where you are established.', why: 'CRA Article 14(2)(a) requires manufacturers to notify ENISA within 24 hours of becoming aware of an actively exploited vulnerability, so coordinated response can begin immediately.', what: 'A short notification indicating: the vulnerability exists, it is being actively exploited, and initial assessment of severity. No detailed fix or analysis required yet.', reference: 'CRA Article 14(2)(a)', }, vulnerability_notification: { who: 'ENISA and your national CSIRT. If users are at immediate risk, you should also notify affected users directly.', why: 'CRA Article 14(2)(b) requires a follow-up notification within 72 hours containing a general assessment of the vulnerability, including its severity and impact, and whether a fix or mitigation is available.', what: 'Assessment of severity (CVSS if available), scope of affected products/versions, whether a patch or workaround exists, and any known indicators of compromise.', reference: 'CRA Article 14(2)(b)', }, final_report: { who: 'ENISA, your national CSIRT, and (if applicable) the market surveillance authority of the EU member states where the product is made available.', why: 'CRA Article 14(2)(c) requires a final report within 14 days of discovery for vulnerabilities (30 days for severe incidents), including root cause analysis and remediation measures taken.', what: 'Root cause analysis, full description of the vulnerability and exploitation, list of affected products/versions, remediation measures taken (patches released, mitigations), lessons learned, and any residual risk.', reference: 'CRA Article 14(2)(c)', }, }; const INVALID_EMAIL_ERROR = 'Please enter a valid contact email before saving.'; export function IncidentCenter() { const config = useConfig(); const isPremium = config.plan !== 'free'; if (!isPremium) { return ; } return ; } function IncidentCenterUpsell() { return (

Incident Center

Guided CRA Article 14 incident workflows with deadline timers, notification drafts, and evidence export.

Missing a reporting deadline is a regulatory violation

The EU Cyber Resilience Act requires you to notify your national CSIRT within 24 hours of becoming aware of an actively-exploited vulnerability — and submit a full vulnerability notification within 72 hours. A final report is due within 14 days. Missing these deadlines can result in fines of up to €15 million or 2.5% of global turnover. The Incident Center makes it impossible to miss them.

The CRA Article 14 reporting clock starts the moment you become aware

0 – 24h
Early Warning
Notify your national CSIRT that an actively-exploited vulnerability exists. Basic info only — no full analysis required yet.
0 – 72h
Vulnerability Notification
Submit a more detailed report including impact, affected scope, and mitigation steps taken or planned.
0 – 14 days
Final Report
Comprehensive report covering the full incident, root cause, remediation, and lessons learned.

The Incident Center tracks all three deadlines with live countdown timers and generates draft notification text for each stage — pre-filled from your plugin and vulnerability data.

⏳

Live deadline countdown timers

Each incident shows a live timer counting down to the next required notification. Colour-coded warnings kick in when deadlines are near — no spreadsheet juggling, no calendar reminders to forget.

📄

Auto-generated notification drafts

Click "Generate Draft" and receive ready-to-send notification text for each stage. Drafts are pre-filled with your product name, version, CVE ID, impact summary, and contact details. Copy to clipboard and email to your CSIRT in seconds.

📄

One-click incident from Scanner

When the Scanner detects a critical or high-severity vulnerability, click "Report Incident" and an Incident case is automatically created with the CVE ID, severity, and impact pre-filled. You start the Article 14 clock immediately with zero manual data entry.

🔒

Evidence pack export (Pro)

Export a structured JSON evidence pack containing all incident data, notification drafts, submission timestamps, and audit trail. Attach it to CSIRT submissions or keep it for your internal compliance records. Auditors love it; regulators expect it.

📋

Full audit trail

Every status change, field update, and submission is logged with a timestamp. The audit log shows exactly what you did and when — the evidence trail CRA Article 14 requires you to maintain for a minimum of five years.

🌐

Direct links to national CSIRTs

Built-in links to ENISA's Single Reporting Platform, the EU CSIRT directory, and MITRE's CVE request form — everything you need to file a compliant report without hunting through government websites under pressure.

Which CRA articles does this help with?

Article 14(1) Manufacturers must notify relevant market surveillance authorities and the public about actively exploited vulnerabilities without undue delay.
Article 14(2) Early warning (24h), vulnerability notification (72h), and final report (14 days) to national CSIRT or ENISA SRP.
Article 14(8) Records of notifications must be maintained and made available to authorities on request.
Basic
$19/month
  • Incident Center access
  • Live deadline countdowns
  • All 3 notification stages
  • Auto-generated drafts
  • Audit trail
  • Vulnerability Scanner access
Get Basic
Most popular
Pro
$45/month
  • Incident Center access
  • Live deadline countdowns
  • All 3 notification stages
  • Auto-generated drafts
  • Full audit trail
  • Evidence pack export
  • Vulnerability Scanner (20 plugins)
  • Dashboard compliance score
  • Priority support
Get Pro
); } const SESSION_KEY = 'cra_selected_incident'; function PremiumIncidentCenter() { const queryClient = useQueryClient(); const config = useConfig(); const { confirm, toast, NotifyPortal } = useNotify(); const [selectedIncidentId, setSelectedIncidentIdRaw] = useState( () => sessionStorage.getItem(SESSION_KEY) ); const setSelectedIncidentId = (id: string | null) => { if (id) sessionStorage.setItem(SESSION_KEY, id); else sessionStorage.removeItem(SESSION_KEY); setSelectedIncidentIdRaw(id); }; const [draft, setDraft] = useState(null); const [draftDirty, setDraftDirty] = useState(false); const [deadlineFilter, setDeadlineFilter] = useState<'all' | DeadlineState>('all'); const [statusFilter, setStatusFilter] = useState<'all' | IncidentStatus>('all'); const [error, setError] = useState(null); const [saveSuccess, setSaveSuccess] = useState(false); const [viewingDraftType, setViewingDraftType] = useState(null); // ── Queries ────────────────────────────────────────────────────────────────── const incidentsQuery = useQuery({ queryKey: ['incidents'], queryFn: async () => { const res = await externalApiFetch<{ data: IncidentListItem[] }>('/api/dashboard?action=incidents_list'); return res.data || []; }, refetchInterval: 60_000, // refresh deadline timers every minute }); const detailQuery = useQuery({ queryKey: ['incident-detail', selectedIncidentId], enabled: Boolean(selectedIncidentId), queryFn: async () => { const res = await externalApiFetch<{ data: IncidentDetailResponse }>( `/api/dashboard?action=incidents_detail&incident_id=${encodeURIComponent(selectedIncidentId || '')}` ); return res.data; }, }); // ── Mutations ──────────────────────────────────────────────────────────────── const startIncidentMutation = useMutation({ mutationFn: async () => { const res = await externalApiFetch<{ data: IncidentCase }>('/api/dashboard', { method: 'POST', body: JSON.stringify({ action: 'incidents_start' }), }); return res.data; }, onSuccess: async (incident) => { await queryClient.invalidateQueries({ queryKey: ['incidents'] }); setSelectedIncidentId(incident.id); setError(null); }, onError: (err) => setError(err.message || 'Failed to start incident'), }); const saveIncidentMutation = useMutation({ mutationFn: async () => { if (!selectedIncidentId || !draft) throw new Error('No selected incident'); await externalApiFetch('/api/dashboard', { method: 'POST', body: JSON.stringify({ action: 'incidents_save_step', incident_id: selectedIncidentId, updates: draft, }), }); }, onSuccess: async () => { setDraftDirty(false); setSaveSuccess(true); setTimeout(() => setSaveSuccess(false), 2000); await queryClient.invalidateQueries({ queryKey: ['incidents'] }); await queryClient.invalidateQueries({ queryKey: ['incident-detail', selectedIncidentId] }); }, onError: (err) => setError(err.message || 'Failed to save incident'), }); const generateDraftMutation = useMutation({ mutationFn: async (notificationType) => { if (!selectedIncidentId) throw new Error('No selected incident'); await externalApiFetch('/api/dashboard', { method: 'POST', body: JSON.stringify({ action: 'incidents_generate_notification', incident_id: selectedIncidentId, notification_type: notificationType, }), }); }, onSuccess: async () => { await queryClient.invalidateQueries({ queryKey: ['incident-detail', selectedIncidentId] }); }, onError: (err) => setError(err.message || 'Failed to generate notification'), }); const markSubmittedMutation = useMutation({ mutationFn: async (notificationType) => { if (!selectedIncidentId) throw new Error('No selected incident'); await externalApiFetch('/api/dashboard', { method: 'POST', body: JSON.stringify({ action: 'incidents_mark_submitted', incident_id: selectedIncidentId, notification_type: notificationType, channel: 'manual', }), }); }, onSuccess: async () => { await queryClient.invalidateQueries({ queryKey: ['incidents'] }); await queryClient.invalidateQueries({ queryKey: ['incident-detail', selectedIncidentId] }); }, onError: (err) => setError(err.message || 'Failed to mark notification submitted'), }); const exportEvidenceMutation = useMutation({ mutationFn: async () => { if (!selectedIncidentId) throw new Error('No selected incident'); const res = await externalApiFetch<{ data: unknown }>('/api/dashboard', { method: 'POST', body: JSON.stringify({ action: 'incidents_export', incident_id: selectedIncidentId }), }); return res.data; }, onSuccess: (data) => { const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; const safeName = (selectedIncident?.product_name || 'incident') .toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, ''); const date = new Date().toISOString().slice(0, 10); a.download = `cra-evidence-${safeName}-${date}.json`; a.click(); URL.revokeObjectURL(url); }, onError: (err) => setError(err.message || 'Failed to export evidence'), }); const deleteIncidentMutation = useMutation({ mutationFn: async (incidentId) => { await externalApiFetch('/api/dashboard', { method: 'POST', body: JSON.stringify({ action: 'incidents_delete', incident_id: incidentId }), }); }, onMutate: async (incidentId) => { const previous = queryClient.getQueryData(['incidents']); queryClient.setQueryData(['incidents'], (old) => (old ?? []).filter((i) => i.id !== incidentId) ); return { previous }; }, onSuccess: (_, incidentId) => { if (selectedIncidentId === incidentId) setSelectedIncidentId(null); queryClient.removeQueries({ queryKey: ['incident-detail', incidentId] }); toast({ message: 'Incident deleted.', type: 'success' }); }, onError: (err, _, ctx) => { if (ctx?.previous) { queryClient.setQueryData(['incidents'], ctx.previous); } setError(err.message || 'Failed to delete incident'); }, }); // ── Derived state ───────────────────────────────────────────────────────────── const incidents = incidentsQuery.data || []; const selectedIncident = detailQuery.data?.incident ?? null; const notifications = detailQuery.data?.notifications ?? []; const auditLog = detailQuery.data?.audit_log ?? []; const busy = startIncidentMutation.isPending || saveIncidentMutation.isPending || generateDraftMutation.isPending || markSubmittedMutation.isPending || exportEvidenceMutation.isPending || deleteIncidentMutation.isPending; // Which notification types have been submitted const submittedTypes = new Set( notifications.filter((n) => n.submitted_at).map((n) => n.notification_type) ); // Which types have drafts (generated but not submitted) const draftedTypes = new Set( notifications.filter((n) => !n.submitted_at).map((n) => n.notification_type) ); // Map notification type to its draft content (formatted for display) const draftTextByType: Partial> = {}; for (const n of notifications) { if (n.content) draftTextByType[n.notification_type] = formatNotificationDraft(n.notification_type, n.content); } const filtered = useMemo(() => { return incidents.filter((i) => { if (statusFilter !== 'all' && i.status !== statusFilter) return false; if (deadlineFilter !== 'all' && i.deadline_state !== deadlineFilter) return false; return true; }); }, [deadlineFilter, incidents, statusFilter]); const emailValidationError = useMemo(() => { const email = draft?.contact_email?.trim() || ''; if (!email) return null; return isValidEmail(email) ? null : INVALID_EMAIL_ERROR; }, [draft?.contact_email]); const handleSaveIncident = () => { if (emailValidationError) { setError(emailValidationError); return; } saveIncidentMutation.mutate(); }; // Auto-select first incident useEffect(() => { if (!selectedIncidentId && incidents.length > 0) setSelectedIncidentId(incidents[0].id); if (selectedIncidentId && incidents.length === 0) setSelectedIncidentId(null); }, [incidents, selectedIncidentId]); // Sync draft from server data useEffect(() => { if (selectedIncident) { setDraft(createDraftFromIncident(selectedIncident)); setDraftDirty(false); } }, [selectedIncident]); useEffect(() => { if (!emailValidationError && error === INVALID_EMAIL_ERROR) { setError(null); } }, [emailValidationError, error]); if (incidentsQuery.isLoading) { return ; } return (

Incident Center

Manage CRA reporting deadlines, notification drafts, and evidence.

{(error || incidentsQuery.error || detailQuery.error) && (
{error || (incidentsQuery.error instanceof Error ? incidentsQuery.error.message : '') || (detailQuery.error instanceof Error ? detailQuery.error.message : 'Failed to load data')}
)}
{/* ── Left: incident list ─────────────────────────────────────────── */} 0 ? ` (${incidents.length})` : ''}`} actions={ } >
{filtered.length === 0 ? (

{incidents.length === 0 ? 'No incidents yet. Create one manually or start from a vulnerability in the Scanner.' : 'No incidents match the current filter.'}

{incidents.length === 0 && ( )}
) : (
{filtered.map((incident) => ( ))}
)}
{/* ── Right: incident details ─────────────────────────────────────── */}
{detailQuery.isLoading ? (
) : !selectedIncident ? (

Select an incident to see details.

) : ( <> {/* Deadline banner */}
{deadlineLabel(selectedIncident.minutes_remaining)} {selectedIncident.report_deadline_at ? `${currentStageLabel(selectedIncident)}: ${formatDate(selectedIncident.report_deadline_at)}` : 'All notifications submitted'}
{selectedIncident.completeness_score}% complete
{/* Details form */} {config.plan === 'pro' ? ( ) : ( Export Evidence ↑ Pro )}
} >
setDraftField(setDraft, setDraftDirty, 'product_name', e.target.value)} />
setDraftField(setDraft, setDraftDirty, 'product_version', e.target.value)} />
setDraftField(setDraft, setDraftDirty, 'contact_name', e.target.value)} />
setDraftField(setDraft, setDraftDirty, 'contact_email', e.target.value)} aria-invalid={Boolean(emailValidationError)} /> {emailValidationError && {emailValidationError}}