From 71f5a4159f7802c121ded96cfe2167293b646334 Mon Sep 17 00:00:00 2001 From: Sidney Date: Fri, 1 May 2026 11:10:13 -0300 Subject: [PATCH] fix: delay de 5s no envio, mensagens de erro detalhadas e cache-busting no Manager --- manager/components/ReportCard.tsx | 18 +++++++++++------- portal/src/pages/Avaliacoes.tsx | 9 +++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/manager/components/ReportCard.tsx b/manager/components/ReportCard.tsx index e812054..7e438fe 100644 --- a/manager/components/ReportCard.tsx +++ b/manager/components/ReportCard.tsx @@ -114,10 +114,10 @@ const ReportCard: React.FC = ({ data, updateData }) => { setSelectedStudent(student); const initialGrades: Record> = {}; - // Buscar notas do Postgres + // Buscar notas do Postgres (com cache busting) let dbNotas: any[] = []; try { - const resNotas = await fetch(`/api/notas/${student.id}`); + const resNotas = await fetch(`/api/notas/${student.id}?t=${new Date().getTime()}`); if (resNotas.ok) { const json = await resNotas.json(); dbNotas = json.notas || []; @@ -127,7 +127,7 @@ const ReportCard: React.FC = ({ data, updateData }) => { } try { - const res = await fetch(`/api/student-submissions/${student.id}`); + const res = await fetch(`/api/student-submissions/${student.id}?t=${new Date().getTime()}`); if (res.ok) { const { submissions } = await res.json(); const subsMap: Record = {}; @@ -591,10 +591,14 @@ const ReportCard: React.FC = ({ data, updateData }) => { {exam.description && (

{exam.description}

)} - {studentSubmissions[exam.id] && ( -
- {studentSubmissions[exam.id].acertos} Acertos - {studentSubmissions[exam.id].erros} Erros + {studentSubmissions[String(exam.id).trim()] && ( +
+ + {studentSubmissions[String(exam.id).trim()].acertos} Acertos + + + {studentSubmissions[String(exam.id).trim()].erros} Erros +
)}
diff --git a/portal/src/pages/Avaliacoes.tsx b/portal/src/pages/Avaliacoes.tsx index 347b2fa..63e1351 100644 --- a/portal/src/pages/Avaliacoes.tsx +++ b/portal/src/pages/Avaliacoes.tsx @@ -141,6 +141,9 @@ export default function Avaliacoes() { }); const data = await res.json(); + + // Artificial delay of 5 seconds to let the student read the message + await new Promise(resolve => setTimeout(resolve, 5000)); if (data.success) { // Show Success Modal @@ -148,9 +151,6 @@ export default function Avaliacoes() { setModalMsg(`Sua ${typeLabel} foi enviada com sucesso! Clique em OK para ver seu resultado.`); setShowModal(true); - // Wait for user to click OK before showing result? - // No, user wants result. But let's follow the "sent successfully" request. - // We'll set a callback to OK button to show result setConfirmCallback(() => { setResult(data.result); setView('result'); @@ -158,7 +158,8 @@ export default function Avaliacoes() { }); } else { const errorCode = `ERR-${activeExam.id.substring(0, 4)}-${new Date().getTime().toString().slice(-4)}`; - showAppAlert(`Não foi possível enviar sua nota. Tente novamente ou contate o suporte. (Código: ${errorCode})`, 'error'); + // Use the error message from server if available + showAppAlert(data.error || `Não foi possível enviar sua nota. Tente novamente ou contate o suporte. (Código: ${errorCode})`, 'error'); if (!autoSubmit) setView('listing'); } } catch (err) {