mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-01-18 16:47:35 +01:00
132 lines
4.8 KiB
JavaScript
132 lines
4.8 KiB
JavaScript
import {attachSearchEventListener} from "./search.js";
|
|
import {attachLoginUserDisplayEventListener, attachLoginPraticienDisplayEventListener, attachDisconnectEventListener} from "./login.js";
|
|
import {displayHome, displayHomeTopBar} from "./home.js";
|
|
import {TokenDecode} from "./lib.js";
|
|
console.log("index.js loaded");
|
|
|
|
|
|
//Felix Part
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
if(sessionStorage.getItem("token") !== null) {
|
|
displayHomeTopBar();
|
|
}
|
|
});
|
|
|
|
function attachReturnHomeEventListener() {
|
|
try {
|
|
document.getElementById("home").addEventListener("click", function (event) {
|
|
displayHome("");
|
|
});
|
|
}
|
|
catch (e) {
|
|
//Do nothing
|
|
//console.error(e);
|
|
}
|
|
}
|
|
|
|
|
|
//Yanis Part
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
ButtonShowRdvPraticient();
|
|
});
|
|
|
|
function ButtonShowRdvPraticient() {
|
|
try {
|
|
console.log("test1");
|
|
document.getElementById("praticien-calendar").addEventListener("click", function () {
|
|
console.log("test2");
|
|
ajaxRequest('GET', "src/API/requests.php/api/rdv-praticient?id=" + 1, function (data) {
|
|
console.log("test3");
|
|
DisplayRDVPraticient(data);
|
|
});
|
|
});
|
|
}
|
|
catch (e) {
|
|
//Do nothing
|
|
//console.error(e);
|
|
}
|
|
}
|
|
|
|
function DisplayRDVPraticient(rdv){
|
|
let count = rdv.length;
|
|
let content = document.getElementById("content");
|
|
content.innerHTML = "";
|
|
content.innerHTML = '<div class="h-100"> <div class="d-flex flex-row flex-wrap my-5 mx-5 gap-5 justify-content-center text-center">';
|
|
if(count === 0){
|
|
content.append('<h1>Vous n\'avez pas de rendez-vous</h1>');
|
|
}
|
|
else {
|
|
for (let i = 0; i < count; i++){
|
|
console.log(rdv[i]);
|
|
if (rdv[i].p_mail !== null){
|
|
content.innerHTML = '' +
|
|
'<div class="card rounded-4 mx-2 pointer">' +
|
|
'<div class="card-header bg-danger">' +
|
|
'<div class="d-flex flex-row justify-content-between text-white">' +
|
|
'<p>' + rdv[i].rdv_date + '</p>' +
|
|
'<p>' + rdv[i].rdv_time + '</p>' +
|
|
'</div>' + '</div>' +
|
|
'<div class="card-body">' +
|
|
'<h5 class="card-title">' + rdv[i].patient + '</h5>' +
|
|
'<a href="mailto:' + rdv[i].p_mail + '" class="card-subtitle mb-2 text-body-secondary">' + rdv[i].email + '</a>' +
|
|
'<br>' +
|
|
'<a href="tel:0' + rdv[i].p_phone + '" class="card-subtitle mb-2 text-body-secondary">' + '0' + rdv[i].phone + '</a>' +
|
|
'</div>' + '</div>';
|
|
}
|
|
else{
|
|
content.innerHTML = '' +
|
|
'<div class="card rounded-4 mx-2 pointer">' +
|
|
'<div class="card-header bg-danger">' +
|
|
'<div class="d-flex flex-row justify-content-between text-white">' +
|
|
'<p>' + rdv[i].rdv_date + '</p>' +
|
|
'<p>' + rdv[i].rdv_time + '</p>' +
|
|
'</div>' + '</div>' +
|
|
'<div class="card-body">' +
|
|
'<h5 class="card-title">Vous n\'avez pas de' + '<br>' + 'patient pour ce créneau</h5>' +
|
|
'</div>' + '</div>';
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
function DisplayRDVPatient(rdv){
|
|
let rdvPatient = rdv[0];
|
|
let lieux = rdv[1];
|
|
|
|
let count = $rdvPatient.length;
|
|
$('#content').empty();
|
|
$('#content').html('<div class="h-100"> <div class="row"> <div class="col-3 border-end border-dark border-3 h-100 mt-2 text-center d-flex flex-column justify-content-center"> <div class="d-flex flex-column"> <div class="border-bottom pb-3 border-dark border-3 align-self-center"> <h5 class="text-center">Vos rendez-vous à venir</h5>');
|
|
if(count === 0){
|
|
$('#content').append('<h1>Bienvenue sur Doct\'ISEN, veuillez prendre un rendez-vous en allant à l\'acceuil et en recherchant un praticient!</h1>');
|
|
}
|
|
else {
|
|
for (let i = 0; i < count; i++){
|
|
if($rdvPatient !== "null")
|
|
$('#content').append('' +
|
|
'<div class="card rounded-4 mx-2 pointer">' +
|
|
'<div class="card-header bg-danger">' +
|
|
'<div class="d-flex flex-row justify-content-between text-white">' +
|
|
'<p>' + $rdvPatient[i].rdv_date + '</p>' +
|
|
'<p>' + $rdvPatient[i].rdv_time + '</p>' +
|
|
'</div>' + '</div>' +
|
|
'<div class="card-body">' +
|
|
'<h5 class="card-title"
|
|
}
|
|
}
|
|
}*/
|
|
|
|
|
|
|
|
//End Call
|
|
|
|
ButtonShowRdvPraticient();
|
|
attachSearchEventListener();
|
|
attachLoginUserDisplayEventListener();
|
|
attachLoginPraticienDisplayEventListener();
|
|
attachReturnHomeEventListener();
|
|
attachDisconnectEventListener(); |