"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { useParams } from "next/navigation"; import { Download, ExternalLink } from "lucide-react"; import DetailSection from "@/components/common/DetailSection"; import DocumentTypeBadge from "@/components/knowledge/DocumentTypeBadge"; import TagList from "@/components/knowledge/TagList"; import { buttonVariants } from "@/components/ui/button"; import { api } from "@/lib/api"; import type { KnowledgeDocument } from "@/types/knowledge"; function fileSize(value: number) { if (!value) return "-"; if (value < 1024 * 1024) return `${Math.round(value / 1024)} KB`; return `${(value / 1024 / 1024).toFixed(1)} MB`; } export default function KnowledgeDocumentDetailPage() { const params = useParams<{ id: string }>(); const [document, setDocument] = useState(null); const [error, setError] = useState(""); useEffect(() => { api.get(`/knowledge/documents/${params.id}`) .then((response) => setDocument(response.data)) .catch(() => setError("Dokument konnte nicht geladen werden")); }, [params.id]); if (error) return

{error}

; if (!document) return

Dokument wird geladen...

; return (

{document.title}

{document.manufacturer.name}{document.device ? ` · ${document.device.name}` : ""}

{document.external_url && Extern} {document.file_name && Download}
Typ
Sprache
{document.language}
Dateiname
{document.file_name || "-"}
Dateigröße
{fileSize(document.file_size)}
SHA-256
{document.checksum_sha256 || "-"}
Paperless-ID
{document.paperless_document_id || "-"}
{document.description &&

{document.description}

}
); }