mirror of
https://github.com/BreizhHardware/ProjetS4COMWEB.git
synced 2026-01-18 16:47:35 +01:00
@@ -55,8 +55,39 @@ test = "coucou"
|
||||
POST http://serveur-projet-s4.felix/src/API/requests.php/api/login/patient
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
mail = "nicolasgrenier@example.com" &
|
||||
password = "a"
|
||||
mail = nicolasgrenier@example.com &
|
||||
password = a
|
||||
|
||||
###
|
||||
|
||||
POST http://serveur-projet-s4.felix/src/API/requests.php/api/login/medecin
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
mail = cberger@example.org &
|
||||
password = a
|
||||
|
||||
###
|
||||
|
||||
PUT http://serveur-projet-s4.felix/src/API/requests.php/api/signup/patient
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
mail = felix.marquet@isen-ouest.yncrea.fr &
|
||||
password = a &
|
||||
name = Marquet &
|
||||
surname = Félix &
|
||||
phone = 0645383602
|
||||
|
||||
###
|
||||
|
||||
PUT http://serveur-projet-s4.felix/src/API/requests.php/api/signup/medecin
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
mail = felix.marquet@isen-ouest.yncrea.fr &
|
||||
password = a &
|
||||
name = Marquet &
|
||||
surname = Félix &
|
||||
phone = 0645383602 &
|
||||
specialite = Test &
|
||||
postal = 44470
|
||||
|
||||
###
|
||||
@@ -15,7 +15,7 @@
|
||||
<body>
|
||||
<div id="topbar">
|
||||
<div id="topInfo">
|
||||
<a href="index.php">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
@@ -82,5 +82,7 @@
|
||||
</footer>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/md5.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -4,6 +4,12 @@ console.log("index.js loaded");
|
||||
|
||||
//Felix Part
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
if(sessionStorage.getItem("token") !== null) {
|
||||
displayHomeTopBar();
|
||||
}
|
||||
});
|
||||
|
||||
function displaySearchResults(data) {
|
||||
let container = document.getElementById("content");
|
||||
container.innerHTML = "";
|
||||
@@ -65,7 +71,7 @@ function removeSearchTopBar(){
|
||||
topbar.innerHTML = "";
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a href="index.php">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
@@ -204,13 +210,83 @@ function clearAlert() {
|
||||
alert.innerHTML = "";
|
||||
}
|
||||
|
||||
function displayHome() {
|
||||
function displayHomeTopBar() {
|
||||
let topbar = document.getElementById("topbar");
|
||||
topbar.innerHTML = "";
|
||||
if(sessionStorage.getItem("token") === null) {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<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>
|
||||
`;
|
||||
attachLoginUserDisplayEventListener();
|
||||
attachLoginPraticienDisplayEventListener();
|
||||
}
|
||||
else {
|
||||
let token = sessionStorage.getItem("token");
|
||||
let user = TokenDecode(token);
|
||||
const mailMD5 = CryptoJS.MD5(user.mail);
|
||||
if(user.type === "patient") {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<img src="https://www.gravatar.com/avatar/${mailMD5}?s=64" alt="avatar" id="avatar" style="width: 14.3%; height: auto; border-radius: 50%">
|
||||
<div>
|
||||
<a class="text-white" id="user-name-disconect">${user.name} ${user.surname}</a>
|
||||
</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>`;
|
||||
attachDisconnectEventListener();
|
||||
}
|
||||
else if (user.type === "medecin") {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<a id="home">
|
||||
<p id="DoctISEN" class="top-0 position-fixed">
|
||||
Doct'ISEN
|
||||
</p>
|
||||
</a>
|
||||
<div class="d-flex position-fixed end-0 flex-row align-items-center gap-3 mt-2 top-0">
|
||||
<img src="https://www.gravatar.com/avatar/${mailMD5}?s=64" alt="avatar" id="avatar" style="width: 14.3%; height: auto; border-radius: 50%">
|
||||
<div>
|
||||
<a class="text-white" id="user-name-disconect">${user.name} ${user.surname}</a>
|
||||
</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>`;
|
||||
attachDisconnectEventListener();
|
||||
}
|
||||
else {
|
||||
topbar.innerHTML = `
|
||||
<div id="topInfo">
|
||||
<p class="alert-danger">Erreur</p>
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function displayHome(text) {
|
||||
removeSearchTopBar();
|
||||
displayHomeTopBar();
|
||||
let container = document.getElementById("content");
|
||||
container.classList = "";
|
||||
container.innerHTML = "";
|
||||
container.innerHTML = `
|
||||
<div style="background-color: red; height: 50vh;">
|
||||
<div class="d-flex justify-content-center align-items-center" id="Alert"></div>
|
||||
<div class="d-flex justify-content-center align-items-center" style="background-color: red;" id="Alert"></div>
|
||||
<img src="src/img/img_index.png" alt="img_index" id="img_index">
|
||||
<div id="rdv">
|
||||
<p class="text-white fw-bold fs-3">Trouvez un rendez vous avec un medecin</p>
|
||||
@@ -252,7 +328,9 @@ function displayHome() {
|
||||
</footer>`;
|
||||
attachSearchEventListener();
|
||||
attachLoginUserDisplayEventListener();
|
||||
displayAlert("Rendez-vous pris avec succès");
|
||||
if(text !== ""){
|
||||
displayAlert(text);
|
||||
}
|
||||
}
|
||||
|
||||
function performSearch(event) {
|
||||
@@ -322,7 +400,7 @@ function displayLoginUser() {
|
||||
ajaxRequest('POST', "src/API/requests.php/api/login/patient", function (data) {
|
||||
if (data.message === "Login success") {
|
||||
sessionStorage.setItem("token", data.token);
|
||||
displayHome();
|
||||
displayHome("Vous êtes connecté");
|
||||
} else {
|
||||
alert("Erreur lors de la connexion");
|
||||
}
|
||||
@@ -373,7 +451,7 @@ function displayLoginPraticien() {
|
||||
ajaxRequest('POST', "src/API/requests.php/api/login/medecin", function (data) {
|
||||
if (data.message === "Login success") {
|
||||
sessionStorage.setItem("token", data.token)
|
||||
displayHome();
|
||||
displayHome("Vous êtes connecté");
|
||||
} else {
|
||||
alert("Erreur lors de la connexion");
|
||||
}
|
||||
@@ -562,6 +640,11 @@ function displaySignUpUser() {
|
||||
});
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
sessionStorage.removeItem("token");
|
||||
displayHome("Vous êtes déconnecté");
|
||||
}
|
||||
|
||||
function attachSearchEventListener() {
|
||||
try{
|
||||
document.getElementById("recherche").addEventListener("click", function (event) {
|
||||
@@ -592,15 +675,20 @@ function attachPrendreRDVEventListener() {
|
||||
let buttons = document.querySelectorAll("button[id^='rdv-id-']");
|
||||
buttons.forEach(function (button) {
|
||||
button.addEventListener("click", function (event) {
|
||||
let RDVid = event.target.id.split("-")[2];
|
||||
data = "rdv_id=" + RDVid + "&patient_id=" + 1;
|
||||
ajaxRequest('PUT', "src/API/requests.php/api/rdv", function (returnData){
|
||||
if (returnData.success) {
|
||||
displayHome();
|
||||
} else {
|
||||
alert("Erreur lors de la prise de rendez-vous");
|
||||
}
|
||||
}, data);
|
||||
if(sessionStorage.getItem("token") === null) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -629,6 +717,28 @@ function attachLoginPraticienDisplayEventListener() {
|
||||
}
|
||||
}
|
||||
|
||||
function attachReturnHomeEventListener() {
|
||||
try {
|
||||
document.getElementById("home").addEventListener("click", function (event) {
|
||||
displayHome("");
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
//Do nothing
|
||||
//console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
function attachDisconnectEventListener() {
|
||||
try {
|
||||
document.getElementById("user-name-disconect").addEventListener("click", function (event) {
|
||||
disconnect();
|
||||
});
|
||||
} catch (e) {
|
||||
//Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Yanis Part
|
||||
|
||||
@@ -693,4 +803,6 @@ function ButtonShowRdvPraticient() {
|
||||
ButtonShowRdvPraticient();
|
||||
attachSearchEventListener();
|
||||
attachLoginUserDisplayEventListener();
|
||||
attachLoginPraticienDisplayEventListener();
|
||||
attachLoginPraticienDisplayEventListener();
|
||||
attachReturnHomeEventListener();
|
||||
attachDisconnectEventListener();
|
||||
Reference in New Issue
Block a user