From 5a767ab87befa0ce3b934a7fed5b79fb1001052d Mon Sep 17 00:00:00 2001 From: Sidney Date: Wed, 13 May 2026 09:25:19 -0300 Subject: [PATCH] Fix: WhatsApp deletion flow, AdminBell attachments and UI stability --- GEMINI.md | 1 + MEMORY.md | 4 ++++ manager/components/AdminNotifications.tsx | 2 +- manager/components/Finance.tsx | 5 ++--- manager/server.selfhosted.js | 16 ++++++++++------ 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/GEMINI.md b/GEMINI.md index 7e40179..4575822 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -60,3 +60,4 @@ 31. **Real-Time Bidirectional Sync**: Asaas webhooks MUST update both the PostgreSQL `alunos_cobrancas` table and the legacy `school_data.json` file in real-time to ensure immediate UI feedback in the administrative panel. 32. **Numerical Type Enforcement**: When serving data from PostgreSQL `NUMERIC` columns, the backend MUST map the result to ensure amounts are sent as `Number` (not String) to prevent string concatenation bugs in the frontend. 33. **Reverse Sync Requirement (SQL -> JSON)**: To ensure visual consistency and avoid automation errors (like double billing), the system MUST perform a reverse sync from `alunos_cobrancas` (SQL) to `school_data.payments` (JSON) during server initialization and on-demand via the `/api/admin/sync-finance-json` endpoint. +34. **Deletion & Notification Order (Async)**: When processing deletions that trigger notifications (e.g., WhatsApp via Asaas Webhook), local database deletion MUST happen only AFTER the notification dispatch. Manual deletion routes should only trigger the external API delete and wait for the webhook to finalize local cleanup, ensuring data availability for message variables. diff --git a/MEMORY.md b/MEMORY.md index 282dd54..05d125c 100644 --- a/MEMORY.md +++ b/MEMORY.md @@ -37,6 +37,10 @@ - [x] **Paridade Lógica Absoluta (Frequência):** A lógica de matching de frequência do Portal (`Frequencia.tsx` e `Dashboard.tsx`) agora é um clone 100% idêntico ao do Manager (`AttendanceQuery.tsx`). - [x] **Fix Janela de Matching (Portal):** Corrigido bug onde aulas sem `endTime` fechavam a janela de presença prematuramente (fallback alterado de `00:00:00` para `23:59:00`). - [x] **Resolução de Justificativas Invisíveis:** Justificativas enviadas agora são corretamente mapeadas às aulas no Portal através da sincronização de janelas de tempo e IDs. +- [x] **Correção do Fluxo de Exclusão (WhatsApp):** Ajustada a ordem de exclusão no `server.selfhosted.js` e `Finance.tsx`. A limpeza local agora ocorre apenas após o disparo bem-sucedido do WhatsApp via Webhook, garantindo que as variáveis `{nome}` e `{descricao}` nunca cheguem vazias. +- [x] **Feedback Real de Exclusão:** Implementado `showAlert` detalhado no Financeiro e confirmação real via **Sino de Notificações** (Admin) após o processamento do Webhook. +- [x] **Refinamento do Sino (AdminBell):** O botão "Ver Anexo" agora é exclusivo de notificações de justificativa que possuem arquivo físico, ocultando-se em notificações de sistema que usam o campo anexo para metadados JSON. +- [x] **Blindagem de UI (Financeiro):** Corrigido potencial erro de referência no parse de erro do Asaas que causava "White Screen" em exclusões negadas. ## 📋 Próximos Passos - [ ] Iniciar a migração do módulo Financeiro para 100% SQL seguindo o padrão do Boletim. diff --git a/manager/components/AdminNotifications.tsx b/manager/components/AdminNotifications.tsx index 39a8eb2..7c0ea62 100644 --- a/manager/components/AdminNotifications.tsx +++ b/manager/components/AdminNotifications.tsx @@ -311,7 +311,7 @@ const AdminNotifications: React.FC = ({ data, updateData, setView, onNavi Aceitar )} - {finalAttachment && ( + {isJustificativa && finalAttachment && !String(finalAttachment).startsWith('{') && (