From 7f580261e0fca116f9075a6300db82eea9a55d7f Mon Sep 17 00:00:00 2001 From: RoxanaElena09 Date: Mon, 8 Dec 2025 15:59:58 +0100 Subject: [PATCH] feat:ajouter_prestation --- .../ajouter_prestation.html | 88 +++++++++++++++++++ .../ajouter_prestation/ajouter_prestation.js | 52 +++++++++++ 2 files changed, 140 insertions(+) create mode 100644 prestations/ajouter_prestation/ajouter_prestation.js diff --git a/prestations/ajouter_prestation/ajouter_prestation.html b/prestations/ajouter_prestation/ajouter_prestation.html index e69de29..1370f9f 100644 --- a/prestations/ajouter_prestation/ajouter_prestation.html +++ b/prestations/ajouter_prestation/ajouter_prestation.html @@ -0,0 +1,88 @@ + + + + + + + Ajouter une catégorie + + + + + + + +
+

Ajouter une prestation

+ + +
Le titre est obligatoire.
+ + +
Cette prestation existe déjà. Veuillez en choisir + une autre.
+ + +
Prestation ajoutée avec succès !
+ +
+ + +
+ + +
+ +
+ + +
+ + +
+ + +
+ + + +
+ +
+ + +
+
+ +
+ Annuler + +
+
+
+ + + + + + + \ No newline at end of file diff --git a/prestations/ajouter_prestation/ajouter_prestation.js b/prestations/ajouter_prestation/ajouter_prestation.js new file mode 100644 index 0000000..8fc3aaf --- /dev/null +++ b/prestations/ajouter_prestation/ajouter_prestation.js @@ -0,0 +1,52 @@ +// Récupération des éléments +const form = document.getElementById("addCategoryForm"); +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) +const existingPrestations = [ + "Toilettage complet", + "Coupe ciseaux", + "Toilettage chiot", + "Démêlage poil long" +]; + +form.addEventListener("submit", function (e) { + e.preventDefault(); + + // 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"); + return; + } + + // 2. Vérif : prestation déjà existante (exemple simple) + if (existingPrestations.includes(titre)) { + errorExists.classList.remove("d-none"); + return; + } + + // 3. Tout est ok → succès + successMessage.classList.remove("d-none"); + + // Simuler ajout en base + existingPrestations.push(titre); + + +}); +