import { Grid } from "../../../../components/grid/Grid";
import { SPACING } from "../../../../data/spacing";
import { NavLink } from "../../../../components/nav-link/NavLink";
import { useLocation } from "react-router-dom";
import {
  // ROUTE_ADMINX_ROUTE_GUILDS,
  ROUTE_ADMINX_ROUTE_IN_PROVINCE_GUILDS_REQUESTS,
  ROUTE_ADMINX_ROUTE_IN_PROVINCE_GUILDS,
  ROUTE_ADMINX_ROUTE_MANAGE_GUILDS,
  ROUTE_ADMINX_ROUTE_OUT_PROVINCE_GUILDS,
  ROUTE_PROVINCE_ROUTE_IN_PROVINCE_GUILDS_REQUESTS,
  ROUTE_PROVINCE_ROUTE_IN_PROVINCE_GUILDS,
  ROUTE_PROVINCE_ROUTE_MANAGE_GUILDS,
  ROUTE_PROVINCE_ROUTE_OUT_PROVINCE_GUILDS,
  // ROUTE_SUPER_ADMIN_ROUTE_GUILDS,
  ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_GUILDS_REQUESTS,
  ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_GUILDS,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_GUILDS,
  ROUTE_SUPER_ADMIN_ROUTE_OUT_PROVINCE_GUILDS,
  ROUTE_SUPER_ADMIN_ROUTE_OUT_PROVINCE_TRUE_GUILDS,
  ROUTE_ADMINX_ROUTE_OUT_PROVINCE_TRUE_GUILDS,
  ROUTE_PROVINCE_ROUTE_OUT_PROVINCE_TRUE_GUILDS,
  ROUTE_SUPER_ADMIN_ROUTE_OUT_PROVINCE_LEGAL_GUILDS,
  ROUTE_ADMINX_ROUTE_OUT_PROVINCE_LEGAL_GUILDS,
  ROUTE_PROVINCE_ROUTE_OUT_PROVINCE_LEGAL_GUILDS,
  ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_TRUE_GUILDS,
  ROUTE_ADMINX_ROUTE_IN_PROVINCE_TRUE_GUILDS,
  ROUTE_PROVINCE_ROUTE_IN_PROVINCE_TRUE_GUILDS,
  ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_LEGAL_GUILDS,
  ROUTE_ADMINX_ROUTE_IN_PROVINCE_LEGAL_GUILDS,
  ROUTE_PROVINCE_ROUTE_IN_PROVINCE_LEGAL_GUILDS,
} from "../../../../routes/routes";
import LinkItem from "../../../../components/link-item/LinkItem";
import { MdCorporateFare } from "react-icons/md";
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
import { BackButton } from "../../../../components/back-button/BackButton";

export const GuildsOperations = () => {
  const { pathname } = useLocation();

  return (
    <>
      {[
        ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_GUILDS,
        ROUTE_ADMINX_ROUTE_IN_PROVINCE_GUILDS,
        ROUTE_PROVINCE_ROUTE_IN_PROVINCE_GUILDS,
        ROUTE_SUPER_ADMIN_ROUTE_OUT_PROVINCE_GUILDS,
        ROUTE_ADMINX_ROUTE_OUT_PROVINCE_GUILDS,
        ROUTE_PROVINCE_ROUTE_OUT_PROVINCE_GUILDS,
      ].includes(pathname) && <BackButton />}

      <Grid
        container
        gap={SPACING.SMALL}
        p={SPACING.SMALL}
        direction={"row"}
        justifyContent="center"
        xs={12}
      >
        {[
          ROUTE_SUPER_ADMIN_ROUTE_MANAGE_GUILDS,
          ROUTE_ADMINX_ROUTE_MANAGE_GUILDS,
          ROUTE_PROVINCE_ROUTE_MANAGE_GUILDS,
        ].includes(pathname) && (
          <>
            <NavLink
              to={
                getRoleFromUrl() === "SuperAdmin"
                  ? ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_GUILDS
                  : getRoleFromUrl() === "AdminX"
                  ? ROUTE_ADMINX_ROUTE_IN_PROVINCE_GUILDS
                  : ROUTE_PROVINCE_ROUTE_IN_PROVINCE_GUILDS
              }
            >
              <LinkItem
                icon={<MdCorporateFare size={30} color="#244CCC" />}
                title="اصناف داخل استان"
              />
            </NavLink>
            <NavLink
              to={
                getRoleFromUrl() === "SuperAdmin"
                  ? ROUTE_SUPER_ADMIN_ROUTE_OUT_PROVINCE_GUILDS
                  : getRoleFromUrl() === "AdminX"
                  ? ROUTE_ADMINX_ROUTE_OUT_PROVINCE_GUILDS
                  : ROUTE_PROVINCE_ROUTE_OUT_PROVINCE_GUILDS
              }
            >
              <LinkItem
                icon={<MdCorporateFare size={30} color="#244CCC" />}
                title="اصناف خارج استان"
              />
            </NavLink>
          </>
        )}
        {[
          ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_GUILDS,
          ROUTE_ADMINX_ROUTE_IN_PROVINCE_GUILDS,
          ROUTE_PROVINCE_ROUTE_IN_PROVINCE_GUILDS,
        ].includes(pathname) && (
          <>
            <NavLink
              to={
                getRoleFromUrl() === "SuperAdmin"
                  ? ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_GUILDS_REQUESTS
                  : getRoleFromUrl() === "AdminX"
                  ? ROUTE_ADMINX_ROUTE_IN_PROVINCE_GUILDS_REQUESTS
                  : ROUTE_PROVINCE_ROUTE_IN_PROVINCE_GUILDS_REQUESTS
              }
            >
              <LinkItem
                icon={<MdCorporateFare size={30} color="#244CCC" />}
                title="درخواست های ثبت صنف"
              />
            </NavLink>
            {/* <NavLink
            to={
              getRoleFromUrl() === "SuperAdmin"
                ? ROUTE_SUPER_ADMIN_ROUTE_GUILDS
                : getRoleFromUrl() === "AdminX"
                ? ROUTE_ADMINX_ROUTE_GUILDS
                : ROUTE_PROVINCE_ROUTE_GUILDS
            }
            active={pathname === ROUTE_PROVINCE_ROUTE_GUILDS ? "true" : null}
          >
            <LinkItem
              icon={<MdCorporateFare size={30} color="#244CCC" />}
              title="اصناف"
            />
          </NavLink> */}
            <NavLink
              to={
                getRoleFromUrl() === "SuperAdmin"
                  ? ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_TRUE_GUILDS
                  : getRoleFromUrl() === "AdminX"
                  ? ROUTE_ADMINX_ROUTE_IN_PROVINCE_TRUE_GUILDS
                  : ROUTE_PROVINCE_ROUTE_IN_PROVINCE_TRUE_GUILDS
              }
            >
              <LinkItem
                icon={<MdCorporateFare size={30} color="#244CCC" />}
                title="اصناف حقیقی"
              />
            </NavLink>
            <NavLink
              to={
                getRoleFromUrl() === "SuperAdmin"
                  ? ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_LEGAL_GUILDS
                  : getRoleFromUrl() === "AdminX"
                  ? ROUTE_ADMINX_ROUTE_IN_PROVINCE_LEGAL_GUILDS
                  : ROUTE_PROVINCE_ROUTE_IN_PROVINCE_LEGAL_GUILDS
              }
            >
              <LinkItem
                icon={<MdCorporateFare size={30} color="#244CCC" />}
                title="اصناف حقوقی"
              />
            </NavLink>
            {/* <NavLink
              to={
                getRoleFromUrl() === "SuperAdmin"
                  ? ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_STEWARDS
                  : getRoleFromUrl() === "AdminX"
                  ? ROUTE_ADMINX_ROUTE_IN_PROVINCE_STEWARDS
                  : ROUTE_PROVINCE_ROUTE_IN_PROVINCE_STEWARDS
              }
              active={pathname === ROUTE_PROVINCE_ROUTE_GUILDS ? "true" : null}
            >
              <LinkItem
                icon={<IoIosPeople size={30} color="#244CCC" />}
                title="مباشرین"
              />
            </NavLink>
            {(getRoleFromUrl() === "AdminX" ||
              getRoleFromUrl() === "SuperAdmin") && (
              <NavLink
                to={
                  getRoleFromUrl() === "SuperAdmin"
                    ? ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_GUILDS_DISTRIBUTIONS
                    : ROUTE_ADMINX_ROUTE_IN_PROVINCE_GUILDS_DISTRIBUTIONS
                }
                active={
                  pathname ===
                  ROUTE_SUPER_ADMIN_ROUTE_IN_PROVINCE_GUILDS_DISTRIBUTIONS
                    ? "true"
                    : null
                }
              >
                <LinkItem
                  icon={<VscLiveShare size={30} color="#244CCC" />}
                  title="مدیریت مباشرین"
                />
              </NavLink>
            )} */}
          </>
        )}

        {[
          ROUTE_SUPER_ADMIN_ROUTE_OUT_PROVINCE_GUILDS,
          ROUTE_ADMINX_ROUTE_OUT_PROVINCE_GUILDS,
          ROUTE_PROVINCE_ROUTE_OUT_PROVINCE_GUILDS,
        ].includes(pathname) && (
          <>
            <NavLink
              to={
                getRoleFromUrl() === "SuperAdmin"
                  ? ROUTE_SUPER_ADMIN_ROUTE_OUT_PROVINCE_TRUE_GUILDS
                  : getRoleFromUrl() === "AdminX"
                  ? ROUTE_ADMINX_ROUTE_OUT_PROVINCE_TRUE_GUILDS
                  : ROUTE_PROVINCE_ROUTE_OUT_PROVINCE_TRUE_GUILDS
              }
            >
              <LinkItem
                icon={<MdCorporateFare size={30} color="#244CCC" />}
                title="اصناف حقیقی"
              />
            </NavLink>
            <NavLink
              to={
                getRoleFromUrl() === "SuperAdmin"
                  ? ROUTE_SUPER_ADMIN_ROUTE_OUT_PROVINCE_LEGAL_GUILDS
                  : getRoleFromUrl() === "AdminX"
                  ? ROUTE_ADMINX_ROUTE_OUT_PROVINCE_LEGAL_GUILDS
                  : ROUTE_PROVINCE_ROUTE_OUT_PROVINCE_LEGAL_GUILDS
              }
            >
              <LinkItem
                icon={<MdCorporateFare size={30} color="#244CCC" />}
                title="اصناف حقوقی"
              />
            </NavLink>
          </>
        )}
      </Grid>
    </>
  );
};
