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_SETTINGS,
  ROUTE_ADMINX_ROUTE_MANAGE_DISTRIBUTIONS,
  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_BUY_REQ,
  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_KILLPLACE,
  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_SLAUGHTER,
  ROUTE_ADMINX_ROUTE_POLICY_COUNCIL_KILLHOUSE_GUILDS,
  ROUTE_ADMINX_ROUTE_SLAUGHTER_TRADE_PANEL,
  ROUTE_ADMINX_SLAUGHTERS_MONITORING_BUYERS,
  ROUTE_PROVINCE_ROUTE_GUILDS_SETTINGS,
  ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_BUY_REQ,
  ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_KILLPLACE,
  ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_SLAUGHTER,
  ROUTE_PROVINCE_ROUTE_POLICY_COUNCIL_KILLHOUSE_GUILDS,
  ROUTE_PROVINCE_SLAUGHTERS_MONITORING_BUYERS,
  ROUTE_SUPER_ADMIN_ROUTE_GUILDS_SETTINGS,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_DISTRIBUTIONS,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_BUY_REQ,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_KILLPLACE,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_SLAUGHTER,
  ROUTE_SUPER_ADMIN_ROUTE_POLICY_COUNCIL_KILLHOUSE_GUILDS,
  ROUTE_SUPER_ADMIN_ROUTE_SLAUGHTER_TRADE_PANEL,
  ROUTE_SUPER_ADMIN_SLAUGHTERS_MONITORING_BUYERS,
} from "../../../../routes/routes";
import LinkItem from "../../../../components/link-item/LinkItem";
import {
  VscGraphLine,
  VscLiveShare,
  VscNewFolder,
  VscOrganization,
} from "react-icons/vsc";
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
import { IoIosPeople } from "react-icons/io";

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

  return (
    <Grid
      container
      gap={SPACING.SMALL}
      p={SPACING.SMALL}
      direction={{ xs: "column", md: "row" }}
      justifyContent="center"
      // style={{ placeContent: "baseline" }}
      alignItems="center"
    >
      <NavLink
        to={
          getRoleFromUrl() === "SuperAdmin"
            ? ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_KILLPLACE
            : getRoleFromUrl() === "AdminX"
            ? ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_KILLPLACE
            : ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_KILLPLACE
        }
        active={
          pathname === ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_KILLPLACE
            ? "true"
            : null
        }
      >
        <LinkItem
          icon={<VscNewFolder size={30} color="#244CCC" />}
          title="خریداران"
        />
      </NavLink>
      {(getRoleFromUrl() === "SuperAdmin" || getRoleFromUrl() === "AdminX") && (
        <NavLink
          to={
            getRoleFromUrl() === "SuperAdmin"
              ? ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_BUY_REQ
              : getRoleFromUrl() === "AdminX"
              ? ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_BUY_REQ
              : ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_BUY_REQ
          }
          active={
            pathname === ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_BUY_REQ
              ? "true"
              : null
          }
        >
          <LinkItem
            icon={<VscNewFolder size={30} color="#244CCC" />}
            title="مجوز خرید"
          />
        </NavLink>
      )}
      <NavLink
        to={
          getRoleFromUrl() === "SuperAdmin"
            ? ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_SLAUGHTER
            : getRoleFromUrl() === "AdminX"
            ? ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_SLAUGHTER
            : ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_SLAUGHTER
        }
        active={
          pathname === ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_SLAUGHTER
            ? "true"
            : null
        }
      >
        <LinkItem
          icon={<VscNewFolder size={30} color="#244CCC" />}
          title="دسترسی خودرو"
        />
      </NavLink>

      <NavLink
        to={
          getRoleFromUrl() === "SuperAdmin"
            ? ROUTE_SUPER_ADMIN_ROUTE_GUILDS_SETTINGS
            : getRoleFromUrl() === "AdminX"
            ? ROUTE_ADMINX_ROUTE_GUILDS_SETTINGS
            : ROUTE_PROVINCE_ROUTE_GUILDS_SETTINGS
        }
        active={
          pathname === ROUTE_PROVINCE_ROUTE_GUILDS_SETTINGS ? "true" : null
        }
      >
        <LinkItem
          icon={<IoIosPeople size={30} color="#244CCC" />}
          title="مجوزهای توزیع"
        />
      </NavLink>
      <NavLink
        to={
          getRoleFromUrl() === "SuperAdmin"
            ? ROUTE_SUPER_ADMIN_ROUTE_POLICY_COUNCIL_KILLHOUSE_GUILDS
            : getRoleFromUrl() === "AdminX"
            ? ROUTE_ADMINX_ROUTE_POLICY_COUNCIL_KILLHOUSE_GUILDS
            : ROUTE_PROVINCE_ROUTE_POLICY_COUNCIL_KILLHOUSE_GUILDS
        }
        active={
          pathname === ROUTE_PROVINCE_ROUTE_POLICY_COUNCIL_KILLHOUSE_GUILDS
            ? "true"
            : null
        }
      >
        <LinkItem
          icon={<VscNewFolder size={30} color="#244CCC" />}
          title="مجوز ثبت صنف به کشتارگاه ها"
        />
      </NavLink>

      {(getRoleFromUrl() === "AdminX" || getRoleFromUrl() === "SuperAdmin") && (
        <NavLink
          to={
            getRoleFromUrl() === "SuperAdmin"
              ? ROUTE_SUPER_ADMIN_ROUTE_SLAUGHTER_TRADE_PANEL
              : ROUTE_ADMINX_ROUTE_SLAUGHTER_TRADE_PANEL
          }
          active={
            pathname === ROUTE_ADMINX_ROUTE_SLAUGHTER_TRADE_PANEL
              ? "true"
              : null
          }
        >
          <LinkItem
            icon={<VscGraphLine size={30} color="#244CCC" />}
            title="پنل معاملاتی"
          />
        </NavLink>
      )}
      {(getRoleFromUrl() === "AdminX" || getRoleFromUrl() === "SuperAdmin") && (
        <NavLink
          to={
            getRoleFromUrl() === "SuperAdmin"
              ? ROUTE_SUPER_ADMIN_ROUTE_MANAGE_DISTRIBUTIONS
              : ROUTE_ADMINX_ROUTE_MANAGE_DISTRIBUTIONS
          }
          active={
            pathname === ROUTE_ADMINX_ROUTE_MANAGE_DISTRIBUTIONS ? "true" : null
          }
        >
          <LinkItem
            icon={<VscLiveShare size={30} color="#244CCC" />}
            title="مدیریت توزیع"
          />
        </NavLink>
      )}
      {(getRoleFromUrl() === "AdminX" || getRoleFromUrl() === "SuperAdmin") && (
        <NavLink
          to={
            getRoleFromUrl() === "SuperAdmin"
              ? ROUTE_SUPER_ADMIN_SLAUGHTERS_MONITORING_BUYERS
              : getRoleFromUrl() === "AdminX"
              ? ROUTE_ADMINX_SLAUGHTERS_MONITORING_BUYERS
              : getRoleFromUrl() === "ProvinceOperator"
              ? ROUTE_PROVINCE_SLAUGHTERS_MONITORING_BUYERS
              : null
          }
          active={
            pathname === ROUTE_SUPER_ADMIN_SLAUGHTERS_MONITORING_BUYERS ||
            pathname === ROUTE_ADMINX_SLAUGHTERS_MONITORING_BUYERS ||
            pathname === ROUTE_PROVINCE_SLAUGHTERS_MONITORING_BUYERS
              ? "true"
              : null
          }
        >
          <LinkItem
            icon={<VscOrganization size={30} color="#244CCC" />}
            title="پایش خریداران"
          />
        </NavLink>
      )}
    </Grid>
  );
};
