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: <Dummy />,
    icon: <FaHome />,
    text: "sidebar.dashboard",
    path: "/",
    abilities: ABILITIES_ENUM?.PASS,
    abilities_value: ABILITIES_VALUES_ENUM.INDEX,
  },


  {
    header: "page_header.subject",
    element: <Subject />,
    icon: <FaMoneyBill />,
    text: "sidebar.subject",
    path: `/${ABILITIES_ENUM?.SUBJECT}`,
    abilities: ABILITIES_ENUM?.SUBJECT,
    abilities_value: ABILITIES_VALUES_ENUM.INDEX,
  },
  {
    header: "page_header.tags",
    element: <Tags />,
    icon: <FaMoneyBill />,
    text: "sidebar.tags",
    path: `/${ABILITIES_ENUM?.TAG}`,
    abilities: ABILITIES_ENUM?.TAG,
    abilities_value: ABILITIES_VALUES_ENUM.INDEX,
  },


];

export const CrudRoute: TCrudRoute[] = [



  {
    header: "page_header.subject_details",
    element: <Unit />,
    path: `/${ABILITIES_ENUM?.SUBJECT}/:${ParamsEnum?.SUBJECT_ID}`,
    abilities: ABILITIES_ENUM?.UNIT,
    abilities_value: ABILITIES_VALUES_ENUM.INDEX,
  },
  {
    header: "page_header.unit_details",
    element: <Lesson />,
    path: `/${ABILITIES_ENUM?.SUBJECT}/:${ParamsEnum?.SUBJECT_ID}/${ABILITIES_ENUM?.UNIT}/:${ParamsEnum?.UNIT_ID}`,
    abilities: ABILITIES_ENUM?.LESSON,
    abilities_value: ABILITIES_VALUES_ENUM.INDEX,
  },

  {
    header: "page_header.lesson_details",
    element: <Question />,
    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,
  },
  {
    header: "page_header.add_Question",
    element: <AddQuestionPage />,
    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,
  },
  {
    header: "page_header.edit_Question",
    element: <EditQuestionPage />,
    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,
  },
  // {
  //   header: "page_header.Question_child",
  //   element: <QuestionChildren />,
  //   path: `/${ABILITIES_ENUM?.SUBJECT}/:${ParamsEnum?.SUBJECT_ID}/${ABILITIES_ENUM?.UNIT}/:${ParamsEnum?.UNIT_ID}/${ABILITIES_ENUM?.LESSON}/:${ParamsEnum?.LESSON_ID}/${ABILITIES_ENUM?.QUESTION}/:${ParamsEnum?.CHILDREN_QUESTION_ID}/children`,
  //   abilities: ABILITIES_ENUM?.QUESTION,
  //   abilities_value: ABILITIES_VALUES_ENUM.INDEX,
  // },
  // {
  //   header: "page_header.add_Question_child",
  //   element: <AddQuestionChildren />,
  //   path: `/${ABILITIES_ENUM?.SUBJECT}/:${ParamsEnum?.SUBJECT_ID}/${ABILITIES_ENUM?.UNIT}/:${ParamsEnum?.UNIT_ID}/${ABILITIES_ENUM?.LESSON}/:${ParamsEnum?.LESSON_ID}/${ABILITIES_ENUM?.QUESTION}/:${ParamsEnum?.CHILDREN_QUESTION_ID}/children/add`,
  //   abilities: ABILITIES_ENUM?.QUESTION,
  //   abilities_value: ABILITIES_VALUES_ENUM.INDEX,
  // },
  // {
  //   header: "page_header.edit_Question_child",
  //   element: <EditQuestionChildren />,
  //   path: `/${ABILITIES_ENUM?.SUBJECT}/:${ParamsEnum?.SUBJECT_ID}/${ABILITIES_ENUM?.UNIT}/:${ParamsEnum?.UNIT_ID}/${ABILITIES_ENUM?.LESSON}/:${ParamsEnum?.LESSON_ID}/${ABILITIES_ENUM?.QUESTION}/:${ParamsEnum?.CHILDREN_QUESTION_ID}/children/:${ParamsEnum?.CHILDREN_QUESTION_ID}`,
  //   abilities: ABILITIES_ENUM?.QUESTION,
  //   abilities_value: ABILITIES_VALUES_ENUM.INDEX,
  // },
];



export const AppRoutes: Record<string, string> = 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,
  }));
