import React, { useEffect, useState } from "react"; import { useParams, Link } from "react-router-dom"; import { ChevronRight } from "lucide-react"; import { DocEditor } from "@/components/DocEditor"; import { useSettingsStore } from "@/stores/settingsStore"; import { generatePostmortemCmd, updateDocumentCmd, exportDocumentCmd, type Document_, } from "@/lib/tauriCommands"; export default function Postmortem() { const { id } = useParams<{ id: string }>(); const getActiveProvider = useSettingsStore((s) => s.getActiveProvider); const [doc, setDoc] = useState(null); const [content, setContent] = useState(""); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); useEffect(() => { if (!id) return; const load = async () => { setIsLoading(true); try { const generated = await generatePostmortemCmd(id); setDoc(generated); setContent(generated.content_md); } catch (err) { setError(String(err)); } finally { setIsLoading(false); } }; load(); }, [id]); const handleContentChange = async (newContent: string) => { setContent(newContent); if (doc) { try { const updated = await updateDocumentCmd(doc.id, newContent); setDoc(updated); } catch (err) { setError(String(err)); } } }; const handleExport = async (format: "md" | "pdf" | "docx") => { if (!doc) return; try { const path = await exportDocumentCmd(doc.id, doc.title, content, format, ""); setError(`Document exported to: ${path}`); setTimeout(() => setError(null), 5000); } catch (err) { setError(`Export failed: ${String(err)}`); } }; return (
{/* Breadcrumb */}

Post-Mortem Report

Document the incident timeline, impact, and lessons learned.

{error && (
{error}
)} {isLoading ? (

Generating post-mortem document...

) : (
)}
); }