diff --git a/prestations/html/ajouter_slider.html b/prestations/html/ajouter_slider.html index c11afc3..1d60d9a 100644 --- a/prestations/html/ajouter_slider.html +++ b/prestations/html/ajouter_slider.html @@ -1,119 +1,147 @@ - - - + + + Ajouter un slide + + + - - - - - - - - +
-
+ + -
+
-
-

Ajouter une image au slider

+
+

Ajouter une image au slider

- -
- -
+ +
+
- - + +
- - + +
- - + +
- Annuler - + Annuler +
+
+
- -
- - - - - + + + - - - diff --git a/prestations/html/modifier_prestation.html b/prestations/html/modifier_prestation.html index 19dc713..e825623 100644 --- a/prestations/html/modifier_prestation.html +++ b/prestations/html/modifier_prestation.html @@ -1,84 +1,98 @@ - - - + + + Modifier une prestation - + - - - + + + +
+ +
-

Modifier une prestation

+

Modifier une prestation

+ +
- -
Le titre est obligatoire.
-
Une erreur est survenue. Veuillez réessayer plus tard.
- - -
Prestation modifiée avec succès !
- -
- - -
- - -
- - -
- - -
- - - -
- - -
- - -
- -
- - -
-
- - -
- Annuler - + + +
+ +
- + +
+ + +
+ +
+ + +
+ + +
+ +
+ + +
+
+ + +
+ Annuler + +
+
- - - - - \ No newline at end of file + + + + diff --git a/prestations/js/modifier_prestation.js b/prestations/js/modifier_prestation.js index 8ae8b65..2876545 100644 --- a/prestations/js/modifier_prestation.js +++ b/prestations/js/modifier_prestation.js @@ -1,41 +1,45 @@ +const form = document.getElementById("editPrestationForm"); +const messages = document.getElementById("messages"); -const form = document.getElementById('editPrestationForm'); -const titleField = document.getElementById('prestationTitle'); -const descriptionField = document.getElementById('prestationDescription'); -const typeField = document.getElementById('prestationType'); -const priceMinField = document.getElementById('priceMin'); -const priceMaxField = document.getElementById('priceMax'); - -const errorEmpty = document.getElementById('errorEmpty'); -const errorTechnical = document.getElementById('errorTechnical'); -const successMsg = document.getElementById('successMsg'); +const titleField = document.getElementById("prestationTitle"); +const descriptionField = document.getElementById("prestationDescription"); +const typeField = document.getElementById("prestationType"); +const priceMinField = document.getElementById("priceMin"); +const priceMaxField = document.getElementById("priceMax"); -form.addEventListener('submit', function (e) { +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(); - - errorEmpty.classList.add('d-none'); - errorTechnical.classList.add('d-none'); - successMsg.classList.add('d-none'); + messages.innerHTML = ""; const title = titleField.value.trim(); - - // champ obligatoire manquant - if (title === '') { - errorEmpty.classList.remove('d-none'); + // Champ obligatoire + if (!title) { + showMessage("danger", "Le titre de la prestation est obligatoire."); return; } - // 2️ Simulation d’erreur technique - const erreurTechnique = false; // mettre true pour tester + // Simulation erreur technique + const erreurTechnique = false; // mettre true pour tester if (erreurTechnique) { - errorTechnical.classList.remove('d-none'); + showMessage("danger", "Une erreur est survenue. Veuillez réessayer plus tard."); return; } - //Succès - successMsg.classList.remove('d-none'); + // Succès + showMessage("success", "Prestation modifiée avec succès !"); console.log("Nouvelles données :", { titre: title, @@ -45,8 +49,8 @@ form.addEventListener('submit', function (e) { prixMax: priceMaxField.value }); - // Redirection après un court délai + // Redirection setTimeout(() => { - window.location.href = "../liste_prestation/liste_prestation.html"; -}, 1500); + window.location.href = "/prestations/html/prestation_accueil.html"; + }, 1500); });