refonte arborescence + correction des chemins

This commit is contained in:
ben
2025-12-09 17:14:35 +01:00
parent f0fbae505f
commit f79ee1e7b6
40 changed files with 185 additions and 144 deletions

View File

@@ -0,0 +1,47 @@
const form = document.getElementById("addCategoryForm");
const nameField = document.getElementById("categoryName");
const descField = document.getElementById("categoryDescription");
const errorEmpty = document.getElementById("errorEmpty");
const errorExists = document.getElementById("errorExists");
const successMessage = document.getElementById("successMessage");
// Catégories existantes ( à remplacer en BD si besoin)
const existingCategories = ["Actualités", "Chien", "Chat", "Boutique"];
form.addEventListener("submit", function (e) {
e.preventDefault();
const nom = nameField.value.trim();
//Remettre tout a zero
errorEmpty.classList.add("d-none");
errorExists.classList.add("d-none");
successMessage.classList.add("d-none");
//Erreur champs vide
if (nom === "") {
errorEmpty.classList.remove("d-none");
return;
}
//Erreur catégorie existante
if (existingCategories.includes(nom)) {
errorExists.classList.remove("d-none");
return;
}
// Succès
successMessage.classList.remove("d-none");
// Ajout d'une nouvelle catégorie
existingCategories.push(nom);
// Redirection après 1 seconde
setTimeout(() => {
window.location.href = "../html/liste_categorie.html";
}, 1000);
});