// app.jsx — root router + Tweaks panel + accent system const TWEAK_DEFAULTS = window.TWEAK_DEFAULTS; const USER = { name: "Etiandro Ucha", phone: "+245 96 660 14 29", balance: 4520, data: "12.4", voice: 86, sms: 142, points: 3850, tierProgress: 3850, tierTarget: 5000, }; const ACCENT_PRESETS = { telecel: { accent: "#F20318", accent700: "#C40212", accentSoft: "#FEE5E7", grad: "linear-gradient(135deg, #F20318 0%, #8B020E 100%)", }, premium: { accent: "#B5051B", accent700: "#7E0212", accentSoft: "#FBE5E8", grad: "linear-gradient(135deg, #C90213 0%, #420108 100%)", }, duotone: { accent: "#F20318", accent700: "#1A1A1B", accentSoft: "#FEE5E7", grad: "linear-gradient(135deg, #F20318 0%, #1A1A1B 100%)", }, }; const FLOW_NAV_TARGETS = new Set(["home", "bundles", "recharge", "services", "account"]); const SCREEN_LIST = [ "splash", "login", "otp", "home", "bundles", "bundle-detail", "recommended", "bundle-compare", "recharge", "recharge-other", "saved-numbers", "payment", "success", "payment-methods", "loyalty", "notifications", "transactions", "promotions", "services", "electricity", "account", "support", ]; const SCREEN_LABELS = { splash: "Splash", login: "Deteção do número", otp: "OTP", home: "Home", bundles: "Pacotes", "bundle-detail": "Pacote · detalhe", recommended: "Recomendado", "bundle-compare": "Comparar", recharge: "Recarga", "recharge-other": "Recarga p/ outro", "saved-numbers": "Números guardados", payment: "Pagamento", success: "Sucesso", "payment-methods": "Meios de pagamento", loyalty: "Recompensas", notifications: "Notificações", transactions: "Transações", promotions: "Promoções", services: "Serviços", electricity: "Eletricidade", account: "Conta", support: "Apoio", }; function App() { const [t, setTweak] = useTweaks(TWEAK_DEFAULTS); const [screen, setScreen] = useState("splash"); const [args, setArgs] = useState(null); const [history, setHistory] = useState([]); const [direction, setDirection] = useState("forward"); const [navOpen, setNavOpen] = useState(false); const isDesktop = useIsDesktop(1024); const go = (target, payload) => { if (target === screen) return; setHistory(h => [...h, screen]); setArgs(payload || null); setDirection("forward"); setScreen(target); }; const back = () => { setHistory(h => { const prev = h[h.length - 1]; if (prev) { setScreen(prev); setDirection("back"); return h.slice(0, -1); } return h; }); }; // Apply accent + dark mode const accent = ACCENT_PRESETS[t.accent] || ACCENT_PRESETS.telecel; useEffect(() => { document.documentElement.style.setProperty("--accent", accent.accent); document.documentElement.style.setProperty("--accent-700", accent.accent700); document.documentElement.style.setProperty("--accent-soft", accent.accentSoft); document.documentElement.style.setProperty("--accent-grad", accent.grad); }, [t.accent]); useEffect(() => { document.documentElement.setAttribute("data-theme", t.dark ? "dark" : "light"); }, [t.dark]); // Determine bottom nav visibility (mobile-only) const NAV_VISIBLE = new Set(["home", "bundles", "services", "account"]); const showBottomNav = !isDesktop && NAV_VISIBLE.has(screen); // Map screen -> current nav id (for active state) const navCurrent = (() => { if (screen === "home" || screen === "promotions") return "home"; if (screen === "recommended") return "recommended"; if (screen === "bundles" || screen === "bundle-detail" || screen === "bundle-compare") return "bundles"; if (screen === "recharge" || screen === "recharge-other" || screen === "saved-numbers") return "recharge"; if (screen === "services") return "services"; if (screen === "electricity") return "electricity"; if (screen === "loyalty") return "loyalty"; if (screen === "transactions") return "transactions"; if (screen === "payment-methods") return "payment-methods"; if (screen === "notifications") return "notifications"; if (screen === "support") return "support"; if (screen === "account") return "account"; return "home"; })(); // Auth screens get a special two-pane desktop layout const AUTH_SCREENS = new Set(["login", "otp"]); const isAuth = AUTH_SCREENS.has(screen); const resetFirstVisit = () => { localStorage.removeItem(FIRST_VISIT_KEY); setHistory([]); setArgs(null); setScreen("splash"); }; if (screen === "splash") { return (
); } const screenLabel = SCREEN_LABELS[screen] || screen; const screenLabelAttr = `${SCREEN_LIST.indexOf(screen) + 1 < 10 ? "0" : ""}${SCREEN_LIST.indexOf(screen) + 1} ${screenLabel}`; /* ── Desktop auth layout ─────────────────────────── */ if (isDesktop && isAuth) { return (
Telecel — Conectando Energias

A tua rede.
O teu mundo.

Pacotes de internet, recargas e TeleTaku — tudo num só lugar, num só toque.

{renderScreen(screen, { go, back, args, user: USER, tweaks: t, setTweak })}
{ setHistory([]); setArgs(null); setScreen(s); }} open={navOpen} onToggle={() => setNavOpen(!navOpen)} />
); } /* ── Default layout (mobile column or desktop app-shell) ─────────────────────────── */ return (
{isDesktop ? ( { setHistory(h => [...h, screen]); setArgs(null); setScreen(id); }} /> ) : null}
{renderScreen(screen, { go, back, args, user: USER, tweaks: t, setTweak, isDesktop })}
{showBottomNav ? ( { if (id === "recharge") return go("recharge"); go(id); }} /> ) : null}
{/* Screen jumper (desktop helper) */} { setHistory([]); setArgs(null); setScreen(s); }} open={navOpen} onToggle={() => setNavOpen(!navOpen)} />
); } function TweaksPanelInline({ t, setTweak, onReset }) { return ( setTweak("accent", v)} /> setTweak("dark", v)} /> setTweak("bundleLayout", v)} /> setTweak("homeHero", v)} /> setTweak("navStyle", v)} /> ); } /* ─────────────────────────── ScreenJumper ─────────────────────────── */ function ScreenJumper({ screen, go, open, onToggle }) { const groups = [ { label: "Primeira visita", screens: ["splash", "login", "otp"] }, { label: "Home & Bundles", screens: ["home", "bundles", "bundle-detail", "bundle-compare", "recommended", "promotions"] }, { label: "Recarga & Pagamento", screens: ["recharge", "recharge-other", "saved-numbers", "payment", "success", "payment-methods"] }, { label: "Conta", screens: ["services", "electricity", "account", "loyalty", "notifications", "transactions", "support"] }, ]; return ( <> {open ? (
{groups.map(g => (
{g.label}
{g.screens.map(s => ( ))}
))}
) : null} ); } function renderScreen(name, props) { switch (name) { case "splash": return ; case "login": return ; case "otp": return ; case "home": return ; case "bundles": return ; case "bundle-detail": return ; case "recommended": return ; case "bundle-compare": return ; case "recharge": return ; case "recharge-other": return ; case "saved-numbers": return ; case "payment": return ; case "success": return ; case "payment-methods": return ; case "loyalty": return ; case "notifications": return ; case "transactions": return ; case "promotions": return ; case "services": return ; case "electricity": return ; case "account": return ; case "support": return ; default: return
{name}
; } } ReactDOM.createRoot(document.getElementById("root")).render();