Files
smeta-web/static/admin2/app.js
T

35 lines
1.7 KiB
JavaScript

import { h, render } from '/static/admin2/vendor/preact.module.js';
import htm from '/static/admin2/vendor/htm.module.js';
import { SECTIONS, sectionFromPath, hrefFor } from '/static/admin2/router.js';
const html = htm.bind(h);
const TITLES = {
today: ["Мой день", "Что требует внимания сегодня"],
customers: ["Клиенты", "Кто платит, кто ушёл и кого надо вернуть"],
money: ["Деньги", "Поступления, поток и обязательства"],
work: ["Работа", "Очередь, прогоны и сбои"],
system: ["Система", "Здоровье службы и настройки"],
};
const section = sectionFromPath(location.pathname);
const [title, subtitle] = TITLES[section]
|| [SECTIONS.find(([key]) => key === section)?.[1] || 'Раздел', ''];
const App = () => html`
<div class="shell">
<nav class="side" aria-label="Разделы">
<a class="brand" href=${hrefFor('today')}>smeta<span>·</span>кокпит</a>
${SECTIONS.map(([key, label, href]) => html`
<a key=${key} href=${href} class=${'nav-link' + (key === section ? ' active' : '')}
aria-current=${key === section ? 'page' : null}>${label}</a>`)}
</nav>
<main class="main">
<header class="top"><div><h1>${title}</h1><p>${subtitle}</p></div></header>
<section class="card" aria-labelledby="placeholder">
<h2 id="placeholder">Раздел готовится</h2>
<p>Оболочка v2. Данные и действия подключит следующий этап.</p>
</section>
</main>
</div>`;
render(html`<${App} />`, document.getElementById('app'));