Actualiser js/admin.js

This commit is contained in:
2026-07-01 10:11:42 +02:00
parent fbbdd8e770
commit 097ec7ff4e
+9 -9
View File
@@ -411,21 +411,19 @@ async function handleCritiqueUpload(input) {
loadDashboardData();
}
// ✅ CORRECTION : Retourne l'EAN ET le titre du CSV
function normalizeVideothequeRow(row) {
let ean = row['ean_isbn13'] || row['EAN'] || row['ean'] || row['Barcode'] || row['UPC'] || row['upc_isbn10'] || '';
if (ean) ean = String(ean).replace(/[^0-9]/g, '');
ean = String(ean).replace(/[^0-9]/g, '');
// ✅ Récupérer le titre du CSV
let title = row['title'] || row['Title'] || row['Titre'] || '';
// Recherche du titre : essayer plusieurs noms de colonne
let title = row['title'] || row['Title'] || row['Titre'] || row['titre'] || '';
title = String(title).trim();
// Si le titre est vide mais qu'il y a un EAN, on peut tenter d'utiliser le nom du fichier ?
// Mais au moins on ne filtre pas les lignes avec titre vide tant qu'il y a un EAN
if (!ean && !title) return null;
return {
ean: ean,
title: title // ✅ Titre envoyé au backend
};
return { ean, title };
}
function handleVideothequeUpload(input) {
@@ -439,7 +437,9 @@ function handleVideothequeUpload(input) {
// ✅ CORRECTION : Utiliser normalizeVideothequeRow qui retourne EAN + titre
const items = parsed.map(row => normalizeVideothequeRow(row)).filter(Boolean);
console.log('Lignes parsées :', parsed.length);
console.log('Items valides :', items.length);
console.log('Premier item :', items[0]);
if (!items.length) { alert("❌ Aucun titre ou EAN valide trouvé."); return; }
showImportModal(items.length, 'videotheque');