diff --git a/prestations/ajouter_prestation/ajouter_prestation.html b/prestations/ajouter_prestation/ajouter_prestation.html index 1370f9f..e1dbf2a 100644 --- a/prestations/ajouter_prestation/ajouter_prestation.html +++ b/prestations/ajouter_prestation/ajouter_prestation.html @@ -74,7 +74,7 @@
- Annuler + Annuler
diff --git a/prestations/ajouter_prestation/ajouter_prestation.js b/prestations/ajouter_prestation/ajouter_prestation.js index 8fc3aaf..70e021e 100644 --- a/prestations/ajouter_prestation/ajouter_prestation.js +++ b/prestations/ajouter_prestation/ajouter_prestation.js @@ -48,5 +48,8 @@ form.addEventListener("submit", function (e) { existingPrestations.push(titre); + setTimeout(() => { + window.location.href = "../liste_prestation/liste_prestation.html"; +}, 1500); }); diff --git a/prestations/liste_prestation/liste_prestation.html b/prestations/liste_prestation/liste_prestation.html new file mode 100644 index 0000000..da22fb1 --- /dev/null +++ b/prestations/liste_prestation/liste_prestation.html @@ -0,0 +1,59 @@ + + + + + + Liste des prestations + + + + + + + +
+

Liste des prestations

+ + +
Prestation supprimée avec succès !
+ +
+ Ajouter une prestation +
+ + + + + + + + + + + + + + + + +
TitreTypeDescriptionTarifActions
+
+ + + + + + + \ No newline at end of file diff --git a/prestations/liste_prestation/liste_prestation.js b/prestations/liste_prestation/liste_prestation.js new file mode 100644 index 0000000..511c1ac --- /dev/null +++ b/prestations/liste_prestation/liste_prestation.js @@ -0,0 +1,61 @@ +// Exemple BDD +const prestations = [ + { + id: 1, + titre: "Toilettage complet", + type: "Chien", + description: "• Bain complet \n• Séchage \n• Coupe aux ciseaux\n• Nettoyage des oreilles", + prixMin: 35, + prixMax: 60 + }, + { + id: 2, + titre: "Toilettage express", + type: "Chat", + description: "• Bain rapide\n• Séchage\n• Brossage", + prixMin: 20, + prixMax: 35 + } +]; + +// Sélection des éléments +const tableBody = document.getElementById('prestationTableBody'); +const successDeleteMsg = document.getElementById('successDeleteMsg'); + +// Fonction pour extrait description +function extrait(desc, limite = 60) { + return desc.length > limite ? desc.substring(0, limite) + '...' : desc; +} + +// Affichage du tableau +function afficherPrestations() { + tableBody.innerHTML = ''; + + prestations.forEach((p, index) => { + const row = ` + + ${p.titre} + ${p.type} + ${extrait(p.description.replace(/\n/g, " "))} + ${p.prixMin}€ - ${p.prixMax}€ + + + Voir + Modifier + + + + `; + tableBody.innerHTML += row; + }); +} + +afficherPrestations(); + +// Suppression +function supprimerPrestation(index) { + prestations.splice(index, 1); + afficherPrestations(); + + successDeleteMsg.classList.remove("d-none"); +} diff --git a/prestations/modifier_prestation/modifier_prestation.html b/prestations/modifier_prestation/modifier_prestation.html index 9066032..19dc713 100644 --- a/prestations/modifier_prestation/modifier_prestation.html +++ b/prestations/modifier_prestation/modifier_prestation.html @@ -69,7 +69,7 @@
- Annuler + Annuler
diff --git a/prestations/modifier_prestation/modifier_prestation.js b/prestations/modifier_prestation/modifier_prestation.js index 865e9bc..8ae8b65 100644 --- a/prestations/modifier_prestation/modifier_prestation.js +++ b/prestations/modifier_prestation/modifier_prestation.js @@ -1,6 +1,6 @@ const form = document.getElementById('editPrestationForm'); -const titleField = document.getElementById('prestationTtile'); +const titleField = document.getElementById('prestationTitle'); const descriptionField = document.getElementById('prestationDescription'); const typeField = document.getElementById('prestationType'); const priceMinField = document.getElementById('priceMin'); @@ -40,8 +40,13 @@ form.addEventListener('submit', function (e) { console.log("Nouvelles données :", { titre: title, type: typeField.value, - description: descField.value, + description: descriptionField.value, prixMin: priceMinField.value, prixMax: priceMaxField.value }); + + // Redirection après un court délai + setTimeout(() => { + window.location.href = "../liste_prestation/liste_prestation.html"; +}, 1500); });