// App shell: sidebar nav + user menu pop
const { useState: useStateS } = React;
// ME is set dynamically from /api/v1/account on app load.
let ME = { name: "", email: "" };
function AppShell({ ctx }) {
const { t, route, setRoute } = ctx;
const [userMenuOpen, setUserMenuOpen] = useStateS(false);
const navItems = [
{ k: "networks", l: t.nav.networks, icon: "⌥" },
{ k: "support", l: t.nav.support, icon: "?" },
];
return (
{open && (
<>
setOpen(false)} style={{ position: "fixed", inset: 0, zIndex: 30 }}/>
{ME.is_admin && }
>
)}
);
}
function TopRightControls({ ctx }) {
const { lang, setLang, theme, toggleTheme } = ctx;
return (
{["en", "zh"].map(l => (
))}
);
}
function MenuItem({ children, onClick }) {
return (
);
}
function AppRouter({ ctx }) {
const { route } = ctx;
switch (route) {
case "networks": return
;
case "network": return ;
case "support": return ;
case "settings": return ;
default: return ;
}
}
function AppTweaks({ state, setState, onReset }) {
const t = APP_I18N[state.lang];
return (
Tweaks
{t.common.language}
setState({ ...state, lang: v })}/>
{t.common.theme}
setState({ ...state, theme: v })}/>
);
}
Object.assign(window, { AppShell, AppTweaks, ME });