|
@@ -94,6 +94,11 @@ async function deleteAppointment(appointmentId) {
|
|
|
method: 'DELETE',
|
|
method: 'DELETE',
|
|
|
body: JSON.stringify({appointmentId: appointmentId})
|
|
body: JSON.stringify({appointmentId: appointmentId})
|
|
|
});
|
|
});
|
|
|
|
|
+ if (response.status === 401) {
|
|
|
|
|
+ window.location.replace("/html/auth.html");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (response.ok) {
|
|
if (response.ok) {
|
|
|
await fetchAppointments();
|
|
await fetchAppointments();
|
|
|
}
|
|
}
|
|
@@ -101,10 +106,17 @@ async function deleteAppointment(appointmentId) {
|
|
|
|
|
|
|
|
async function fetchAppointments() {
|
|
async function fetchAppointments() {
|
|
|
const response = await fetchWithToken("/api/users/appointments");
|
|
const response = await fetchWithToken("/api/users/appointments");
|
|
|
|
|
+ if (response.status === 401) {
|
|
|
|
|
+ window.location.replace("/html/auth.html");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const js = await response.json();
|
|
const js = await response.json();
|
|
|
if (!response.ok) {
|
|
if (!response.ok) {
|
|
|
window.location.replace("/html/404.html");
|
|
window.location.replace("/html/404.html");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
renderAppointments(js);
|
|
renderAppointments(js);
|
|
|
}
|
|
}
|
|
|
|
|
|