import { Download, FileText, LoaderCircle } from "lucide-react"; import { VersionRecord } from "@/wordaddin/models/versionRecord"; import { MessageBar } from "./MessageBar"; import { Spinner } from "./Spinner"; /** * FR-4 — แสดง version history (เลข version / เวลา / ผู้สร้าง) + ปุ่มดาวน์โหลด version นั้น * ชั้นภาพ: timeline แนวตั้ง — จุดโหนดเท่าทึบคือเวอร์ชันล่าสุด จุดกลวงคือเก่ากว่า * (เลข version เป็น static → ใช้ ink ตามกฎ "blue เฉพาะ interactive" ของ DESIGN.md) */ function formatTimestamp(iso: string): string { const date = new Date(iso); return Number.isNaN(date.getTime()) ? iso : date.toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" }); } /** px-2 py-1.5 + text-xs ≈ สูง 30px — พ้นเกณฑ์ touch target 24px ของ WCAG 2.5.8 โดยยัง dense พอสำหรับ list */ const BTN_ACTION = "focus-ring inline-flex items-center gap-1 rounded-md px-2 py-1.5 text-xs text-ink-soft transition hover:bg-primary/[0.06] hover:text-primary disabled:pointer-events-none disabled:opacity-50"; export function VersionHistoryPanel({ versions, loading, error, downloadingVersionId, downloadingPdfVersionId, onDownloadPdf, onDownload, onRetry, }: { versions: VersionRecord[]; loading: boolean; error: string | null; /** versionId ของ version ที่กำลังดาวน์โหลดอยู่ (แสดง spinner ที่ปุ่ม) */ downloadingVersionId: string | null; downloadingPdfVersionId: string | null; onDownloadPdf: (version: VersionRecord) => void; onDownload: (version: VersionRecord) => void; onRetry: () => void; }) { const anyDownloading = downloadingVersionId !== null || downloadingPdfVersionId !== null; return (
ยังไม่มี version ในระบบ
) : null} {versions.length > 0 ? ({version.message}
) : null}{formatTimestamp(version.createdAt)} · โดย {version.createdByUserId}