import React from 'react';
import { normalizeMaterialSubMenu } from './materialSubMenu';
import MaterialLockersPage from './pages/MaterialLockersPage';
import MaterialInventoryPage from './pages/MaterialInventoryPage';
import MaterialTypePage from './pages/MaterialTypePage';
import MaterialStandardPage from './pages/MaterialStandardPage';
import MaterialStandardPropertyValuesPage from './pages/MaterialStandardPropertyValuesPage';
import MaterialInformationPage from './pages/MaterialInformationPage';
import MaterialLoanPage from './pages/MaterialLoanPage';
import MaterialInspectionPlanPage from './pages/MaterialInspectionPlanPage';
import MaterialInspectionRecordPage from './pages/MaterialInspectionRecordPage';
import MaterialReplacementRecordPage from './pages/MaterialReplacementRecordPage';
import MaterialBlacklistPage from './pages/MaterialBlacklistPage';
import MaterialInstructionsPage from './pages/MaterialInstructionsPage';
import MaterialBaseDataStatisticsPage from './pages/MaterialBaseDataStatisticsPage';
import MaterialClaimReturnStatisticsPage from './pages/MaterialClaimReturnStatisticsPage';

interface MaterialManagementProps {
  subMenu: string;
  /** 后端子菜单 path，用于在 key 不可靠时按路由解析到正确子页 */
  routePath?: string | null;
}

export default function MaterialManagement({ subMenu, routePath }: MaterialManagementProps) {
  const key = normalizeMaterialSubMenu(subMenu, routePath);
  switch (key) {
    case 'materialLockers':
      return <MaterialLockersPage />;
    case 'materialInventory':
      return <MaterialInventoryPage />;
    case 'materialType': 
      return <MaterialTypePage />;
    case 'materialStandard':
      return <MaterialStandardPage />;
    case 'materialStandardPropertyValues':
      return <MaterialStandardPropertyValuesPage />;
    case 'materialInformation':
      return <MaterialInformationPage />;
    case 'materialLoan':
      return <MaterialLoanPage />;
    case 'materialInspectionPlan':
      return <MaterialInspectionPlanPage />;
    case 'materialInspectionRecord':
      return <MaterialInspectionRecordPage />;
    case 'materialReplacementRecord':
      return <MaterialReplacementRecordPage />;
    case 'materialBlacklist':
      return <MaterialBlacklistPage />;
    case 'materialInstructions':
      return <MaterialInstructionsPage />;
    case 'materialBaseDataStatistics':
      return <MaterialBaseDataStatisticsPage />;
    case 'materialClaimReturnStatistics':
      return <MaterialClaimReturnStatisticsPage />;
    default:
      return <MaterialLockersPage />;
  }
}
