Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/contexts/NavegacionContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function NavegacionProvider({ children }) {
const [recargarPagina, setRecargarPagina] = useState(false);
const { mode, setMode } = useColorScheme();
const { i18n } = useTranslation();
const idioma = useMemo(() => i18n.language, [i18n.language]);
const idioma = useMemo(() => i18n.language.split("-")[0], [i18n.language]);
const tema = useMemo(() => {
if (mode == "system" || mode == undefined) {
if (window.matchMedia("(prefers-color-scheme: light)").matches) {
Expand Down
24 changes: 21 additions & 3 deletions src/pages/diagnosticos/VerDiagnosticoPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { peticionApi } from "../../services/Api";
import { ChipDiagnostico, ChipSexo, ChipValidado } from "../../components/tabs/Chips";
import ContLime from "../../components/diagnosticos/ContLime";
import { useTranslation } from "react-i18next";
import { DatosIcono } from "../../components/icons/IconosSidebar";

/**
* Página para ver los datos de un diagnóstico.
Expand Down Expand Up @@ -201,6 +202,11 @@ export default function VerDiagnosticoPage() {
if (datos.success && datos.data != []) {
setDiagOriginal({ ...datos.data });

if (rol != CODIGO_ADMIN && datos.data.medico != auth.authInfo.uid) {
volverPestanaAnterior();
return;
}

if (rol == CODIGO_ADMIN) {
await cargarDatosMedico(token, datos.data.medico);
} else {
Expand All @@ -209,7 +215,7 @@ export default function VerDiagnosticoPage() {

preprocesarDiag(datos.data);
} else if (DB != null && !datos.success) {
navigate("/diagnosticos", { replace: true });
volverPestanaAnterior();
}
};

Expand Down Expand Up @@ -316,12 +322,24 @@ export default function VerDiagnosticoPage() {
});
};

/**
* Vuelve a la pestaña anterior cuando el diagnóstico no existe o el usuario no tiene permisos para verlo.
* Se requiere el timeout porque sino hay condiciones de carrera con el sessionStorage y navigate.
*/
const volverPestanaAnterior = () => {
setTimeout(() => {
sessionStorage.removeItem("paciente");
sessionStorage.setItem("descargando-drive", "false");
navigate("/diagnosticos", { replace: true });
}, 100);
};

/**
* Determina el tamaño del elemento dentro de la malla.
* Si se visualiza desde un dispositivo movil en orientación horizontal y el menú o en escritorio,
* se ajusta el contenido a 2 columnas, en caso contrario se deja en 1 columna.
* @param {Int} indice
* @returns Int
* @returns {Int}
*/
const detVisualizacion = (indice) => {
const { orientacion, mostrarMenu, dispositivoMovil, ancho } = navegacion;
Expand Down Expand Up @@ -525,7 +543,7 @@ export default function VerDiagnosticoPage() {
urlPredet="/diagnosticos"
titulo={t("titDiagnostico")}
pestanas={listadoPestanas}
tooltip={t("txtVolverAtrasDiagnosticos")}/>
tooltip={t("txtVolverAtrasDiagnosticos")} />
<Grid container
columns={12}
spacing={1}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/diagnosticos/VerDiagnosticosPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function VerDiagnosticosPage() {
{ id: "sexo", label: t("txtCampoSexo"), componente: (x) => <ChipSexo sexo={x.sexo} />, ordenable: true },
{ id: "diagnostico", label: t("txtCampoDiagModelo"), componente: (x) => <ChipDiagnostico diagnostico={x.diagnostico} />, ordenable: true },
{ id: "validado", label: t("txtCampoDiagMedico"), componente: (x) => <ChipValidado validado={x.validado} />, ordenable: true }
]), [navegacion.idioma]);
]), [camposVariables, navegacion.idioma]);
const camposTabla = useMemo(() => {
return (rol != CODIGO_ADMIN) ? camposFijos.concat([{ id: "accion", label: t("txtAccion"), componente: null, ordenable: false }]) : camposFijos;
}, [rol, camposFijos, navegacion.idioma]);
Expand Down Expand Up @@ -437,7 +437,7 @@ export default function VerDiagnosticosPage() {
/**
* Botón para validar diagnóstico
* @param {JSON} diagnostico - Diagnóstico a validar.
* @returns JSX.Element
* @returns {JSX.Element}
*/
const BtnValidar = (diagnostico) => {
const func = (x) => {
Expand Down