Kairo-Jinkendo/frontend/src/config/controlNav.js

26 lines
786 B
JavaScript
Raw Normal View History

/**
* Kontrolle-Subnav (Mitai: settingsNav / analysis-split).
* Pfade müssen mit Routes in App.jsx übereinstimmen.
*
* @typedef {{ key: string, to: string, label: string }} ModeNavItem
*/
/** @type {ModeNavItem[]} */
export const CONTROL_NAV_ITEMS = [
{ key: 'status', to: '/control/status', label: 'Steuerung' },
{ key: 'plan-ist', to: '/control/plan-ist', label: 'Plan / Ist' },
{ key: 'journey', to: '/control/journey', label: 'Nachvollziehbarkeit' },
]
/**
* @param {string} pathname
* @returns {string | null}
*/
export function resolveControlNavActiveKey(pathname) {
const path = pathname.replace(/\/$/, '') || pathname
const match = CONTROL_NAV_ITEMS.find(
(item) => path === item.to || path.startsWith(`${item.to}/`),
)
return match?.key ?? null
}