All files / src/app/layout navConfig.ts

0% Statements 0/117
0% Branches 0/1
0% Functions 0/1
0% Lines 0/117

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118                                                                                                                                                                                                                                           
/**
 * @file navConfig.ts
 * @module app/layout/navConfig
 *
 * @summary
 * Navigation configuration metadata for the application sidebar.
 * Defines routes, labels, icons, and contextual properties for all navigation items.
 *
 * @enterprise
 * - Centralized single source of truth for navigation structure
 * - Supports optional disabled state and tooltips for feature flags
 * - Enables dynamic nav generation and help topic routing
 * - Type-safe with strict enum patterns for route consistency
 */

import DashboardIcon from '@mui/icons-material/Dashboard';
import InventoryIcon from '@mui/icons-material/Inventory2';
import LocalShippingIcon from '@mui/icons-material/LocalShipping';
import InsightsIcon from '@mui/icons-material/Insights';

/**
 * Supported navigation routes in the application.
 * Each route maps to an authenticated page within AppShell.
 */
export const AppRoutes = {
  Dashboard: '/dashboard',
  Inventory: '/inventory',
  Suppliers: '/suppliers',
  Analytics: '/analytics/overview',
} as const;

export type AppRoutesType = (typeof AppRoutes)[keyof typeof AppRoutes];

/**
 * Help topic IDs for context-sensitive help system.
 * Maps routes to their corresponding help documentation topics.
 */
export const HelpTopics = {
  Main: 'app.main',
  Dashboard: 'app.main',
  Inventory: 'inventory.overview',
  Suppliers: 'suppliers.manage',
  Analytics: 'analytics.overview',
} as const;

export type HelpTopicsType = (typeof HelpTopics)[keyof typeof HelpTopics];

/**
 * Navigation item configuration.
 *
 * @property route - Target route path
 * @property label - i18n key for navigation label
 * @property icon - MUI Icon component
 * @property disabled - Optional feature flag to disable navigation
 * @property tooltip - Optional tooltip message when disabled
 * @property helpTopic - Help documentation topic ID for this route
 */
export interface NavItemConfig {
  route: AppRoutesType;
  label: string;
  icon: React.ComponentType<{ className?: string }>;
  disabled?: boolean;
  tooltip?: string;
  helpTopic: HelpTopicsType;
}

/**
 * Navigation items array defining the left sidebar menu structure.
 *
 * Order matters: items appear top-to-bottom in the sidebar.
 * Disabled items remain visible but non-interactive with tooltip explanation.
 *
 * @const
 */
export const NAV_ITEMS: NavItemConfig[] = [
  {
    route: AppRoutes.Dashboard,
    label: 'nav.dashboard',
    icon: DashboardIcon,
    helpTopic: HelpTopics.Dashboard,
  },
  {
    route: AppRoutes.Inventory,
    label: 'nav.inventory',
    icon: InventoryIcon,
    helpTopic: HelpTopics.Inventory,
  },
  {
    route: AppRoutes.Suppliers,
    label: 'nav.suppliers',
    icon: LocalShippingIcon,
    helpTopic: HelpTopics.Suppliers,
  },
  {
    route: AppRoutes.Analytics,
    label: 'nav.analytics',
    icon: InsightsIcon,
    helpTopic: HelpTopics.Analytics,
  },
];

/**
 * Get help topic ID based on current route pathname.
 *
 * Matches the current location pathname against known routes
 * and returns the corresponding help topic.
 *
 * @param pathname - Current route pathname from useLocation()
 * @returns HelpTopics enum value for context-sensitive help
 */
export function getHelpTopicForRoute(pathname: string): HelpTopicsType {
  if (pathname.startsWith(AppRoutes.Inventory)) return HelpTopics.Inventory;
  if (pathname.startsWith(AppRoutes.Analytics)) return HelpTopics.Analytics;
  if (pathname.startsWith(AppRoutes.Suppliers)) return HelpTopics.Suppliers;
  if (pathname.startsWith(AppRoutes.Dashboard)) return HelpTopics.Dashboard;
  return HelpTopics.Main;
}