Configurar estado inicial de pendientes por defecto en no resueltos y refrescar estado al cargar Pendientes de Sala
This commit is contained in:
@@ -1437,9 +1437,32 @@ const actualizarInternacion = useCallback(async (internacionId: string, datos: P
|
||||
return true;
|
||||
}, []);
|
||||
|
||||
const refreshState = useCallback(async () => {
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/state`);
|
||||
if (!res.ok) throw new Error('no state');
|
||||
const body = await res.json();
|
||||
if (body) {
|
||||
setState(prev => ({
|
||||
...prev,
|
||||
...body,
|
||||
estudiosComplementarios: body.estudiosComplementarios || prev.estudiosComplementarios,
|
||||
interconsultas: body.interconsultas || prev.interconsultas,
|
||||
atb: body.atb || prev.atb,
|
||||
glucemias: body.glucemias || prev.glucemias,
|
||||
movimientosIndicaciones: body.movimientosIndicaciones || prev.movimientosIndicaciones,
|
||||
pendientes: body.pendientes || prev.pendientes,
|
||||
}));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error refreshing state:', err);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return {
|
||||
...state,
|
||||
isLoaded,
|
||||
refreshState,
|
||||
setVista,
|
||||
agregarPaciente,
|
||||
actualizarPaciente,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import {
|
||||
ListTodo,
|
||||
Search,
|
||||
@@ -45,12 +45,16 @@ export function PendientesSala({
|
||||
getPacienteById,
|
||||
getCamaById,
|
||||
}: PendientesSalaProps) {
|
||||
const { currentUser } = useHospitalStore();
|
||||
const { currentUser, refreshState } = useHospitalStore();
|
||||
const [busqueda, setBusqueda] = useState('');
|
||||
const [filtroCategoria, setFiltroCategoria] = useState<string>('todos');
|
||||
const [filtroEstado, setFiltroEstado] = useState<string>('todos');
|
||||
const [filtroEstado, setFiltroEstado] = useState<string>('pendiente');
|
||||
const [filtroFechaProgramada, setFiltroFechaProgramada] = useState<string>('');
|
||||
|
||||
useEffect(() => {
|
||||
refreshState();
|
||||
}, [refreshState]);
|
||||
|
||||
// Active internaciones map for quick lookup
|
||||
const internacionesActivas = internaciones.filter(i => i.activa);
|
||||
const activeInternacionMap = new Map<string, Internacion>();
|
||||
|
||||
Reference in New Issue
Block a user