import { TCrudRoute, TMenuItem } from "./types/App"; import { FaHome, FaMoneyBill, FaUser } from "react-icons/fa"; import { ImBooks } from "react-icons/im"; import React, { lazy } from "react"; // import Home from "./Pages/Home/Page"; const Dummy = React.lazy(() => import("./Pages/Home/Dummy")); const Subject = React.lazy(() => import("./Pages/subject/Table/Page")); const Tags = React.lazy(() => import("./Pages/Tags/Page")); const Unit = React.lazy(() => import("./Pages/Unit/Page")); const Lesson = React.lazy(() => import("./Pages/lesson/Page")); const Question = React.lazy(() => import('./Pages/question/Page')) const AddQuestionPage = React.lazy(() => import('./Pages/question/AddPage')) const EditQuestionPage = React.lazy(() => import('./Pages/question/EditPage')) // const QuestionChildren = React.lazy(() => import('./Pages/question/children/Page')) // const AddQuestionChildren = React.lazy(() => import('./Pages/question/children/Model/AddModel')) // const EditQuestionChildren = React.lazy(() => import('./Pages/question/children/Model/EditModel')) import { hasAbility } from "./utils/hasAbility"; import { ABILITIES_ENUM, ABILITIES_VALUES_ENUM } from "./enums/abilities"; import { ParamsEnum } from "./enums/params"; export const menuItems: TMenuItem[] = [ { header: "page_header.dashboard", element: , icon: , text: "sidebar.dashboard", path: "/", abilities: ABILITIES_ENUM?.PASS, abilities_value: ABILITIES_VALUES_ENUM.INDEX, prevPath: 0, }, { header: "page_header.subject", element: , icon: , text: "sidebar.subject", path: `/${ABILITIES_ENUM?.SUBJECT}`, abilities: ABILITIES_ENUM?.SUBJECT, abilities_value: ABILITIES_VALUES_ENUM.INDEX, prevPath: 0, }, { header: "page_header.tags", element: , icon: , text: "sidebar.tags", path: `/${ABILITIES_ENUM?.TAG}`, abilities: ABILITIES_ENUM?.TAG, abilities_value: ABILITIES_VALUES_ENUM.INDEX, prevPath: 0, }, ]; export const CrudRoute: TCrudRoute[] = [ { header: "page_header.subject_details", element: , path: `/${ABILITIES_ENUM?.SUBJECT}/:${ParamsEnum?.SUBJECT_ID}`, abilities: ABILITIES_ENUM?.UNIT, abilities_value: ABILITIES_VALUES_ENUM.INDEX, prevPath: 1, }, { header: "page_header.unit_details", element: , path: `/${ABILITIES_ENUM?.SUBJECT}/:${ParamsEnum?.SUBJECT_ID}/${ABILITIES_ENUM?.UNIT}/:${ParamsEnum?.UNIT_ID}`, abilities: ABILITIES_ENUM?.LESSON, abilities_value: ABILITIES_VALUES_ENUM.INDEX, prevPath: 2, }, { header: "page_header.lesson_details", element: , path: `/${ABILITIES_ENUM?.SUBJECT}/:${ParamsEnum?.SUBJECT_ID}/${ABILITIES_ENUM?.UNIT}/:${ParamsEnum?.UNIT_ID}/${ABILITIES_ENUM?.LESSON}/:${ParamsEnum?.LESSON_ID}`, abilities: ABILITIES_ENUM?.QUESTION, abilities_value: ABILITIES_VALUES_ENUM.INDEX, prevPath: 2, }, { header: "page_header.add_Question", element: , path: `/${ABILITIES_ENUM?.SUBJECT}/:${ParamsEnum?.SUBJECT_ID}/${ABILITIES_ENUM?.UNIT}/:${ParamsEnum?.UNIT_ID}/${ABILITIES_ENUM?.LESSON}/:${ParamsEnum?.LESSON_ID}/${ABILITIES_ENUM?.QUESTION}/add`, abilities: ABILITIES_ENUM?.QUESTION, abilities_value: ABILITIES_VALUES_ENUM.INDEX, prevPath: 2, }, { header: "page_header.edit_Question", element: , path: `/${ABILITIES_ENUM?.SUBJECT}/:${ParamsEnum?.SUBJECT_ID}/${ABILITIES_ENUM?.UNIT}/:${ParamsEnum?.UNIT_ID}/${ABILITIES_ENUM?.LESSON}/:${ParamsEnum?.LESSON_ID}/${ABILITIES_ENUM?.QUESTION}/:${ParamsEnum?.QUESTION_ID}`, abilities: ABILITIES_ENUM?.QUESTION, abilities_value: ABILITIES_VALUES_ENUM.INDEX, prevPath: 2, }, ]; export const AppRoutes: Record = Object.fromEntries( menuItems.map((route) => [ route.path, route.header ? route.header : route.text, ]), ); export const CrudRoutes: any = Object.fromEntries( CrudRoute.map((route) => [route?.path, route?.header]), ); export const search_array: { label: string; value: string }[] = menuItems ?.filter((item: TMenuItem) => { return hasAbility(item.abilities, item.abilities_value); }) .map((item: TMenuItem) => ({ label: item.header as string, value: item.path as string, })); const AllRoute = [...menuItems, ...CrudRoute]; export const PrevRoutes: any = AllRoute.map((route) => ({ path: route.path, prevPath: route.prevPath, }));