diff --git a/blog/html/ajouter_categorie.html b/blog/html/ajouter_categorie.html index 4e6e0c9..6e0a7a1 100644 --- a/blog/html/ajouter_categorie.html +++ b/blog/html/ajouter_categorie.html @@ -4,11 +4,7 @@ Ajouter une catégorie - - - - @@ -17,6 +13,50 @@ @@ -24,7 +64,7 @@

Ajouter une catégorie

- +
diff --git a/blog/html/modifier_article.html b/blog/html/modifier_article.html index d15f6ad..23a8b96 100644 --- a/blog/html/modifier_article.html +++ b/blog/html/modifier_article.html @@ -69,7 +69,7 @@

Modifier un article

- +
diff --git a/css/prestation.css b/css/prestation.css new file mode 100644 index 0000000..eba3746 --- /dev/null +++ b/css/prestation.css @@ -0,0 +1,2 @@ +body { background: #f4f6f981; } + .container { margin-top: 50px; } \ No newline at end of file diff --git a/prestations/html/ajouter_prestation.html b/prestations/html/ajouter_prestation.html index e1dbf2a..9dde8b7 100644 --- a/prestations/html/ajouter_prestation.html +++ b/prestations/html/ajouter_prestation.html @@ -1,88 +1,117 @@ - - Ajouter une catégorie - + Ajouter une prestation + + - + -
-

Ajouter une prestation

+
+ +
+
+

Ajouter une prestation

- -
+ +
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
-
+
-
- Annuler - -
- -
+
+ Annuler + +
+ +
- - + + - - \ No newline at end of file + diff --git a/prestations/js/ajouter_prestation.js b/prestations/js/ajouter_prestation.js index 70e021e..b3aec96 100644 --- a/prestations/js/ajouter_prestation.js +++ b/prestations/js/ajouter_prestation.js @@ -1,16 +1,14 @@ -// Récupération des éléments +// Éléments const form = document.getElementById("addCategoryForm"); +const messages = document.getElementById("messages"); + const titleField = document.getElementById("categoryName"); const typeField = document.getElementById("prestationType"); const descField = document.getElementById("prestationDescription"); const priceMinField = document.getElementById("priceMin"); const priceMaxField = document.getElementById("priceMax"); -const errorEmpty = document.getElementById("errorEmpty"); -const errorExists = document.getElementById("errorExists"); -const successMessage = document.getElementById("successMessage"); - -// Prestations existantes (simulation) +// Prestations existantes (simulation BDD) const existingPrestations = [ "Toilettage complet", "Coupe ciseaux", @@ -18,38 +16,42 @@ const existingPrestations = [ "Démêlage poil long" ]; + +function showMessage(type, text) { + messages.innerHTML = ""; + + const div = document.createElement("div"); + div.className = `alert alert-${type}`; + div.textContent = text; + + messages.appendChild(div); +} + + form.addEventListener("submit", function (e) { e.preventDefault(); + messages.innerHTML = ""; - // Récupérer le titre const titre = titleField.value.trim(); - // Réinitialiser les alertes - errorEmpty.classList.add("d-none"); - errorExists.classList.add("d-none"); - successMessage.classList.add("d-none"); - - // 1. Vérif : titre obligatoire - if (titre === "") { - errorEmpty.classList.remove("d-none"); + // Titre obligatoire + if (!titre) { + showMessage("danger", "Le titre de la prestation est obligatoire."); return; } - // 2. Vérif : prestation déjà existante (exemple simple) + // Doublon if (existingPrestations.includes(titre)) { - errorExists.classList.remove("d-none"); + showMessage("danger", "Cette prestation existe déjà. Veuillez en choisir une autre."); return; } - // 3. Tout est ok → succès - successMessage.classList.remove("d-none"); - - // Simuler ajout en base + // Succès existingPrestations.push(titre); + showMessage("success", "Prestation ajoutée avec succès !"); - + // Redirection setTimeout(() => { - window.location.href = "../liste_prestation/liste_prestation.html"; -}, 1500); + window.location.href = "../liste_prestation/liste_prestation.html"; + }, 1500); }); -