feat:ajouter_prestation
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Ajouter une catégorie</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
|
||||
|
||||
<style>
|
||||
body {
|
||||
background: #f4f6f981;
|
||||
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h1 class="mb-5 text-center">Ajouter une prestation</h2>
|
||||
|
||||
<!--Erreur champ vide -->
|
||||
<div id="errorEmpty" class="alert alert-danger d-none">Le titre est obligatoire.</div>
|
||||
|
||||
<!--Erreur nom deja existant -->
|
||||
<div id="errorExists" class="alert alert-danger d-none">Cette prestation existe déjà. Veuillez en choisir
|
||||
une autre.</div>
|
||||
|
||||
<!--Succès ajout catégorie -->
|
||||
<div id="successMessage" class="alert alert-success d-none">Prestation ajoutée avec succès !</div>
|
||||
|
||||
<form id="addCategoryForm">
|
||||
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-bold">Titre de la prestation (obligatoire)</label>
|
||||
<input type="text" id="categoryName" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">Type de prestation</label>
|
||||
<select id="prestationType" class="form-select">
|
||||
<option value="chien" selected>Chien</option>
|
||||
<option value="chat">Chat</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!--Description (liste à puces)-->
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">Description de la prestation</label>
|
||||
<textarea id="prestationDescription" class="form-control" rows="5">
|
||||
•
|
||||
•
|
||||
•
|
||||
• </textarea>
|
||||
</div>
|
||||
|
||||
|
||||
<!--Tariffs-->
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">Tarif (fourchette)</label>
|
||||
<div class="d-flex gap-3">
|
||||
<input type="number" id="priceMin" class="form-control" placeholder="Prix min (€)" value="35">
|
||||
<input type="number" id="priceMax" class="form-control" placeholder="Prix max (€)" value="60">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-3 mt-4">
|
||||
<a href="liste_prestations.html" class="btn btn-secondary w-50">Annuler</a>
|
||||
<button type="submit" class="btn btn-primary w-50">Ajouter</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script src="ajouter_prestation.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
52
prestations/ajouter_prestation/ajouter_prestation.js
Normal file
52
prestations/ajouter_prestation/ajouter_prestation.js
Normal file
@@ -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);
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user