21 lines
695 B
JavaScript
21 lines
695 B
JavaScript
export const BASE = "/admin/v2";
|
|
export const SECTIONS = [
|
|
["today", "Мой день", BASE],
|
|
["customers", "Клиенты", `${BASE}/customers`],
|
|
["money", "Деньги", `${BASE}/money`],
|
|
["work", "Работа", `${BASE}/work`],
|
|
["system", "Система", `${BASE}/system`],
|
|
];
|
|
|
|
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;
|
|
}
|