WhatsApp
Assessoria Jurídica Sênior
RS Advogados e Associados
window.addEventListener("storage", (e) => { if (e.key === "rs_consultas_vendidas" && currentSession && currentSession.type === "admin" && activeAdminTab === "consultas") { renderCurrentAdminTab(); showToast("Consultas vendidas atualizadas em tempo real!"); } if (e.key === "rs_clients" && currentSession && currentSession.type === "admin" && (activeAdminTab === "clientes" || activeAdminTab === "dashboard")) { renderCurrentAdminTab(); } }); ======= // ========================================== window.addEventListener("storage", (e) => { if (e.key === "rs_consultas_vendidas" && currentSession && currentSession.type === "admin" && activeAdminTab === "consultas") { renderCurrentAdminTab(); showToast("Consultas vendidas atualizadas em tempo real!"); } if (e.key === "rs_clients" && currentSession && currentSession.type === "admin" && (activeAdminTab === "clientes" || activeAdminTab === "dashboard")) { renderCurrentAdminTab(); } }); // ========================================== // 10. INITIALIZATION // ========================================== document.addEventListener("DOMContentLoaded", () => { renderLoginView(); }); ======= // 9. REAL-TIME STORAGE EVENT LISTENER // ========================================== window.addEventListener("storage", (e) => { if ((e.key === "rs_consultas_vendidas" || !e.key) && currentSession && currentSession.type === "admin" && activeAdminTab === "consultas") { renderCurrentAdminTab(); showToast("Consultas vendidas atualizadas em tempo real!"); } if (e.key === "rs_clients" && currentSession && currentSession.type === "admin" && (activeAdminTab === "clientes" || activeAdminTab === "dashboard")) { renderCurrentAdminTab(); } }); // Suporte para alteração de hash em tempo real window.addEventListener("hashchange", () => { if (currentSession && currentSession.type === "admin") { activeAdminTab = getRequestedAdminDestination(); document.querySelectorAll(".tab-btn[data-tab]").forEach(btn => { btn.classList.toggle("active", btn.getAttribute("data-tab") === activeAdminTab); }); renderCurrentAdminTab(); } }); // ========================================== // 10. INITIALIZATION // ========================================== document.addEventListener("DOMContentLoaded", () => { // Pré-define destino a partir da URL se fornecido (#dashboard ou ?dest=dashboard) activeAdminTab = getRequestedAdminDestination(); renderLoginView(); });========================================== // Sincroniza em tempo real caso uma venda seja registrada em outra aba (ex: na Consulta Online) window.addEventListener("storage", (e) => { if ((e.key === "rs_consultas_vendidas" || !e.key) && currentSession && currentSession.type === "admin" && activeAdminTab === "consultas") { renderCurrentAdminTab(); showToast("Consultas vendidas atualizadas em tempo real!"); } if (e.key === "rs_clients" && currentSession && currentSession.type === "admin" && (activeAdminTab === "clientes" || activeAdminTab === "dashboard")) { renderCurrentAdminTab(); } }); // Permite disparos internos de atualização sem recarregar a tela window.addEventListener("rs_consultas_updated", () => { if (currentSession && currentSession.type === "admin" && activeAdminTab === "consultas") { renderCurrentAdminTab(); showToast("Consultas vendidas atualizadas!"); } });========================================== // 0. BRAND SVG LOGO BUILDER (SINGLE SOURCE) // ========================================== function getBrandLogoSVG(size = 46) { =======