import React from "react";
import {
  ROUTE_ADMINX_COLD_HOUSES,
  ROUTE_ADMINX_COLD_HOUSES_MANAGEMENT,
  ROUTE_PROVINCE_COLD_HOUSES,
  ROUTE_PROVINCE_COLD_HOUSES_MANAGEMENT,
  ROUTE_SUPER_ADMIN_COLD_HOUSES,
  ROUTE_SUPER_ADMIN_COLD_HOUSES_MANAGEMENT,
} from "../routes/routes";
import { SPACING } from "../data/spacing";
import { Grid } from "../components/grid/Grid";
import { Box, Typography } from "@mui/material";
import { useLocation, useParams } from "react-router-dom";
import { BackButton } from "../components/back-button/BackButton";
import { ProvinceColdHousesOperations } from "../features/province/components/province-cold-houses-operations/ProvinceColdHousesOperations";
import { ProvinceColdHousesList } from "../features/province/components/province-cold-houses-list/ProvinceColdHousesList";
import { ProvinceStewardShowColdHousesList } from "../features/province/components/province-steward-show-cold-houses-list/ProvinceStewardShowColdHousesList";

const ProvinceColdHousesPage = () => {
  const { pathname } = useLocation();
  const { key } = useParams();
  return (
    <>
      <Box display={"flex"} justifyContent="center">
        <Grid
          container
          direction="column"
          justifyContent="center"
          xs={12}
          sm={12}
          md={10}
          lg={10}
        >
          {pathname === ROUTE_PROVINCE_COLD_HOUSES ||
          pathname === ROUTE_ADMINX_COLD_HOUSES ||
          pathname === ROUTE_SUPER_ADMIN_COLD_HOUSES ? (
            <Grid justifyContent="center" my={SPACING.MEDIUM}>
              <Grid>
                <Typography variant="h6">داشبورد مدیریت سردخانه ها </Typography>
              </Grid>
              <ProvinceColdHousesOperations />
            </Grid>
          ) : (
            <BackButton />
          )}

          {(pathname === ROUTE_PROVINCE_COLD_HOUSES_MANAGEMENT ||
            pathname === ROUTE_ADMINX_COLD_HOUSES_MANAGEMENT ||
            pathname === ROUTE_SUPER_ADMIN_COLD_HOUSES_MANAGEMENT) && (
            <ProvinceColdHousesList />
          )}

          {key && <ProvinceStewardShowColdHousesList />}
        </Grid>
      </Box>
    </>
  );
};

export default ProvinceColdHousesPage;
