Files

22 lines
751 B
JavaScript

export const BASE = "/admin/v2";
export const SECTIONS = [
["today", "Мой день", BASE],
["customers", "Клиенты", `${BASE}/customers`],
["money", "Деньги", `${BASE}/money`],
["work", "Работа", `${BASE}/work`],
["system", "Система", `${BASE}/system`],
["stove-api", "API печей", `${BASE}/stove-api`],
];
export function sectionFromPath(pathname) {
const clean = (pathname || "").replace(/\/+$/, "");
if (clean === BASE || clean === `${BASE}/today`) return "today";
const found = SECTIONS.find(([, , href]) => clean === href);
return found ? found[0] : "today";
}
export function hrefFor(section) {
const found = SECTIONS.find(([key]) => key === section);
return found ? found[2] : BASE;
}