suppression de Appointement
Some checks failed
Format / formatting (push) Successful in 7s
Build / build (push) Successful in 42s
CI / build (push) Failing after 11s
Format / formatting (pull_request) Successful in 6s

This commit is contained in:
root 2025-04-27 21:52:43 +02:00
parent a895b0afda
commit 3de1ec71ff

View File

@ -1,169 +0,0 @@
<template>
<div>
<h2>Ajouter / Modifier un Rapport pour un Rendez-vous</h2>
<form @submit.prevent="submitReport">
<div>
<label for="appointmentId">ID du rendez-vous :</label>
<div style="display: flex; align-items: center; gap: 0.5rem;">
<button type="button" @click="decrementId">-</button>
<input
type="number"
id="appointmentId"
v-model.number="appointmentId"
min="1"
style="width: 60px; text-align: center;"
/>
<button type="button" @click="incrementId">+</button>
</div>
</div>
<div>
<label for="reportContent">Contenu du rapport :</label>
<textarea
id="reportContent"
v-model="reportContent"
required
></textarea>
</div>
<button type="submit">{{ isUpdate ? "Mettre à jour" : "Créer" }} le rapport</button>
</form>
<p v-if="responseMessage">{{ responseMessage }}</p>
</div>
</template>
<script>
export default {
data() {
return {
appointmentId: 1, // Valeur initiale par défaut
reportContent: "",
responseMessage: "",
isUpdate: false, // Détermine si l'on fait une mise à jour ou une création
};
},
methods: {
incrementId() {
this.appointmentId++;
},
decrementId() {
if (this.appointmentId > 1) {
this.appointmentId--;
}
},
async submitReport() {
const reportData = {
reportContent: this.reportContent,
};
let url = `/admin/appointments/report/${this.appointmentId}`;
let method = this.isUpdate ? "PUT" : "POST";
try {
const response = await this.$axios({
method,
url,
data: reportData,
});
if (response.status === 201 || response.status === 200) {
this.responseMessage = "Rapport " + (this.isUpdate ? "mis à jour" : "créé") + " avec succès.";
}
} catch (error) {
if (error.response && error.response.status === 400) {
this.responseMessage = "Requête invalide. Vérifiez les informations.";
} else if (error.response && error.response.status === 401) {
this.responseMessage = "Vous n'êtes pas autorisé à effectuer cette action.";
} else {
this.responseMessage = "Une erreur est survenue. Veuillez réessayer.";
}
}
},
},
watch: {
appointmentId(newVal) {
if (newVal) {
this.isUpdate = true;
}
},
},
};
</script>
<style scoped>
/* Centrer le formulaire */
div {
max-width: 600px;
margin: 0 auto;
padding: 1rem;
background-color: #f9f9f9;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
/* Titre */
h2 {
text-align: center;
color: #333;
margin-bottom: 1rem;
}
/* Formulaire */
form {
display: flex;
flex-direction: column;
gap: 1rem;
}
/* Boutons */
button {
padding: 0.5rem 1rem;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
/* Input et Textarea */
input[type="number"],
textarea {
width: 100%;
padding: 0.5rem;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
}
textarea {
height: 120px;
resize: none;
}
/* Message de réponse */
p {
text-align: center;
font-weight: bold;
color: green;
}
/* Boutons d'incrémentation/décrémentation */
div[style*="display: flex"] button {
background-color: #6c757d;
color: white;
border: none;
border-radius: 4px;
padding: 0.5rem;
}
div[style*="display: flex"] button:hover {
background-color: #5a6268;
}
</style>