From c7109b101776b891c21227cebf21016d85ac91f7 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 30 Jun 2026 19:00:01 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20uuid/id=20restaurados=20ao=20editar=20di?= =?UTF-8?q?a=20anterior;=20calcAll=E2=86=92updateTotals;=20invoke=20usa=20?= =?UTF-8?q?id;=20senha=20sempre=20pedida?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.html | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/index.html b/src/index.html index 38e9e11..85a4958 100644 --- a/src/index.html +++ b/src/index.html @@ -2389,6 +2389,10 @@ window.abrirFechamentoEdicao = function(full) { const dados = full.dados || full; if (!dados) { alert('Dados detalhados não encontrados neste registro.'); return; } + // IDs do registro — CRÍTICO para o salvamento via Supabase + estado.uuid = full.uuid || null; + estado.id = full.id || full.uuid || null; + // Preenche o estado global com todos os campos do JSONB estado.loja = dados.loja || full.loja || ''; estado.data = dados.data || full.data || ''; @@ -2463,7 +2467,7 @@ window.abrirFechamentoEdicao = function(full) { renderTable('tbl-cartao-pix', estado.cartoes.pix); // Recalcula totais - calcAll(); + updateTotals(); // Rola para o topo do formulário window.scrollTo(0, 0); @@ -2479,11 +2483,15 @@ window.toggleEditConsulta = async function() { // Se já está editando, apenas fecha if (window._editModalOpen) { closeEditModal(); return; } - // Pede senha admin primeiro (se configurada) + // Pede senha admin primeiro — sempre, para proteger edições const pw = config.admin_password; if (pw) { const ok = await askPassword(); if (!ok) return; + } else { + // Sem senha configurada — avisa e abre mesmo assim (primeiro uso) + const ok = await askPassword(); // mostra diálogo vazio para o admin configurar mentalmente + if (!ok) return; } openEditModal(full); @@ -2991,7 +2999,7 @@ window.salvarEdicaoModal = async function() { if (!uuid) { alert('UUID do registro não encontrado.'); return; } console.log('[DEBUG] salvarEdicaoModal uuid:', uuid, 'updates:', JSON.stringify(updates)); - await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { uuid, updates: JSON.stringify(updates) }); + await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { id: uuid, updates: JSON.stringify(updates) }); closeEditModal(); closeRelatorioModal(); alert('✅ Atualizado com sucesso!'); @@ -3252,7 +3260,7 @@ async function salvarEdicaoSupabase() { const id = estado.id || estado.uuid; console.log('[DEBUG] salvando id:', id, 'data:', JSON.stringify(data)); const result = await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { - uuid: id, + id: id, updates: JSON.stringify(data) }); console.log('[DEBUG] sb_atualizar_fechamento result:', result);