import { Folder, File, ChevronRight, Loader2 } from "lucide-react"; import type { FileNode } from "../api"; interface FileBrowserProps { entries: FileNode[]; currentPath: string; onSelectFile: (path: string) => void; onNavigate: (path: string) => void; loading?: boolean; error?: string | null; onRetry?: () => void; } function formatBytes(bytes?: number): string { if (bytes === undefined) return ""; if (bytes < 1024) return `${bytes} B`; if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; } function formatTime(mtime?: string): string { if (!mtime) return ""; const date = new Date(mtime); return date.toLocaleDateString(); } export function FileBrowser({ entries, currentPath, onSelectFile, onNavigate, loading, error, onRetry, }: FileBrowserProps) { if (loading) { return (
Error: {error}
{onRetry && ( )}