list des upcoming appointments prettier
Some checks failed
Format / formatting (push) Successful in 6s
Build / build (push) Successful in 1m0s
CI / build (push) Failing after 10s
Format / formatting (pull_request) Successful in 6s

This commit is contained in:
root 2025-05-01 16:05:46 +02:00
parent f46c3756f0
commit 35f314498f

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="appointment-list"> <div class="appointment-list">
<h2>Liste des rendez-vous</h2> <h2>Liste des rendez-vous</h2>
<h3>de {{ store.user.username }}</h3>
<ul v-if="appointments.length"> <ul v-if="appointments.length">
<li v-for="appt in appointments" :key="appt.idAppointment"> <li v-for="appt in appointments" :key="appt.idAppointment">
<strong>Sujet :</strong> {{ appt.appointmentSubject }}<br /> <strong>Sujet :</strong> {{ appt.appointmentSubject }}<br />
@ -23,24 +23,39 @@ import { callApi } from "@/services/api";
import Appointment from "@/ApiClasses/Appointment"; import Appointment from "@/ApiClasses/Appointment";
import { store } from "@/main.ts"; import { store } from "@/main.ts";
// Define the interface for the API response
interface AppointmentResponse {
idAppointment: number;
appointmentSubject: string;
appointmentDate: string;
appointmentTime: string;
appointmentDuration: string;
appointmentPlace: string;
}
const appointments = ref<Appointment[]>([]); const appointments = ref<Appointment[]>([]);
function loadAppointments() { function loadAppointments() {
if (!store.user) { if (!store.user) {
console.error("L'utilisateur n'est pas connecté ou les données utilisateur ne sont pas disponibles."); console.error(
"L'utilisateur n'est pas connecté ou les données utilisateur ne sont pas disponibles."
);
return; return;
} }
console.log("username :", store.user.username); //console.log("username :", store.user.username);
console.log("token :", store.user.token); //console.log("token :", store.user.token);
callApi( callApi(
"/admin/appointments/upcoming", "/admin/appointments/upcoming",
(response) => { (response) => {
appointments.value = response.data.map( appointments.value = response.data.map(
(item: any) => new Appointment(item) (item: AppointmentResponse) => new Appointment(item)
); );
}, },
(error) => { (error) => {
console.error("Erreur lors de la récupération des rendez-vous :", error); console.error(
"Erreur lors de la récupération des rendez-vous :",
error
);
} }
); );
} }