import {FC} from 'react';
import {RouteObject, useRoutes} from 'react-router-dom';
import {
  HOME_PATH,
  MAIN_PATH,
  MENU_PATH,
  ROLE_PATH,
  USER_PATH,
  STORAGE_PATH,
  GOODS_PATH,
  PDA_MENU_PATH,
  CONTAINER_PATH,
  MATTER_PATH,
  RAW_IN_STREAM_PATH,
  RAW_OUT_STREAM_PATH,
  SEMI_REPORT_PATH,
  SEMI_DRAW_PATH,
  SEMI_IN_STREAM_PATH,
  SEMI_OUT_STREAM_PATH,
  LOGIN_PATH,
  NO_PERMISSION_PATH,
  FINISH_PRODUCT_IN_STREAM_PATH,
  FINISH_PRODUCT_OUT_STREAM_PATH,
  DEAD_PRODUCT_PATH,
  RESERVE_WARNING_PATH,
  QUALITY_PATH,
  PURCHASE_PATH,
  MATERIAL_BIND_PATH,
  STOCK_PATH,
  DICTIONARY_PATH,
  GS_INTERFACE_LOG_PATH,
  PRODUCTION_REQUISITION_PATH,
  SELL_ORDER_PATH,
  PRODUCT_DRAW_PATH,
  RELOCAT_ORDER_PATH,
  PRODUCT_REPORT_PATH,
  ORDER_LOG_PATH,
  INVENTORY_PATH,
  GS_ERROR_LOG_PATH,
  PUT_IN_STORAGE,
  PUT_OUT_STORAGE,
} from './name';
import {
  Container,
  Goods,
  Matter,
  Menu,
  NoPermision,
  NotFound,
  Pda,
  RawInStream,
  RawOutStream,
  Role,
  SemiDraw,
  SemiInStream,
  SemiOutStream,
  SemiReport,
  User,
  Storage,
  ProductInStream,
  ProductOutStream,
  ReserveWarning,
  Quality,
  Stock,
  Dictionary,
  GSInterfaceLog,
  ProductionRequisitionOrder,
  RelcationOrder,
  ProductDraw,
  ProductReport,
  DeadProduct,
  PurchaseOrder,
  MaterialBind,
  SellOrder,
  OrderDeleteLog,
  Inventory,
  Login,
  GSErrorLog,
  PutInStorageWithOther,
  PutOutStorageWithOther,
} from './routes';
import Main from '@pages/main';
import Home from '@pages/home';

export const routes: RouteObject[] = [
  {path: LOGIN_PATH, element: <Login />},
  {
    path: HOME_PATH,
    element: <Home />,
    children: [
      {path: MAIN_PATH, element: <Main />},
      {path: MENU_PATH, element: <Menu />},
      {path: ROLE_PATH, element: <Role />},
      {path: USER_PATH, element: <User />},
      {path: STORAGE_PATH, element: <Storage />},
      {path: GOODS_PATH, element: <Goods />},
      {path: PDA_MENU_PATH, element: <Pda />},
      {path: CONTAINER_PATH, element: <Container />},
      {path: MATTER_PATH, element: <Matter />},
      {path: QUALITY_PATH, element: <Quality />},
      {path: RAW_IN_STREAM_PATH, element: <RawInStream />},
      {path: RAW_OUT_STREAM_PATH, element: <RawOutStream />},
      {path: SEMI_REPORT_PATH, element: <SemiReport />},
      {path: SEMI_DRAW_PATH, element: <SemiDraw />},
      {path: SEMI_IN_STREAM_PATH, element: <SemiInStream />},
      {path: SEMI_OUT_STREAM_PATH, element: <SemiOutStream />},
      {path: FINISH_PRODUCT_IN_STREAM_PATH, element: <ProductInStream />},
      {path: FINISH_PRODUCT_OUT_STREAM_PATH, element: <ProductOutStream />},
      {path: DEAD_PRODUCT_PATH, element: <DeadProduct />},
      {path: RESERVE_WARNING_PATH, element: <ReserveWarning />},
      {path: PURCHASE_PATH, element: <PurchaseOrder />},
      {path: MATERIAL_BIND_PATH, element: <MaterialBind />},
      {path: STOCK_PATH, element: <Stock />},
      {path: DICTIONARY_PATH, element: <Dictionary />},
      {path: GS_INTERFACE_LOG_PATH, element: <GSInterfaceLog />},
      {path: PRODUCTION_REQUISITION_PATH, element: <ProductionRequisitionOrder />},
      {path: SELL_ORDER_PATH, element: <SellOrder />},
      {path: RELOCAT_ORDER_PATH, element: <RelcationOrder />},
      {path: PRODUCT_DRAW_PATH, element: <ProductDraw />},
      {path: PRODUCT_REPORT_PATH, element: <ProductReport />},
      {path: ORDER_LOG_PATH, element: <OrderDeleteLog />},
      {path: INVENTORY_PATH, element: <Inventory />},
      {path: GS_ERROR_LOG_PATH, element: <GSErrorLog />},
      {path: PUT_IN_STORAGE, element: <PutInStorageWithOther />},
      {path: PUT_OUT_STORAGE, element: <PutOutStorageWithOther />},
    ],
  },
  {path: NO_PERMISSION_PATH, element: <NoPermision />},
  {path: '*', element: <NotFound />},
];

export const RootRoutes: FC = function () {
  const Routes = useRoutes(routes);

  return Routes;
};

export * from './name';
