"use client"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { AlertCircle, CheckCircle2, ChevronDown, ChevronRight, History, RefreshCw, Trash2, Upload, Wand2, } from "lucide-react"; import type { HistoryEntry } from "@/hooks/useKnowledgeHistory"; interface KbUpdateHistoryProps { entries: HistoryEntry[]; onClear: () => void; } export default function KbUpdateHistory({ entries, onClear, }: KbUpdateHistoryProps) { const { t } = useTranslation(); const [expandedId, setExpandedId] = useState(null); if (entries.length === 0) return null; return (
{t("Update history")} {entries.length}
); } function iconForKind(kind: HistoryEntry["kind"]) { switch (kind) { case "upload": return Upload; case "reindex": return RefreshCw; case "create": default: return Wand2; } } function formatDuration(ms: number): string { if (ms < 1000) return `${ms}ms`; if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`; const minutes = Math.floor(ms / 60_000); const seconds = Math.round((ms % 60_000) / 1000); return `${minutes}m ${seconds}s`; }