Actualiser test.html
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
.status-ok { color: #4ade80; font-weight: bold; }
|
.status-ok { color: #4ade80; font-weight: bold; }
|
||||||
.status-err { color: #f87171; font-weight: bold; }
|
.status-err { color: #f87171; font-weight: bold; }
|
||||||
.card { background: #444; padding: 20px; margin-bottom: 20px; border-radius: 8px; }
|
.card { background: #444; padding: 20px; margin-bottom: 20px; border-radius: 8px; }
|
||||||
input, select { padding: 10px; border-radius: 5px; border: none; margin: 5px 0; width: 100%; }
|
input, select { padding: 10px; border-radius: 5px; border: none; margin: 5px 0; width: 100%; box-sizing: border-box; }
|
||||||
button { padding: 10px 20px; background: #1976d2; color: white; border: none; border-radius: 5px; cursor: pointer; }
|
button { padding: 10px 20px; background: #1976d2; color: white; border: none; border-radius: 5px; cursor: pointer; margin-top: 10px; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h3>Modifier le produit</h3>
|
<h3>Modifier le produit</h3>
|
||||||
<input type="text" id="prod-name" placeholder="Nom du produit" value="Jus Ananas">
|
<input type="text" id="prod-id" placeholder="ID du produit (ex: 123)">
|
||||||
|
<input type="text" id="prod-name" placeholder="Nom du produit">
|
||||||
<select id="category-selector">
|
<select id="category-selector">
|
||||||
<option value="">-- Choisir une catégorie --</option>
|
<option value="">-- Choisir une catégorie --</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -30,7 +31,7 @@
|
|||||||
|
|
||||||
<h1>Table des Catégories</h1>
|
<h1>Table des Catégories</h1>
|
||||||
<table id="cat-table" style="width:100%; border-collapse: collapse;">
|
<table id="cat-table" style="width:100%; border-collapse: collapse;">
|
||||||
<thead><tr style="background:#444;"><th>Clé</th><th>Libellé</th></tr></thead>
|
<thead><tr style="background:#444;"><th style="padding:10px;">Clé</th><th style="padding:10px;">Libellé</th></tr></thead>
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@
|
|||||||
const statusText = document.getElementById('status-text');
|
const statusText = document.getElementById('status-text');
|
||||||
const debugPanel = document.getElementById('debug-panel');
|
const debugPanel = document.getElementById('debug-panel');
|
||||||
|
|
||||||
|
// Chargement des catégories
|
||||||
fetch('translations/fr.json')
|
fetch('translations/fr.json')
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
@@ -51,9 +53,7 @@
|
|||||||
statusText.className = "status-ok";
|
statusText.className = "status-ok";
|
||||||
|
|
||||||
Object.entries(catData).forEach(([key, val]) => {
|
Object.entries(catData).forEach(([key, val]) => {
|
||||||
// Remplir tableau
|
|
||||||
tbody.innerHTML += `<tr><td style="border:1px solid #555; padding:8px;">${key}</td><td style="border:1px solid #555; padding:8px;">${val}</td></tr>`;
|
tbody.innerHTML += `<tr><td style="border:1px solid #555; padding:8px;">${key}</td><td style="border:1px solid #555; padding:8px;">${val}</td></tr>`;
|
||||||
// Remplir select
|
|
||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
opt.value = key;
|
opt.value = key;
|
||||||
opt.textContent = val;
|
opt.textContent = val;
|
||||||
@@ -66,14 +66,21 @@
|
|||||||
debugPanel.style.borderLeftColor = "#f87171";
|
debugPanel.style.borderLeftColor = "#f87171";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fonction d'enregistrement
|
||||||
function saveProduct() {
|
function saveProduct() {
|
||||||
|
const idEl = document.getElementById('prod-id');
|
||||||
|
const nameEl = document.getElementById('prod-name');
|
||||||
|
const catEl = document.getElementById('category-selector');
|
||||||
|
|
||||||
|
if (!idEl.value) return alert("Veuillez entrer un ID de produit.");
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
id: document.getElementById('prod-id').value, // Ajoute un champ pour l'ID
|
id: idEl.value,
|
||||||
name: document.getElementById('prod-name').value,
|
name: nameEl.value,
|
||||||
category: document.getElementById('category-selector').value
|
category: catEl.value
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remplace 'update_product' par l'action trouvée dans ton onglet Réseau
|
// Remplace 'product_edit' par l'action confirmée dans ton onglet Réseau
|
||||||
fetch('api/index.php?action=product_edit', {
|
fetch('api/index.php?action=product_edit', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
@@ -81,8 +88,8 @@
|
|||||||
})
|
})
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(res => {
|
.then(res => {
|
||||||
console.log("Réponse :", res);
|
console.log("Réponse API :", res);
|
||||||
alert("Action effectuée avec succès !");
|
alert("Action effectuée. Voir la console pour les détails.");
|
||||||
})
|
})
|
||||||
.catch(e => alert("Erreur : " + e));
|
.catch(e => alert("Erreur : " + e));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user