// App.jsx — main router const { useState: useStateApp, useEffect: useEffectApp } = React; const PAGES = { "dashboard": () => , "live-planejamento": () => , "live-apresentar": () => , "live-pedidos": () => , "live-bag": () => , "live-sortear": () => , "loja-pdv": () => , "loja-crediario": () => , "loja-financeiro": () => , "site-pedidos": () => , "site-carrinhos": () => , "produtos": () => , "clientes": () => , "disparo": () => , "marketing": () => , "relatorios": () => , "config": () => , }; const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{ "density": "compact" }/*EDITMODE-END*/; const App = () => { const [route, setRoute] = useStateApp(() => { const h = window.location.hash.replace("#", ""); return PAGES[h] ? h : "dashboard"; }); const [tweaks, setTweak] = useTweaks(TWEAK_DEFAULTS); const [dataVersion, setDataVersion] = useStateApp(0); // Carrega dados reais do banco (API PHP). Em falha, mantém os dados locais. useEffectApp(() => { if (window.API && window.API.bootstrap) { window.API.bootstrap() .then(() => setDataVersion((v) => v + 1)) .catch((e) => console.warn("API indisponível — usando dados locais.", e)); } }, []); useEffectApp(() => { window.location.hash = "#" + route; document.documentElement.setAttribute("data-density", tweaks.density); // Scroll content area to top on route change const sc = document.querySelector(".content-scroll"); if (sc) sc.scrollTop = 0; }, [route, tweaks.density]); useEffectApp(() => { const onHash = () => { const h = window.location.hash.replace("#", ""); if (PAGES[h] && h !== route) setRoute(h); }; window.addEventListener("hashchange", onHash); return () => window.removeEventListener("hashchange", onHash); }, [route]); const Page = PAGES[route] || PAGES["dashboard"]; return (
setTweak("density", v)} />
Atalhos para ver os módulos:
{Object.entries({ "dashboard": "Dashboard", "live-planejamento": "Live · Planejamento", "live-apresentar": "Live · Apresentar", "live-pedidos": "Live · Pedidos", "loja-pdv": "PDV", "loja-crediario": "Crediário", "loja-financeiro": "DRE", "site-pedidos": "E-com", "site-carrinhos": "Carrinhos", "produtos": "Produtos", "clientes": "CRM", "disparo": "Disparo em massa", "marketing": "Marketing", "relatorios": "Relatórios", "config": "Config", }).map(([k, label]) => ( ))}
); }; ReactDOM.createRoot(document.getElementById("app")).render();