import { Box, Typography } from "@mui/material";
import { useLocation } from "react-router-dom";
import { BackButton } from "../components/back-button/BackButton";
import { Grid } from "../components/grid/Grid";
import { SPACING } from "../data/spacing";
import { ProvinceManageBuyReq } from "../features/province/components/province-manage-buy-req/ProvinceManageBuyReq";
import { ProvinceManageProcessOperation } from "../features/province/components/province-manage-process-operation/ProvinceManageProcessOperation";
import { ProvinceManageSlaughterKillplace } from "../features/province/components/province-manage-slaughter-killplace/ProvinceManageSlaughterKillplace";
import { ProvinceManageSlaughters } from "../features/province/components/province-manage-slaughters/ProvinceManageSlaughters";
import { ProvincePolicyCouncil } from "../features/province/components/province-policy-council/ProvincePolicyCouncil";
import {
  ROUTE_ADMINX_ROUTE_ACCOUNTS,
  ROUTE_ADMINX_ROUTE_CRONJOB,
  ROUTE_ADMINX_ROUTE_Sms_Submission_Management,
  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS,
  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_BUY_REQ,
  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_DOCUMENT_STATES,
  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_KILLPLACE,
  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_POLICY_COUNCIL,
  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_SLAUGHTER,
  ROUTE_ADMINX_ROUTE_TICKET_PERMISSION,
  ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS,
  ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_BUY_REQ,
  ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_KILLPLACE,
  ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_POLICY_COUNCIL,
  ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_SLAUGHTER,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_BUY_REQ,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_DOCUMENT_STATES,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_KILLPLACE,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_POLICY_COUNCIL,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_SLAUGHTER,
  ROUTE_SUPER_ADMIN_ROUTE_TICKET_PERMISSION,
  ROUTE_SUPER_ADMIN_ROUTE_SLAUGHTER_TRADE_PANEL,
  ROUTE_ADMINX_ROUTE_SLAUGHTER_TRADE_PANEL,
  ROUTE_ADMINX_ROUTE_WEIGHT_RANGE,
  ROUTE_ADMINX_ROUTE_WEIGHT_CATEGORY,
  ROUTE_SUPER_ADMIN_ROUTE_WEIGHT_CATEGORY,
  ROUTE_SUPER_ADMIN_ROUTE_WEIGHT_RANGE,
  ROUTE_SUPER_ADMIN_ROUTE_PENALTY,
  ROUTE_ADMINX_ROUTE_PENALTY,
  ROUTE_ADMINX_ROUTE_MANAGE_DISTRIBUTIONS,
  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_DISTRIBUTIONS,
  ROUTE_ADMINX_ROUTE_RESTRICTION_OF_CARCASS_DISTRIBUTION,
  ROUTE_SUPER_ADMIN_ROUTE_RESTRICTION_OF_CARCASS_DISTRIBUTION,
} from "../routes/routes";
import { ProvincePolicyDocumentStates } from "../features/province/components/province-policy-document-states/ProvincePolicyDocumentStates";
import { ProvincePolicyAccounts } from "../features/province/components/province-policy-accounts/ProvincePolicyAccounts";
import { ProvincePolicyTicketPermission } from "../features/province/components/province-policy-ticket-permission/ProvincePolicyTicketPermission";
import ProcincePolicyKronjob from "../features/province/components/province-policey-kronjon/ProcincePolicyKronjob";
import { ProvinceSmsSubmissionManagement } from "../features/province/components/province-sms-submission-management/provinceSmsSubmissionManagement";
import { ProvinceManageTrades } from "../features/province/components/province-manage-trades/ProvinceManageTrades";
import { ProvincePolicyManageWeightRange } from "../features/province/components/province-policy-manage-weight-range/ProvincePolicyManageWeightRange";
import { ProvincePolicyManageWeightCategory } from "../features/province/components/province-policy-manage-weight-category/ProvincePolicyManageWeightCategory";
import { ProvincePolicyManagePenalty } from "../features/province/components/province-policy-manage-penalty/provincePolicyManagePenalty";
import { ProvinceManageDistributions } from "../features/province/components/province-manage-distributions/ProvinceManageDistributions";
import { ProvinceRestrictionCarcassDistribution } from "../features/province/components/province-restriction-carcass-distribution/ProvinceRestrictionCarcassDistribution";

const ManageProcess = () => {
  const { pathname } = useLocation();
  return (
    <>
      <Box display={"flex"} justifyContent="center">
        <Grid
          container
          direction="column"
          justifyContent="center"
          xs={12}
          sm={12}
          md={10}
          lg={10}
        >
          {pathname === ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS ||
          pathname === ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS ||
          pathname === ROUTE_ADMINX_ROUTE_MANAGE_PROCESS ? (
            <Grid justifyContent="center" my={SPACING.MEDIUM}>
              <Grid>
                <Typography variant="h6">مدیریت فرآیند</Typography>
              </Grid>
              <ProvinceManageProcessOperation />
            </Grid>
          ) : (
            <BackButton />
          )}

          <Grid container justifyContent="space-between" gap={SPACING.SMALL}>
            <Grid mt={SPACING.SMALL} xs={12}>
              {(pathname ===
                ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_POLICY_COUNCIL ||
                pathname ===
                  ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_POLICY_COUNCIL ||
                pathname ===
                  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_POLICY_COUNCIL) && (
                <ProvincePolicyCouncil />
              )}
              {(pathname === ROUTE_SUPER_ADMIN_ROUTE_SLAUGHTER_TRADE_PANEL ||
                pathname === ROUTE_ADMINX_ROUTE_SLAUGHTER_TRADE_PANEL) && (
                <ProvinceManageTrades />
              )}
              {(pathname === ROUTE_ADMINX_ROUTE_MANAGE_DISTRIBUTIONS ||
                pathname === ROUTE_SUPER_ADMIN_ROUTE_MANAGE_DISTRIBUTIONS) && (
                <ProvinceManageDistributions />
              )}
              {(pathname === ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_SLAUGHTER ||
                pathname === ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_SLAUGHTER ||
                pathname === ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_SLAUGHTER) && (
                <ProvinceManageSlaughters />
              )}
              {(pathname === ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_KILLPLACE ||
                pathname === ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_KILLPLACE ||
                pathname === ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_KILLPLACE) && (
                <ProvinceManageSlaughterKillplace />
              )}
              {(pathname === ROUTE_PROVINCE_ROUTE_MANAGE_PROCESS_BUY_REQ ||
                pathname === ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_BUY_REQ ||
                pathname === ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_BUY_REQ) && (
                <ProvinceManageBuyReq />
              )}
              {(pathname ===
                ROUTE_SUPER_ADMIN_ROUTE_MANAGE_PROCESS_DOCUMENT_STATES ||
                pathname ===
                  ROUTE_ADMINX_ROUTE_MANAGE_PROCESS_DOCUMENT_STATES) && (
                <ProvincePolicyDocumentStates />
              )}
              {pathname === ROUTE_ADMINX_ROUTE_ACCOUNTS && (
                <ProvincePolicyAccounts />
              )}
              {(pathname === ROUTE_ADMINX_ROUTE_TICKET_PERMISSION ||
                pathname === ROUTE_SUPER_ADMIN_ROUTE_TICKET_PERMISSION) && (
                <ProvincePolicyTicketPermission />
              )}
              {pathname === ROUTE_ADMINX_ROUTE_CRONJOB && (
                <ProcincePolicyKronjob />
              )}
              {pathname === ROUTE_ADMINX_ROUTE_Sms_Submission_Management && (
                <ProvinceSmsSubmissionManagement />
              )}
              {(pathname === ROUTE_ADMINX_ROUTE_WEIGHT_RANGE ||
                pathname === ROUTE_SUPER_ADMIN_ROUTE_WEIGHT_RANGE) && (
                <ProvincePolicyManageWeightRange />
              )}
              {(pathname === ROUTE_ADMINX_ROUTE_WEIGHT_CATEGORY ||
                pathname === ROUTE_SUPER_ADMIN_ROUTE_WEIGHT_CATEGORY) && (
                <ProvincePolicyManageWeightCategory />
              )}
              {(pathname === ROUTE_ADMINX_ROUTE_PENALTY ||
                pathname === ROUTE_SUPER_ADMIN_ROUTE_PENALTY) && (
                <ProvincePolicyManagePenalty />
              )}
              {(pathname ===
                ROUTE_ADMINX_ROUTE_RESTRICTION_OF_CARCASS_DISTRIBUTION ||
                pathname ===
                  ROUTE_SUPER_ADMIN_ROUTE_RESTRICTION_OF_CARCASS_DISTRIBUTION) && (
                <ProvinceRestrictionCarcassDistribution />
              )}
            </Grid>
          </Grid>
        </Grid>
      </Box>
    </>
  );
};

export default ManageProcess;
