51 lines
2.4 KiB
TypeScript
51 lines
2.4 KiB
TypeScript
/**
|
|
* Route metadata for the `/sales/settings/*` branch.
|
|
*
|
|
* The branch layout is the deepest match that returns a `title`, so its title
|
|
* became the document title *and* the header breadcrumb for every child
|
|
* (`useTitleData` takes the last titled match). Until this map existed, opening
|
|
* "Telefonie-Einstellungen" or "Felder und Tags" announced itself as
|
|
* "Pipeline konfigurieren" — including the 404 page under
|
|
* `/sales/settings/leads` (admin audit 2026-07-26, P0-08).
|
|
*
|
|
* Keys are path prefixes below `/sales/settings`; the longest match wins, so a
|
|
* nested route can refine its parent. Labels reuse the navigation strings the
|
|
* operator clicked, which keeps title, breadcrumb and sidebar in one wording.
|
|
*/
|
|
export const ADMIN_SALES_SETTINGS_TITLE_KEYS: ReadonlyArray<readonly [path: string, i18nKey: string]> = [
|
|
["pipelines", "admin.sales.navigation.pipelineSettings"],
|
|
["leads", "admin.sales.navigation.leadSettings"],
|
|
["fields-tags", "admin.sales.navigation.fieldsTags"],
|
|
["telephony", "admin.sales.navigation.telephonySettings"],
|
|
["calendars", "admin.sales.booking.calendars.title"],
|
|
["meeting-types", "admin.sales.booking.settings.meetingTypes.title"],
|
|
["availability", "admin.sales.booking.settings.availability.title"],
|
|
["email-accounts", "admin.sales.email.accounts.title"],
|
|
["sending-domains", "admin.sales.email.domains.title"],
|
|
];
|
|
|
|
/** Fallback for a child that is not mapped yet: the branch's own section name. */
|
|
export const ADMIN_SALES_SETTINGS_FALLBACK_TITLE_KEY = "admin.sales.navigation.configurationSection";
|
|
|
|
/**
|
|
* Resolves the i18n key for a `/sales/settings/...` pathname. Matching is done
|
|
* on whole segments so `telephony-legacy` never matches `telephony`.
|
|
*/
|
|
export function resolveAdminSalesSettingsTitleKey(pathname: string): string {
|
|
const branchIndex = pathname.indexOf("/sales/settings");
|
|
const remainder = branchIndex === -1 ? "" : pathname.slice(branchIndex + "/sales/settings".length);
|
|
const segments = remainder.split("/").filter(Boolean);
|
|
|
|
let bestKey = ADMIN_SALES_SETTINGS_FALLBACK_TITLE_KEY;
|
|
let bestDepth = 0;
|
|
for (const [path, i18nKey] of ADMIN_SALES_SETTINGS_TITLE_KEYS) {
|
|
const candidate = path.split("/").filter(Boolean);
|
|
const matches = candidate.length <= segments.length && candidate.every((segment, index) => segment === segments[index]);
|
|
if (matches && candidate.length > bestDepth) {
|
|
bestKey = i18nKey;
|
|
bestDepth = candidate.length;
|
|
}
|
|
}
|
|
return bestKey;
|
|
}
|