améliore l'import (normalisation colonnes)
This commit is contained in:
@@ -8,7 +8,7 @@ import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||
import { Upload, FileText, Download, AlertCircle } from 'lucide-react';
|
||||
import { BaseModal } from './base/BaseModal';
|
||||
import { ErrorDisplay } from './base/ErrorDisplay';
|
||||
import { parseCSV, parseExcel, getExpectedColumns, downloadTemplate, validateFileType } from '@/lib/file-utils';
|
||||
import { parseCSV, parseExcel, getExpectedColumns, downloadTemplate, validateFileType, normalizeParsedData } from '@/lib/file-utils';
|
||||
|
||||
interface ImportFileModalProps {
|
||||
isOpen: boolean;
|
||||
@@ -52,7 +52,9 @@ export default function ImportFileModal({
|
||||
return;
|
||||
}
|
||||
|
||||
setPreview(result.data.slice(0, 5)); // Afficher les 5 premières lignes
|
||||
// Normaliser les données pour correspondre aux colonnes attendues
|
||||
const normalizedData = normalizeParsedData(result.data, type);
|
||||
setPreview(normalizedData.slice(0, 5)); // Afficher les 5 premières lignes
|
||||
}
|
||||
};
|
||||
|
||||
@@ -69,7 +71,9 @@ export default function ImportFileModal({
|
||||
return;
|
||||
}
|
||||
|
||||
onImport(result.data);
|
||||
// Normaliser les données pour correspondre aux colonnes attendues
|
||||
const normalizedData = normalizeParsedData(result.data, type);
|
||||
onImport(normalizedData);
|
||||
onClose();
|
||||
setFile(null);
|
||||
setPreview([]);
|
||||
|
||||
Reference in New Issue
Block a user