fix(navigation): redireciona o botão voltar e resetar da imagem para a pasta de RX do paciente no Dashboard
continuous-integration/webhook Deploy concluído (VPS4)

This commit is contained in:
VPS 4 Deploy Agent
2026-06-01 01:39:39 +02:00
parent c85c991c7f
commit 0cbb65acea
2 changed files with 33 additions and 2 deletions
@@ -95,6 +95,37 @@ export default function DashboardPage() {
}, 300);
}, [searchParams]);
// ── URL query patient (abre a pasta de RX do paciente se informado) ──
useEffect(() => {
const patientName = searchParams.get('patient');
if (!patientName) return;
const loadQueryPatient = async () => {
try {
const { data } = await api.get(`/images/patients?search=${encodeURIComponent(patientName)}&limit=10`);
const found = data.find(p => p.patient_name === patientName) || data[0];
if (found) {
setSelectedPatient(found);
setView('patient-images');
loadPatientImages(found.patient_name);
} else {
const fallbackPatient = { patient_name: patientName, doctor: '', remark: '', image_count: 0 };
setSelectedPatient(fallbackPatient);
setView('patient-images');
loadPatientImages(patientName);
}
} catch {
const fallbackPatient = { patient_name: patientName, doctor: '', remark: '', image_count: 0 };
setSelectedPatient(fallbackPatient);
setView('patient-images');
loadPatientImages(patientName);
}
};
loadQueryPatient();
navigate('/', { replace: true });
}, [searchParams]);
// ── Socket.IO: nova imagem em tempo real ──────────────────────────
useEffect(() => {
let debounceTimer;
@@ -183,7 +183,7 @@ export default function ImageDetailsPage() {
rotation: 0, flipH: false, flipV: false, remark: ''
});
showToast('Imagem restaurada para o original!', 'success');
navigate('/patients');
navigate('/?patient=' + encodeURIComponent(patientName));
} catch {
showToast('Erro ao restaurar a imagem.', 'error');
} finally {
@@ -337,7 +337,7 @@ export default function ImageDetailsPage() {
{/* Top Header para navegação / Voltar */}
<header className="header" style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12, width: '100%' }}>
<button className="btn btn-secondary" onClick={() => navigate('/patients')} style={{ padding: '8px 12px' }} title="Voltar ao Painel">
<button className="btn btn-secondary" onClick={() => navigate('/?patient=' + encodeURIComponent(patientName))} style={{ padding: '8px 12px' }} title="Voltar ao Painel">
{isMobile ? '←' : '← Voltar'}
</button>
<div style={{ flex: 1, minWidth: 0 }}>