mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-01-18 16:47:35 +01:00
Fix take rdv
This commit is contained in:
@@ -19,6 +19,7 @@ function displayHomeTopBar() {
|
||||
<button type="button" class="btn btn-danger" style="top: 0.4375em;" id="login-praticien">Vous êtes praticien ?</button> <button type="button" class="btn btn-danger" style="top: 0.4375em;" id="login-user">Se connecter</button><p> </p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="searchbar"></div>
|
||||
`;
|
||||
attachLoginUserDisplayEventListener();
|
||||
attachLoginPraticienDisplayEventListener();
|
||||
@@ -42,7 +43,8 @@ function displayHomeTopBar() {
|
||||
</div>
|
||||
<p class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light" id="my-rdv">Mes rendez-vous</p>
|
||||
</div>
|
||||
</div>`;
|
||||
</div>
|
||||
<div id="searchbar"></div>`;
|
||||
attachDisconnectEventListener();
|
||||
}
|
||||
else if (user.type === "medecin") {
|
||||
@@ -60,7 +62,8 @@ function displayHomeTopBar() {
|
||||
</div>
|
||||
<p class="text-white fw-bold link-underline-opacity-75-hover link-underline link-underline-opacity-0 link-offset-3-hover link-underline-light" id="my-rdv-medecin">Mes rendez-vous practicien</p>
|
||||
</div>
|
||||
</div>`;
|
||||
</div>
|
||||
<div id="searchbar"></div>`;
|
||||
attachDisconnectEventListener();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
console.log("take-rdv.js loaded");
|
||||
import {displayHome} from "./home.js";
|
||||
import {TokenDecode} from "./lib.js";
|
||||
console.log("take-rdv.js loaded");
|
||||
|
||||
|
||||
function displayRDVForDate(data) {
|
||||
let container = document.getElementById("rdv-list");
|
||||
@@ -104,7 +106,7 @@ function displayCalendar(data) {
|
||||
document.getElementById("date-selection-form").addEventListener("submit", function(event) {
|
||||
event.preventDefault();
|
||||
let date = document.getElementById("date").value;
|
||||
let id = data[0].m_id; // Assuming 'data' is accessible in this scope and contains the doctor's details
|
||||
let id = data[0].m_id;
|
||||
ajaxRequest('GET', "src/API/requests.php/api/rdv-date?date=" + date + "&id=" + id, function (data) {
|
||||
displayRDVForDate(data);
|
||||
});
|
||||
@@ -133,15 +135,22 @@ function attachPrendreRDVEventListener() {
|
||||
displayHome("Vous devez être connecté pour prendre un rendez-vous");
|
||||
}
|
||||
else{
|
||||
let RDVid = event.target.id.split("-")[2];
|
||||
let data = "rdv_id=" + RDVid + "&patient_id=" + 1;
|
||||
ajaxRequest('PUT', "src/API/requests.php/api/rdv", function (returnData){
|
||||
if (returnData.success) {
|
||||
displayHome("Rendez-vous pris avec succès");
|
||||
} else {
|
||||
alert("Erreur lors de la prise de rendez-vous");
|
||||
}
|
||||
}, data);
|
||||
let decodedToken = TokenDecode(sessionStorage.getItem("token"));
|
||||
if(decodedToken.type !== "patient") {
|
||||
displayHome("Vous devez être un patient pour prendre un rendez-vous");
|
||||
}
|
||||
else {
|
||||
let RDVid = event.target.id.split("-")[2];
|
||||
const id = decodedToken.id;
|
||||
let data = "rdv_id=" + RDVid + "&patient_id=" + id;
|
||||
ajaxRequest('PUT', "src/API/requests.php/api/rdv", function (returnData){
|
||||
if (returnData.success) {
|
||||
displayHome("Rendez-vous pris avec succès");
|
||||
} else {
|
||||
alert("Erreur lors de la prise de rendez-vous");
|
||||
}
|
||||
}, data);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
function checkMailMatch(mailContainer, mailConfirmContainer, signupButton) {
|
||||
if (mailContainer.value !== mailConfirmContainer.value) {
|
||||
signupButton.classList.add("disabled");
|
||||
document.getElementById("mail-error").innerHTML = "Emails don't match";
|
||||
} else {
|
||||
signupButton.classList.remove("disabled");
|
||||
document.getElementById("mail-error").innerHTML = "";
|
||||
}
|
||||
}
|
||||
|
||||
function checkPasswordMatch(passwordContainer, passwordConfirmContainer, signupButton) {
|
||||
if (passwordContainer.value !== passwordConfirmContainer.value) {
|
||||
signupButton.classList.add("disabled");
|
||||
document.getElementById("password-error").innerHTML = "Passwords don't match";
|
||||
} else {
|
||||
signupButton.classList.remove("disabled");
|
||||
document.getElementById("password-error").innerHTML = "";
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const mailContainer = document.getElementById("mail");
|
||||
const mailConfirmContainer = document.getElementById("mailConfirmation");
|
||||
const passwordContainer = document.getElementById("password");
|
||||
const passwordConfirmContainer = document.getElementById("passwordConfirmation");
|
||||
const signupButton = document.getElementById("signupButton");
|
||||
|
||||
mailContainer.addEventListener("keyup", function() {
|
||||
checkMailMatch(mailContainer, mailConfirmContainer, signupButton);
|
||||
});
|
||||
|
||||
mailConfirmContainer.addEventListener("keyup", function() {
|
||||
checkMailMatch(mailContainer, mailConfirmContainer, signupButton);
|
||||
});
|
||||
|
||||
passwordContainer.addEventListener("keyup", function() {
|
||||
checkPasswordMatch(passwordContainer, passwordConfirmContainer, signupButton);
|
||||
});
|
||||
|
||||
passwordConfirmContainer.addEventListener("keyup", function() {
|
||||
checkPasswordMatch(passwordContainer, passwordConfirmContainer, signupButton);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user