import { Box, Typography } from "@mui/material";
import { Grid } from "../components/grid/Grid";
import { SPACING } from "../data/spacing";
import { useLocation } from "react-router-dom";
import {
  ROUTE_ADMINX_SLAUGHTERS,
  ROUTE_ADMINX_SLAUGHTERS_MANAGE,
  ROUTE_ADMINX_SLAUGHTERS_MONITORING_BUYERS,
  ROUTE_PROVINCE_SLAUGHTERS,
  ROUTE_PROVINCE_SLAUGHTERS_MANAGE,
  ROUTE_PROVINCE_SLAUGHTERS_MONITORING_BUYERS,
  ROUTE_SUPER_ADMIN_SLAUGHTERS,
  ROUTE_SUPER_ADMIN_SLAUGHTERS_MANAGE,
  ROUTE_SUPER_ADMIN_SLAUGHTERS_MONITORING_BUYERS,
} from "../routes/routes";
import { SlaughterActiveRequests } from "../features/slaughter-house/components/slaughter-active-requests/SlaughterActiveRequests";
import { BackButton } from "../components/back-button/BackButton";
import { ProvinceSlaughterOperations } from "../features/province/components/province-slaughter-operations/ProvinceSlaughterOperations";
import { MonitoringBuyers } from "../features/province/components/monitoring-buyers/MonitoringBuyers";

const Slaughters = () => {
  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_SLAUGHTERS ||
          pathname === ROUTE_SUPER_ADMIN_SLAUGHTERS ||
          pathname === ROUTE_ADMINX_SLAUGHTERS ? (
            <Grid justifyContent="center" my={SPACING.MEDIUM}>
              <Grid>
                <Typography variant="h6">مدیریت خریداران</Typography>
              </Grid>
              <ProvinceSlaughterOperations />
            </Grid>
          ) : (
            <BackButton />
          )}

          <Grid container justifyContent="space-between" gap={SPACING.SMALL}>
            <Grid xs={12}>
              {(pathname === ROUTE_PROVINCE_SLAUGHTERS_MANAGE ||
                pathname === ROUTE_SUPER_ADMIN_SLAUGHTERS_MANAGE ||
                pathname === ROUTE_ADMINX_SLAUGHTERS_MANAGE) && (
                <SlaughterActiveRequests />
              )}
              {(pathname === ROUTE_PROVINCE_SLAUGHTERS_MONITORING_BUYERS ||
                pathname === ROUTE_SUPER_ADMIN_SLAUGHTERS_MONITORING_BUYERS ||
                pathname === ROUTE_ADMINX_SLAUGHTERS_MONITORING_BUYERS) && (
                <MonitoringBuyers />
              )}
            </Grid>
          </Grid>
        </Grid>
      </Box>
    </>
  );
};

export default Slaughters;
