import { VscFolderActive, VscNewFolder } from "react-icons/vsc";
import { useLocation } from "react-router-dom";
import { Grid } from "../../../../components/grid/Grid";
import LinkItem from "../../../../components/link-item/LinkItem";
import { NavLink } from "../../../../components/nav-link/NavLink";
import { SPACING } from "../../../../data/spacing";
import {
  ROUTE_SLAUGHTER_INVENTORY_SELL_CARCASS_IN_PROVINCE,
  ROUTE_SLAUGHTER_INVENTORY_SELL_CARCASS_OUT_PROVINCE,
  ROUTE_SLAUGHTER_INVENTORY_STOCK,
  ROUTE_SLAUGHTER_OUT_PROVINCE_BUY,
  ROUTE_SLAUGHTER_SEGMENTATION,
} from "../../../../routes/routes";
import { slaughterGetProfile } from "../../services/slaughter-get-profile";
import {
  LOADING_END,
  LOADING_START,
} from "../../../../lib/redux/slices/appSlice";
import { useDispatch, useSelector } from "react-redux";
import { useEffect } from "react";
// import moment from "moment";

export const SlaughterInventoryOperation = () => {
  const dispatch = useDispatch();
  const { pathname } = useLocation();
  const { profile } = useSelector((state) => state.slaughterSlice);

  useEffect(() => {
    if (!profile) {
      dispatch(LOADING_START());
      dispatch(slaughterGetProfile()).then((r) => {
        dispatch(LOADING_END());
      });
    }
  }, []);

  return (
    <Grid
      container
      gap={SPACING.SMALL}
      p={SPACING.SMALL}
      direction={{ xs: "column", md: "row" }}
      justifyContent="center"
      style={{ placeContent: "baseline" }}
    >
      <NavLink
        to={ROUTE_SLAUGHTER_INVENTORY_STOCK}
        active={pathname === ROUTE_SLAUGHTER_INVENTORY_STOCK ? "true" : null}
      >
        <LinkItem
          icon={<VscNewFolder size={30} color="#244CCC" />}
          title="ورود به انبار"
        />
      </NavLink>

      <NavLink
        to={ROUTE_SLAUGHTER_INVENTORY_SELL_CARCASS_IN_PROVINCE}
        active={
          pathname === ROUTE_SLAUGHTER_INVENTORY_SELL_CARCASS_IN_PROVINCE
            ? "true"
            : null
        }
      >
        <LinkItem
          icon={<VscNewFolder size={30} color="#244CCC" />}
          title="فروش داخل استان"
        />
      </NavLink>

      <NavLink
        to={ROUTE_SLAUGHTER_INVENTORY_SELL_CARCASS_OUT_PROVINCE}
        active={
          pathname === ROUTE_SLAUGHTER_INVENTORY_SELL_CARCASS_OUT_PROVINCE
            ? "true"
            : null
        }
      >
        <LinkItem
          icon={<VscNewFolder size={30} color="#244CCC" />}
          title="فروش به خارج استان"
        />
      </NavLink>

      <NavLink
        to={ROUTE_SLAUGHTER_OUT_PROVINCE_BUY}
        active={pathname === ROUTE_SLAUGHTER_OUT_PROVINCE_BUY ? "true" : null}
      >
        <LinkItem
          icon={<VscFolderActive size={30} color="#244CCC" />}
          title="خرید خارج از استان"
          description="درخواست های در انتظار عملیات وارد کردن اطلاعات بارهای دریافتی"
        />
      </NavLink>

      <NavLink
        to={ROUTE_SLAUGHTER_SEGMENTATION}
        active={pathname === ROUTE_SLAUGHTER_SEGMENTATION ? "true" : null}
      >
        <LinkItem
          icon={<VscNewFolder size={30} color="#244CCC" />}
          title="قطعه بندی"
        />
      </NavLink>

      {/* <NavLink
        to={`${ROUTE_SLAUGHTER_AGENT_SHARE}/${
          profile?.killHouse[0]?.key
        }/${moment(new Date()).format("YYYY-MM-DD")}`}
        active={
          pathname ===
          `${ROUTE_SLAUGHTER_AGENT_SHARE}/${
            profile?.killHouse[0]?.key
          }/${moment(new Date()).format("YYYY-MM-DD")}`
            ? "true"
            : null
        }
      >
        <LinkItem
          icon={<VscNewFolder size={30} color="#244CCC" />}
          title="سهم بندی اتوماتیک مباشرین"
        />
      </NavLink> */}
    </Grid>
  );
};
