From 041d31d54a8bb5ef10667ee89bf362cc1992ef6a Mon Sep 17 00:00:00 2001 From: Sidney Date: Fri, 24 Apr 2026 09:39:08 -0300 Subject: [PATCH] fix: total stability patch - session persistence, auto-polling and notification fixes --- manager/components/AdminNotifications.tsx | 21 +++--- manager/components/AttendanceQuery.tsx | 3 +- manager/components/Sidebar.tsx | 5 +- manager/index.tsx | 88 ++++++++++++++--------- portal/server.selfhosted.js | 8 ++- 5 files changed, 78 insertions(+), 47 deletions(-) diff --git a/manager/components/AdminNotifications.tsx b/manager/components/AdminNotifications.tsx index 9d2f3c4..d24286f 100644 --- a/manager/components/AdminNotifications.tsx +++ b/manager/components/AdminNotifications.tsx @@ -63,8 +63,9 @@ const AdminNotifications: React.FC = ({ data, updateData, setView, onNavi if (!notif.read) handleMarkAsRead(notif.id); if (notif.title.toLowerCase().includes('justificativa') || notif.message.toLowerCase().includes('justificativa')) { - if (onNavigateToStudent) { - onNavigateToStudent(notif.studentId); + const targetId = (notif as any).fromStudentId || notif.studentId; + if (onNavigateToStudent && targetId !== 'admin') { + onNavigateToStudent(targetId); } else { setView(View.AttendanceQuery); } @@ -94,8 +95,11 @@ const AdminNotifications: React.FC = ({ data, updateData, setView, onNavi ); if (pendingAbsences.length > 0) { - // Tenta achar pelo studentId mencionado na mensagem ou aceita o mais recente - const matchedAbsence = pendingAbsences[0]; // aceita o mais recente pendente + // Tenta achar pelo studentId mencionado ou associado à notificação + const targetId = (notif as any).fromStudentId; + const matchedAbsence = targetId + ? pendingAbsences.find(a => a.studentId === targetId) || pendingAbsences[0] + : pendingAbsences[0]; const updatedAttendance = (data.attendance || []).map(a => a.id === matchedAbsence.id ? { ...a, justificationAccepted: true } : a @@ -168,7 +172,7 @@ const AdminNotifications: React.FC = ({ data, updateData, setView, onNavi try { const parsed = JSON.parse(notif.message); displayMessage = parsed.motivo || displayMessage; - attachmentFromMessage = parsed.arquivo_base64 || null; + attachmentFromMessage = parsed.arquivo || parsed.arquivo_base64 || null; } catch(e) {} } @@ -189,13 +193,14 @@ const AdminNotifications: React.FC = ({ data, updateData, setView, onNavi {displayMessage}

{(!notif.read) && ( -
+
{isJustificativa && (