diff --git a/healthmanager/package-lock.json b/healthmanager/package-lock.json index e18a08c..d6d596e 100644 --- a/healthmanager/package-lock.json +++ b/healthmanager/package-lock.json @@ -12,6 +12,7 @@ "@mui/material": "^5.15.15", "@mui/styled-engine": "^5.15.14", "axios": "^1.6.8", + "jspdf": "^2.5.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.23.0" @@ -1624,6 +1625,12 @@ "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz", "integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==" }, + "node_modules/@types/raf": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/@types/raf/-/raf-3.4.3.tgz", + "integrity": "sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw==", + "optional": true + }, "node_modules/@types/react": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.1.tgz", @@ -1882,6 +1889,17 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, + "node_modules/atob": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", + "bin": { + "atob": "bin/atob.js" + }, + "engines": { + "node": ">= 4.5.0" + } + }, "node_modules/available-typed-arrays": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", @@ -1943,6 +1961,15 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "node_modules/base64-arraybuffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz", + "integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==", + "optional": true, + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1985,6 +2012,17 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/btoa": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz", + "integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==", + "bin": { + "btoa": "bin/btoa.js" + }, + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/call-bind": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", @@ -2032,6 +2070,31 @@ } ] }, + "node_modules/canvg": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/canvg/-/canvg-3.0.10.tgz", + "integrity": "sha512-qwR2FRNO9NlzTeKIPIKpnTY6fqwuYSequ8Ru8c0YkYU7U0oW+hLUvWadLvAu1Rl72OMNiFhoLu4f8eUjQ7l/+Q==", + "optional": true, + "dependencies": { + "@babel/runtime": "^7.12.5", + "@types/raf": "^3.4.0", + "core-js": "^3.8.3", + "raf": "^3.4.1", + "regenerator-runtime": "^0.13.7", + "rgbcolor": "^1.0.1", + "stackblur-canvas": "^2.0.0", + "svg-pathdata": "^6.0.3" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/canvg/node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", + "optional": true + }, "node_modules/chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -2089,6 +2152,17 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, + "node_modules/core-js": { + "version": "3.37.1", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.37.1.tgz", + "integrity": "sha512-Xn6qmxrQZyB0FFY8E3bgRXei3lWDJHhvI+u0q9TKIYM49G8pAr0FgnnrFRAmsbptZL1yxRADVXn+x5AGsbBfyw==", + "hasInstallScript": true, + "optional": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/cosmiconfig": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.1.0.tgz", @@ -2118,6 +2192,15 @@ "node": ">= 8" } }, + "node_modules/css-line-break": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.1.0.tgz", + "integrity": "sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==", + "optional": true, + "dependencies": { + "utrie": "^1.0.2" + } + }, "node_modules/csstype": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", @@ -2260,6 +2343,12 @@ "csstype": "^3.0.2" } }, + "node_modules/dompurify": { + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.5.4.tgz", + "integrity": "sha512-l5NNozANzaLPPe0XaAwvg3uZcHtDBnziX/HjsY1UcDj1MxTK8Dd0Kv096jyPK5HRzs/XM5IMj20dW8Fk+HnbUA==", + "optional": true + }, "node_modules/electron-to-chromium": { "version": "1.4.750", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.750.tgz", @@ -2818,6 +2907,11 @@ "reusify": "^1.0.4" } }, + "node_modules/fflate": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.4.8.tgz", + "integrity": "sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==" + }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -3174,6 +3268,19 @@ "react-is": "^16.7.0" } }, + "node_modules/html2canvas": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.4.1.tgz", + "integrity": "sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==", + "optional": true, + "dependencies": { + "css-line-break": "^2.1.0", + "text-segmentation": "^1.0.3" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/ignore": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", @@ -3667,6 +3774,23 @@ "node": ">=6" } }, + "node_modules/jspdf": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/jspdf/-/jspdf-2.5.1.tgz", + "integrity": "sha512-hXObxz7ZqoyhxET78+XR34Xu2qFGrJJ2I2bE5w4SM8eFaFEkW2xcGRVUss360fYelwRSid/jT078kbNvmoW0QA==", + "dependencies": { + "@babel/runtime": "^7.14.0", + "atob": "^2.1.2", + "btoa": "^1.2.1", + "fflate": "^0.4.8" + }, + "optionalDependencies": { + "canvg": "^3.0.6", + "core-js": "^3.6.0", + "dompurify": "^2.2.0", + "html2canvas": "^1.0.0-rc.5" + } + }, "node_modules/jsx-ast-utils": { "version": "3.3.5", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", @@ -4051,6 +4175,12 @@ "node": ">=8" } }, + "node_modules/performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", + "optional": true + }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -4146,6 +4276,15 @@ } ] }, + "node_modules/raf": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz", + "integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==", + "optional": true, + "dependencies": { + "performance-now": "^2.1.0" + } + }, "node_modules/react": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", @@ -4307,6 +4446,15 @@ "node": ">=0.10.0" } }, + "node_modules/rgbcolor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz", + "integrity": "sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==", + "optional": true, + "engines": { + "node": ">= 0.8.15" + } + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -4520,6 +4668,15 @@ "node": ">=0.10.0" } }, + "node_modules/stackblur-canvas": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/stackblur-canvas/-/stackblur-canvas-2.7.0.tgz", + "integrity": "sha512-yf7OENo23AGJhBriGx0QivY5JP6Y1HbrrDI6WLt6C5auYZXlQrheoY8hD4ibekFKz1HOfE48Ww8kMWMnJD/zcQ==", + "optional": true, + "engines": { + "node": ">=0.1.14" + } + }, "node_modules/string.prototype.matchall": { "version": "4.0.11", "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.11.tgz", @@ -4646,6 +4803,24 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/svg-pathdata": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/svg-pathdata/-/svg-pathdata-6.0.3.tgz", + "integrity": "sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==", + "optional": true, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/text-segmentation": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.3.tgz", + "integrity": "sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==", + "optional": true, + "dependencies": { + "utrie": "^1.0.2" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -4811,6 +4986,15 @@ "punycode": "^2.1.0" } }, + "node_modules/utrie": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/utrie/-/utrie-1.0.2.tgz", + "integrity": "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==", + "optional": true, + "dependencies": { + "base64-arraybuffer": "^1.0.2" + } + }, "node_modules/vite": { "version": "5.2.10", "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.10.tgz", diff --git a/healthmanager/package.json b/healthmanager/package.json index d941ae7..894d783 100644 --- a/healthmanager/package.json +++ b/healthmanager/package.json @@ -14,6 +14,7 @@ "@mui/material": "^5.15.15", "@mui/styled-engine": "^5.15.14", "axios": "^1.6.8", + "jspdf": "^2.5.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.23.0" diff --git a/healthmanager/src/DescargaRecetas.css b/healthmanager/src/DescargaRecetas.css index e2c62ac..6cd524d 100644 --- a/healthmanager/src/DescargaRecetas.css +++ b/healthmanager/src/DescargaRecetas.css @@ -1,26 +1,54 @@ -.descarga-recetas { - padding: 2rem; - text-align: center; +#headerFacultad{ + margin-left: 50px; + text-align: left; + font-family: Arial, Helvetica, sans-serif; } - -.titulo { - margin-bottom: 2rem; +#box1{ + padding-top: 15px; + margin-right: 20px; } - -.contenedor-recetas { +#box2{ + padding-top: 15px; +} +#headerPublicaciones{ + margin-left: 50px; +} +#divPublicaciones{ display: flex; - flex-direction: column; - align-items: center; + padding: auto; } - -.receta-item { +#divsPublicaciones2{ + width: 600px; + text-align:justify; + font-family:Georgia, 'Times New Roman', Times, serif; + padding-top: 15px; + } +#boxCerrar{ + margin-left: auto; + margin-right: 100px; + padding: auto; +} +#division{ + margin-top: 20px; +} +#botonEliminar{ + margin: 0 auto; +} +#listaEliminar{ display: flex; - justify-content: space-between; - align-items: center; - width: 100%; - max-width: 600px; - margin-bottom: 1rem; - padding: 1rem; - background-color: #f5f5f5; - border-radius: 4px; + +} +#divLista2{ + width: 600px; + display: grid; + margin: 0 auto; +} +#divBotonesRecetas{ + display: flex; + margin-left: auto; + margin-right: 100px; +} +#leyendaPublicacion{ + margin-right: auto; + margin-left: 50px; } \ No newline at end of file diff --git a/healthmanager/src/DescargaRecetas.jsx b/healthmanager/src/DescargaRecetas.jsx index 86e313d..7e900c0 100644 --- a/healthmanager/src/DescargaRecetas.jsx +++ b/healthmanager/src/DescargaRecetas.jsx @@ -1,62 +1,117 @@ -import { useState, useEffect } from 'react'; -import axios from 'axios'; -import { Button, Box, Typography, List, ListItem, ListItemText } from '@mui/material'; -import './DescargaRecetas.css'; +/* eslint-disable no-unused-vars */ +import { Button, Box, TextField ,DialogContentText, Divider} from "@mui/material" +import axios from "axios" +import {useEffect,useState } from "react" +import './DescargaRecetas.css' +import { useNavigate } from 'react-router-dom' +import jsPDF from "jspdf" -function DescargaRecetas() { - const [recetas, setRecetas] = useState([]); - const [cargando, setCargando] = useState(false); - useEffect(() => { - const fetchRecetas = async () => { - setCargando(true); - try { - const respuesta = await axios.get('/api/recetas'); - setRecetas(respuesta.data); - } catch (error) { - console.error('Error al obtener las recetas:', error); - } - setCargando(false); - }; +// eslint-disable-next-line no-unused-vars +function DescargaRecetas(props) { + const navigate = useNavigate(); + const [publicacionesData, setPublicacionesData] = useState([]); + const [Cargando, setCargando] = useState (false) + const [datosID, setDatosID] = useState( {idPublicacion:''} ) + const nombreUsuario = window.localStorage.getItem("IDUsuario"); - fetchRecetas().then(() =>{}); - }, []); + const cambiosID = (evento) => { + const {name, value} = evento.target + setDatosID( { ...datosID, [name] : value }) + } - const descargarReceta = (recetaId) => { + const regresarPrincipal = () => { + navigate('/Principal'); + } - console.log('Descargando receta:', recetaId); + const cerrarSesion = () => { + navigate('/'); + } + + const obtenerListaMisPublicaciones = async () => { + try { + const response = await axios.get("http://localhost:4567/MisRecetas", { params: { idUsuario: nombreUsuario } }); + console.log(response.data) + console.log(nombreUsuario) + setPublicacionesData(response.data); + } catch (error) { + console.error('Error al obtener el id del usuario:', error); + } }; + obtenerListaMisPublicaciones() + + const peticionEliminar=async()=>{ + try { + const respuesta= await axios.post("https://back-endproyectofinal8-production-a397.up.railway.app/eliminarPublicacion",{params:{idPublicacion:window.localStorage.getItem("idePublicacion")}}); + return respuesta; + } catch (error) { + console.log(error); + } + } + + const procesarEliminacion=async()=>{ + setCargando(true); + try { + const respuesta=await peticionEliminar(); + console.log("Respuesta de publicacion a eliminar", respuesta.data); + alert("Publicacion eliminada",respuesta.data); + setCargando(false); + } catch (error) { + console.log(error); + setCargando(false); + } + } + + const generarPdf= (idReceta,nombreMedico,contactoMedico,fecha) =>{ + var doc = new jsPDF(); + const docWidth = doc.internal.pageSize.getWidth(); + doc.text(10, 10,'Receta No.'+ idReceta); + doc.line(0, 12, docWidth, 12); + doc.text(10, 20,'Medico: '+nombreMedico) + doc.text(10, 30,'Contacto: '+contactoMedico) + doc.text(10, 40,'Fecha: '+fecha) + doc.save('Receta '+ fecha + ' .pdf'); + } return ( -
Visualiza tus recetas.
+Receta No. ({elemento.idRec})
+{elemento.nombreMed}
+{elemento.contactoMed}
+{elemento.fecha}
+ +Seguimiento medico de pacientes
+Visualiza tu datos como Usuario, Correo y Contraseña.
+