Fix new Frontend 8
This commit is contained in:
@@ -125,15 +125,14 @@ const OnboardingPage: React.FC<OnboardingPageProps> = ({ user, onComplete }) =>
|
||||
try {
|
||||
// Step 2.1: First validate the CSV data
|
||||
toast.loading('Validando datos del archivo CSV...', { id: 'csv-validation' });
|
||||
|
||||
const validationResult = await validateSalesData(tenantId, bakeryData.csvFile);
|
||||
|
||||
toast.dismiss('csv-validation');
|
||||
|
||||
|
||||
// Check validation result
|
||||
if (!validationResult.success) {
|
||||
const validationResult = await validateSalesData(tenantId, bakeryData.csvFile);
|
||||
|
||||
// Check validation result using the correct field names
|
||||
if (!validationResult.is_valid) { // ← Changed from .success to .is_valid
|
||||
// Validation failed - show errors but let user decide
|
||||
const errorMessages = validationResult.errors?.slice(0, 3).join(', ') || 'Errores de validación';
|
||||
const errorMessages = validationResult.errors?.slice(0, 3).map(e => e.message || 'Unknown error').join(', ') || 'Errores de validación';
|
||||
const hasMoreErrors = validationResult.errors && validationResult.errors.length > 3;
|
||||
|
||||
toast.error(
|
||||
@@ -145,13 +144,13 @@ const OnboardingPage: React.FC<OnboardingPageProps> = ({ user, onComplete }) =>
|
||||
// Don't proceed with upload if validation fails
|
||||
throw new Error('Validación del CSV falló');
|
||||
}
|
||||
|
||||
|
||||
// Validation passed - show summary and proceed
|
||||
if (validationResult.warnings && validationResult.warnings.length > 0) {
|
||||
toast.warn(`CSV validado con ${validationResult.warnings.length} advertencias. Continuando con la subida...`);
|
||||
console.warn('CSV validation warnings:', validationResult.warnings);
|
||||
} else {
|
||||
toast.success('CSV validado correctamente. Procediendo con la subida...');
|
||||
toast.success(`CSV validado correctamente. ${validationResult.valid_records} de ${validationResult.total_records} registros válidos.`);
|
||||
}
|
||||
|
||||
// Step 2.2: Now upload the validated CSV
|
||||
|
||||
Reference in New Issue
Block a user