import * as React from "react"; import { FileTextIcon, XIcon } from "lucide-react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { UploadCard } from "@/components/ui/upload-card"; // --------------------------------------------------------------------------- // Types // --------------------------------------------------------------------------- export interface CsvImportModalProps { open: boolean; onOpenChange: (open: boolean) => void; /** Controlled: display name of the currently selected file. */ fileName?: string; /** Controlled: size of the currently selected file in bytes. */ fileSize?: number; /** Called when the user picks a file via the upload zone. */ onFileSelect?: (file: File) => void; /** Called when the user removes the currently selected file. */ onFileClear?: () => void; /** Called when the user clicks Next (a file must already be selected). */ onNext: () => void; /** Called when the user clicks the CSV template download link. */ onDownloadTemplate?: () => void; /** Override the upload zone description (e.g. for a stricter file-size cap). */ uploadDescription?: string; isLoading?: boolean; className?: string; } // --------------------------------------------------------------------------- // Helpers // --------------------------------------------------------------------------- function formatBytes(bytes: number): string { if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; } // --------------------------------------------------------------------------- // Component // --------------------------------------------------------------------------- export function CsvImportModal({ open, onOpenChange, fileName, fileSize, onFileSelect, onFileClear, onNext, onDownloadTemplate, uploadDescription, isLoading = false, className, }: CsvImportModalProps) { const hasFile = !!fileName; return ( ); } // --------------------------------------------------------------------------- // Sub-component // --------------------------------------------------------------------------- function SelectedFile({ name, size, onClear, }: { name: string; size?: number; onClear?: () => void; }) { return (
{name}
{size !== undefined && ({formatBytes(size)}
)}