import { useState } from 'react'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Upload, Download, X } from 'lucide-react'; import { useTranslation } from 'react-i18next'; interface ImportExportModalProps { isOpen: boolean; onClose: () => void; onExport: () => void; onImport: (file: File) => void; } export function ImportExportModal({ isOpen, onClose, onExport, onImport }: ImportExportModalProps) { const { t } = useTranslation(); const [selectedFile, setSelectedFile] = useState(null); const [dragActive, setDragActive] = useState(false); const handleFileChange = (e: React.ChangeEvent) => { if (e.target.files && e.target.files[0]) { setSelectedFile(e.target.files[0]); } }; const handleDrag = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); if (e.type === "dragenter" || e.type === "dragover") { setDragActive(true); } else if (e.type === "dragleave") { setDragActive(false); } }; const handleDrop = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); setDragActive(false); if (e.dataTransfer.files && e.dataTransfer.files[0]) { setSelectedFile(e.dataTransfer.files[0]); } }; const handleImportClick = () => { if (selectedFile) { onImport(selectedFile); setSelectedFile(null); } }; const handleClose = () => { setSelectedFile(null); onClose(); }; return ( {t('Import / Export Employees')}
{/* Export Section */}

{t('Export')}

{t('Download employee data as CSV file')}

{t('Or')}
{/* Import Section */}

{t('Import')}

{t('Upload CSV or Excel file to import employees')}

document.getElementById('file-upload')?.click()} >

{selectedFile ? selectedFile.name : t('Click to upload or drag and drop')}

{t('CSV or Excel files only')}

{selectedFile && (
{selectedFile.name}
)}
); }