import { TickSquare } from "iconsax-react";
import { FC } from "react";
import { useTranslation } from "react-i18next";
import { useLocation } from "react-router-dom";
import { Pages } from "../../config/Pages";
import { TASK_MANAGER_PERMISSION_RESOURCES } from "../../helpers/permissions";
import SubMenuItem from "./SubMenuItem";

const TaskManagerSubMenu: FC = () => {
  const location = useLocation();
  const { t } = useTranslation("global");

  const isTaskManagerActive =
    location.pathname.startsWith(Pages.taskmanager.workspace) ||
    location.pathname === Pages.taskmanager.workspaceList ||
    location.pathname.startsWith(Pages.taskmanager.updateWorkspace) ||
    location.pathname === Pages.taskmanager.createWorkspace ||
    location.pathname === Pages.taskmanager.createProject ||
    location.pathname.startsWith(Pages.taskmanager.updateProject) ||
    location.pathname.startsWith(Pages.taskmanager.projectList);

  return (
    <div className="py-12">
      <div className="flex gap-3 items-center border-b pb-10 px-6">
        <TickSquare
          size={24}
          color="#000"
          variant="Bold"
        />
        <div className="text-xs">{t("sidebar.taskmanager")}</div>
      </div>

      <div className="flex flex-col mt-10 gap-4">
        <SubMenuItem
          title={t("submenu.taskmanager_workspace_list")}
          isActive={isTaskManagerActive}
          link={Pages.taskmanager.workspaceList}
          activeNames={TASK_MANAGER_PERMISSION_RESOURCES}
        />
      </div>
    </div>
  );
};

export default TaskManagerSubMenu;
