From 56bc6a709f35f1e742bd60a54ea24e2014c7566d Mon Sep 17 00:00:00 2001 From: morgane Date: Wed, 17 Jun 2026 17:48:35 +0000 Subject: [PATCH] Actualiser test.html --- test.html | 62 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/test.html b/test.html index 8c39989..199e6ff 100644 --- a/test.html +++ b/test.html @@ -2,36 +2,35 @@ - ⚡ Debug Catégories - Dashboard + ⚡ Debug & Modification
- État : Tentative de récupération... + État : Chargement...
-
-

Choisir une catégorie :

+
+

Modifier le produit

+ +
-

Table des Catégories (Source: translations/fr.json)

- - +

Table des Catégories

+
CléLibellé (Français)
+
CléLibellé
@@ -40,38 +39,49 @@ const debugPanel = document.getElementById('debug-panel'); fetch('translations/fr.json') - .then(res => { - if (!res.ok) throw new Error("Fichier introuvable (" + res.status + ")"); - return res.json(); - }) + .then(res => res.json()) .then(data => { const tbody = document.querySelector('#cat-table tbody'); - const selector = document.querySelector('#category-selector'); + const selector = document.getElementById('category-selector'); const catData = data.categories; if (catData) { - statusText.innerText = "OK - Données chargées avec succès."; + statusText.innerText = "OK - Données chargées."; debugPanel.style.borderLeftColor = "#4ade80"; statusText.className = "status-ok"; Object.entries(catData).forEach(([key, val]) => { - const row = `${key}${val}`; - tbody.innerHTML += row; - + // Remplir tableau + tbody.innerHTML += `${key}${val}`; + // Remplir select const opt = document.createElement('option'); opt.value = key; opt.textContent = val; selector.appendChild(opt); }); - } else { - throw new Error("Structure JSON invalide (section 'categories' manquante)"); } }) .catch(err => { statusText.innerText = "ERREUR : " + err.message; debugPanel.style.borderLeftColor = "#f87171"; - statusText.className = "status-err"; }); + + function saveProduct() { + const data = { + name: document.getElementById('prod-name').value, + category: document.getElementById('category-selector').value + }; + + // Appel API pour la réconciliation + fetch('api/index.php?action=update_product', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(data) + }) + .then(r => r.json()) + .then(res => alert("Réponse API : " + JSON.stringify(res))) + .catch(e => alert("Erreur d'envoi : " + e)); + } \ No newline at end of file