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,
|
||||
|
||||
Reference in New Issue
Block a user