Skip to content

Commit

Permalink
Merge pull request #58 from FraanBat/Rama_Franco
Browse files Browse the repository at this point in the history
Agregado consulta de especialistas
  • Loading branch information
FraanBat authored Jun 20, 2024
2 parents fd21c75 + 4c2463d commit 4f0d03f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
8 changes: 5 additions & 3 deletions static/js/buscarListadoEspecialistas.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//Solicita a la API el listado con todos los especialistas y lo guarda
const solicitarEspecialistas = function() {
fetch(`https://api.mockaroo.com/api/9d323580?count=80&key=b59cfd90`)
.then(response => response.json())
.then(data => {
if(localStorage.getItem("usuarioLogueado") !== null){
fetch("http://127.0.0.1:5000/solicitarEspecialistas/" + localStorage.getItem("usuarioLogueado"))
.then(response => response.json())
.then(data => {
sessionStorage.setItem("listadoEspecialistas", JSON.stringify(data))
sessionStorage.setItem("FiltradoEspecialistaBuscado", JSON.stringify(data))
})
.catch(error => console.error(error))
}
}

solicitarEspecialistas()
12 changes: 9 additions & 3 deletions static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
const validarLogin = function (especialidad) {
if (localStorage.getItem("usuarioLogueado") !== null) {
let listaEspecialistasABuscar = JSON.parse(sessionStorage.getItem("listadoEspecialistas"))
listaEspecialistasABuscar = listaEspecialistasABuscar.filter(especialista => especialista.profesion === especialidad)
sessionStorage.setItem("FiltradoEspecialistaBuscado", JSON.stringify(listaEspecialistasABuscar))
window.location.replace("templates/servicios.html")
if(listaEspecialistasABuscar.filter(especialista => especialista.profesion === especialidad).length > 0)
{
listaEspecialistasABuscar = listaEspecialistasABuscar.filter(especialista => especialista.profesion === especialidad)
sessionStorage.setItem("FiltradoEspecialistaBuscado", JSON.stringify(listaEspecialistasABuscar))
window.location.replace("templates/servicios.html")
}
else {
alert("Lo siento, pero no se encontraron especialistas con las especificaciones realizadas")
}
}
else {
alert("Lo siento, pero debe estar logueado para usar la funcionalidad de búsqueda de especialista")
Expand Down
2 changes: 1 addition & 1 deletion templates/servicios.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Servicios</title>
<link rel="shortcut icon" href="static/img/favicon/casaLista.ico" type="image/x-icon">
<link rel="shortcut icon" href="../static/img/favicon/casaLista.ico" type="image/x-icon">
<link rel="stylesheet" href="../static/css/general.css">
<link rel="stylesheet" href="../static/css/header.css">
<link rel="stylesheet" href="../static/css/servicios.css">
Expand Down

0 comments on commit 4f0d03f

Please sign in to comment.