"use client"; import { Lock, Calendar, User, Link2, FileText, AlertTriangle, Download, } from "lucide-react"; import { Badge } from "@/shared/components/ui/badge"; import { Button } from "@/shared/components/ui/button"; import type { ClosureInfo, RegistryEntry } from "../types"; interface ClosureBannerProps { closureInfo: ClosureInfo; /** Navigate to the linked continuation entry */ onNavigateLinked?: (entry: RegistryEntry) => void; /** All entries — to find the linked entry for navigation */ allEntries?: RegistryEntry[]; } const RESOLUTION_LABELS: Record = { finalizat: "Finalizat", "aprobat-tacit": "Aprobat tacit", respins: "Respins / Negativ", retras: "Retras", altele: "Altele", }; /** * Read-only banner displayed at the top of a closed entry, * showing who closed it, when, why, linked entry, and attachment. */ export function ClosureBanner({ closureInfo, onNavigateLinked, allEntries, }: ClosureBannerProps) { const linkedEntry = closureInfo.linkedEntryId && allEntries ? allEntries.find((e) => e.id === closureInfo.linkedEntryId) : null; const closedDate = new Date(closureInfo.closedAt).toLocaleDateString( "ro-RO", { day: "2-digit", month: "long", year: "numeric" }, ); const handleDownload = () => { if (!closureInfo.attachment) return; const a = document.createElement("a"); a.href = closureInfo.attachment.data; a.download = closureInfo.attachment.name; a.click(); }; return (
Înregistrare închisă {closureInfo.resolution && ( {RESOLUTION_LABELS[closureInfo.resolution] ?? closureInfo.resolution} )} {closureInfo.hadActiveDeadlines && ( Avea termene active )}
{/* Who + When */}
{closureInfo.closedBy} {closedDate}
{/* Reason */}
Motiv: {closureInfo.reason}
{/* Linked entry */} {(linkedEntry || closureInfo.linkedEntryNumber) && (
Continuat în: {linkedEntry && onNavigateLinked ? ( ) : ( {closureInfo.linkedEntryNumber ?? closureInfo.linkedEntryId} )}
)} {/* Attached document */} {closureInfo.attachment && (
{closureInfo.attachment.name} {(closureInfo.attachment.size / 1024).toFixed(0)} KB
)}
); }