diff --git a/src/app/mail/[id]/page.tsx b/src/app/mail/[id]/page.tsx index 98a631d..09e980a 100644 --- a/src/app/mail/[id]/page.tsx +++ b/src/app/mail/[id]/page.tsx @@ -7,6 +7,7 @@ import { getThread, downloadMailAttachment, downloadMailRaw, + downloadMailOCRText, exportMailPDF, type MailDetail, type MailAttachment, @@ -20,6 +21,8 @@ import { Card, CardContent, CardHeader } from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; import { Skeleton } from "@/components/ui/skeleton"; import { Alert, AlertDescription } from "@/components/ui/alert"; +import { OcrBadge } from "@/components/ocr-badge"; +import { FileText } from "lucide-react"; // ── Helpers ──────────────────────────────────────────────────────────────── @@ -87,7 +90,7 @@ function MailHeaderGrid({ mail }: { mail: MailDetail }) { {formatBytes(mail.size)} {/* Verification status */} Integrität: - + {mail.verify_ok === true ? ( @@ -110,6 +113,7 @@ function MailHeaderGrid({ mail }: { mail: MailDetail }) { Noch nicht geprüft )} + @@ -257,6 +261,8 @@ export default function MailViewPage({ const [loading, setLoading] = useState(true); const [downloading, setDownloading] = useState(false); const [pdfLoading, setPdfLoading] = useState(false); + const [ocrLoading, setOcrLoading] = useState(false); + const [ocrInfo, setOcrInfo] = useState(null); const [thread, setThread] = useState(null); const [threadOpen, setThreadOpen] = useState(false); @@ -302,6 +308,25 @@ export default function MailViewPage({ } } + async function handleOCRDownload() { + setOcrLoading(true); + setOcrInfo(null); + try { + const result = await downloadMailOCRText(id); + if (result.kind === "ok") { + triggerDownload(result.blob, result.filename); + } else if (result.kind === "pending") { + setOcrInfo("OCR läuft noch, bitte gleich nochmal versuchen."); + } else { + setOcrInfo("Kein OCR-Text verfügbar."); + } + } catch (e) { + alert(`OCR-Download fehlgeschlagen: ${e instanceof Error ? e.message : e}`); + } finally { + setOcrLoading(false); + } + } + return (
@@ -341,9 +366,26 @@ export default function MailViewPage({ > {pdfLoading ? "..." : "Als PDF exportieren"} + {mail.ocr_status === "done" && (mail.ocr_chars ?? 0) > 0 && ( + + )}
)} + {ocrInfo && ( + + {ocrInfo} + + )} {/* Loading */} {loading && (