feat(menu): refactor menu handling to use labels directly and remove unused functions
This commit is contained in:
@@ -1,17 +1,5 @@
|
||||
import { Menu } from './tenant.interface';
|
||||
|
||||
const MENU_LABELS: Record<string, string> = {
|
||||
account: 'Mi cuenta',
|
||||
profile: 'Datos personales',
|
||||
purchases: 'Mis compras',
|
||||
tickets: 'Mis tickets',
|
||||
'help.faq': 'Preguntas frecuentes',
|
||||
'help.contact': 'Contacto',
|
||||
'help.payment-methods': 'Medios de pago',
|
||||
'help.shipping': 'Envíos',
|
||||
'help.terms-and-conditions': 'Términos y condiciones',
|
||||
};
|
||||
|
||||
export function findMenu(menues: readonly Menu[], menuCode: string): Menu | undefined {
|
||||
for (const menu of menues) {
|
||||
if (menu.code === menuCode) {
|
||||
@@ -27,19 +15,3 @@ export function findMenu(menues: readonly Menu[], menuCode: string): Menu | unde
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getMenuLabel(menu: Menu): string {
|
||||
const configuredLabel = MENU_LABELS[menu.code];
|
||||
|
||||
if (configuredLabel) {
|
||||
return configuredLabel;
|
||||
}
|
||||
|
||||
const label = menu.code.split('.').at(-1)?.replaceAll('-', ' ') ?? menu.code;
|
||||
|
||||
return label.charAt(0).toUpperCase() + label.slice(1);
|
||||
}
|
||||
|
||||
export function getAccountNavigationLabel(menu: Menu): string {
|
||||
return menu.code === 'profile' ? 'Mi cuenta' : getMenuLabel(menu);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ export interface EventConfig {
|
||||
export interface Menu {
|
||||
id: number;
|
||||
code: string;
|
||||
label: string;
|
||||
parent_menu_code: string | null;
|
||||
content_type: 'static' | 'dynamic';
|
||||
route: string;
|
||||
@@ -63,4 +64,3 @@ export interface Tenant {
|
||||
}
|
||||
|
||||
export type TenantBootstrapResponse = ApiResponse<Tenant>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user