import { parseExcelFile, validateImportData } from './server/importExcel';
import { readFileSync } from 'fs';

const buffer = readFileSync('/home/ubuntu/upload/template_import_formations_test.xlsx');
const { formations, sequences } = parseExcelFile(buffer);

console.log('=== FORMATIONS PARSÉES ===');
console.log(`Total: ${formations.length}`);
formations.forEach((f, i) => {
  console.log(`${i}: nom="${f.nom}", desc="${f.description}", public="${f.publicCible}"`);
});

console.log('\n=== SÉQUENCES PARSÉES ===');
console.log(`Total: ${sequences.length}`);
sequences.forEach((s, i) => {
  console.log(`${i}: formation="${s.formationNom}", nom="${s.nom}", lieu="${s.lieu}"`);
});

console.log('\n=== VALIDATION ===');
const validation = validateImportData(formations, sequences);
console.log(`Valid: ${validation.valid}`);
if (validation.errors.length > 0) {
  console.log('Erreurs:');
  validation.errors.forEach(e => console.log(`  - ${e}`));
}
if (validation.warnings.length > 0) {
  console.log('Avertissements:');
  validation.warnings.forEach(w => console.log(`  - ${w}`));
}
