/** * @ai-summary Import button component * @ai-context Opens file selector and triggers import dialog */ import React, { useRef } from 'react'; import toast from 'react-hot-toast'; interface ImportButtonProps { onFileSelected: (file: File) => void; disabled?: boolean; } export const ImportButton: React.FC = ({ onFileSelected, disabled = false, }) => { const fileInputRef = useRef(null); const handleButtonClick = () => { fileInputRef.current?.click(); }; const handleFileChange = (event: React.ChangeEvent) => { const file = event.target.files?.[0]; if (!file) return; // Validate file extension if (!file.name.endsWith('.tar.gz')) { toast.error('Please select a .tar.gz file'); return; } // Validate file size (max 500MB) const maxSize = 500 * 1024 * 1024; if (file.size > maxSize) { toast.error('File size exceeds 500MB limit'); return; } onFileSelected(file); // Reset input so same file can be selected again event.target.value = ''; }; return ( <> ); };