import React, { useRef } from 'react'; import { parseAndImportCsv } from '../api'; export default function CsvImporter({ onImported }) { const fileInputRef = useRef(null); const handleUpload = async (e) => { const file = e.target.files[0]; if (!file) return; try { const result = await parseAndImportCsv(file); alert(`Успешно! Загружено деталей: ${result.count}`); if (onImported) onImported(); // Обновляем список деталей на странице } catch (err) { alert("Ошибка импорта: " + err); } finally { // Очищаем инпут, чтобы можно было загрузить тот же файл повторно if (fileInputRef.current) fileInputRef.current.value = ''; } }; return (
Выберите .csv файл для массовой загрузки