my-homelab-configs/apps/opsproof/overlay/resources/js/pages/Report.tsx

75 lines
3.3 KiB
TypeScript

interface Report {
id: number;
execution_id: number;
scope: string;
target: string;
outcome: string;
findings: string;
diagnostic: string;
five_whys_json: string;
mitigation: string;
validation: string;
recommendation: string;
before_evidence_json: string;
after_evidence_json: string;
execution_output: string;
approved_by: string;
created_at: string;
}
function list(value: string): string[] {
try {
const parsed = JSON.parse(value);
return Array.isArray(parsed) ? parsed.map(String) : [];
} catch {
return [];
}
}
export default function ReportPage({ report }: { report: Report }) {
return (
<main className="min-h-screen bg-[#071019] px-5 py-8 text-slate-100">
<div className="mx-auto max-w-5xl">
<p className="text-xs uppercase tracking-[0.2em] text-cyan-300">Evidence-backed incident report</p>
<div className="mt-3 flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
<h1 className="text-3xl font-semibold">{report.scope} / {report.target}</h1>
<span className="w-fit rounded-md border border-cyan-300/20 bg-cyan-300/10 px-3 py-1 text-xs uppercase text-cyan-200">
{report.outcome}
</span>
</div>
<div className="mt-8 grid gap-4">
{[
['Findings', report.findings],
['Diagnostic', report.diagnostic],
['Mitigation', report.mitigation],
['Validation', report.validation],
['Recommendation', report.recommendation],
].map(([heading, body]) => (
<section key={heading} className="rounded-2xl border border-white/10 bg-[#0a141e] p-6">
<h2 className="text-xs uppercase tracking-[0.18em] text-cyan-200">{heading}</h2>
<p className="mt-3 text-sm leading-6 text-slate-400">{body}</p>
</section>
))}
<section className="rounded-2xl border border-white/10 bg-[#0a141e] p-6">
<h2 className="text-xs uppercase tracking-[0.18em] text-cyan-200">Five Whys</h2>
<ol className="mt-3 space-y-3 text-sm leading-6 text-slate-400">
{list(report.five_whys_json).map((item, index) => <li key={item}>{index + 1}. {item}</li>)}
</ol>
</section>
<section className="rounded-2xl border border-white/10 bg-[#0a141e] p-6">
<h2 className="text-xs uppercase tracking-[0.18em] text-cyan-200">Bounded execution output</h2>
<pre className="mt-3 max-h-80 overflow-auto whitespace-pre-wrap rounded-xl bg-black/20 p-4 text-xs leading-5 text-slate-400">
{report.execution_output || 'No execution output was returned.'}
</pre>
</section>
</div>
<p className="mt-6 text-xs text-slate-600">Approved by {report.approved_by} · report {report.id} · execution {report.execution_id}</p>
</div>
</main>
);
}