Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fea957dfb9 |
+34
-24
@@ -1930,9 +1930,12 @@ if (btnAnterior) {
|
||||
console.log('[DEBUG] btn-anterior clicado');
|
||||
const loja = val('f-loja') || 'União';
|
||||
console.log('[DEBUG] btn-anterior loja:', loja);
|
||||
const hasTauri = !!(window.__TAURI__ && window.__TAURI__.core);
|
||||
|
||||
// Salva rascunho atual antes de tudo
|
||||
await tauriSaveLocal();
|
||||
if (hasTauri) {
|
||||
try { await window.__TAURI__.core.invoke('salvar_rascunho_local', {}); } catch(e) { console.warn('salvar_rascunho_local:', e); }
|
||||
}
|
||||
|
||||
// Calcula dia anterior
|
||||
const prevDate = new Date(estado.data);
|
||||
@@ -1948,11 +1951,15 @@ if (btnAnterior) {
|
||||
|
||||
// Carrega lista de fechamentos recentes do Supabase com uuid
|
||||
let recentList = [];
|
||||
try {
|
||||
recentList = await window.__TAURI__.core.invoke('sb_listar_recentes', { loja, limite: 20 });
|
||||
console.log('[DEBUG] sb_listar_recentes retornou:', recentList?.length, 'itens');
|
||||
} catch(e) {
|
||||
console.warn('sb_listar_recentes falhou:', e);
|
||||
if (hasTauri) {
|
||||
try {
|
||||
recentList = await window.__TAURI__.core.invoke('sb_listar_recentes', { loja, limite: 20 });
|
||||
console.log('[DEBUG] sb_listar_recentes retornou:', recentList?.length, 'itens');
|
||||
} catch(e) {
|
||||
console.warn('sb_listar_recentes falhou:', e);
|
||||
}
|
||||
} else {
|
||||
console.warn('Tauri não disponível, pulando sb_listar_recentes');
|
||||
}
|
||||
|
||||
// Extrai datas únicas ordenadas + mapeamento data→id
|
||||
@@ -1997,24 +2004,27 @@ if (btnAnterior) {
|
||||
|
||||
// Tenta Supabase primeiro (com id se disponível), senão local
|
||||
let rascunho = null;
|
||||
if (selectedId) {
|
||||
try {
|
||||
rascunho = await window.__TAURI__.core.invoke('sb_buscar_por_id', { id: selectedId });
|
||||
console.log('[DEBUG] sb_buscar_por_id retornou:', !!rascunho);
|
||||
} catch(e) { console.warn('sb_buscar_por_id falhou:', e); }
|
||||
}
|
||||
if (!rascunho) {
|
||||
try {
|
||||
rascunho = await window.__TAURI__.core.invoke('sb_carregar_rascunho', { loja, data: selectedDate });
|
||||
console.log('[DEBUG] sb_carregar_rascunho retornou:', !!rascunho);
|
||||
} catch(e) { console.warn('sb_carregar_rascunho falhou:', e); }
|
||||
}
|
||||
|
||||
if (!rascunho) {
|
||||
try {
|
||||
rascunho = await window.__TAURI__.core.invoke('carregar_rascunho', { loja, data: selectedDate });
|
||||
console.log('[DEBUG] carregar_rascunho local retornou:', !!rascunho);
|
||||
} catch(e) { console.warn('carregar_rascunho local falhou:', e); }
|
||||
if (hasTauri) {
|
||||
if (selectedId) {
|
||||
try {
|
||||
rascunho = await window.__TAURI__.core.invoke('sb_buscar_por_id', { id: selectedId });
|
||||
console.log('[DEBUG] sb_buscar_por_id retornou:', !!rascunho);
|
||||
} catch(e) { console.warn('sb_buscar_por_id falhou:', e); }
|
||||
}
|
||||
if (!rascunho) {
|
||||
try {
|
||||
rascunho = await window.__TAURI__.core.invoke('sb_carregar_rascunho', { loja, data: selectedDate });
|
||||
console.log('[DEBUG] sb_carregar_rascunho retornou:', !!rascunho);
|
||||
} catch(e) { console.warn('sb_carregar_rascunho falhou:', e); }
|
||||
}
|
||||
if (!rascunho) {
|
||||
try {
|
||||
rascunho = await window.__TAURI__.core.invoke('carregar_rascunho', { loja, data: selectedDate });
|
||||
console.log('[DEBUG] carregar_rascunho local retornou:', !!rascunho);
|
||||
} catch(e) { console.warn('carregar_rascunho local falhou:', e); }
|
||||
}
|
||||
} else {
|
||||
console.warn('Tauri não disponível, não foi possível carregar rascunho');
|
||||
}
|
||||
|
||||
if (rascunho) {
|
||||
|
||||
Reference in New Issue
Block a user