import { Box, Typography } from "@mui/material";
import { Grid } from "../components/grid/Grid";
import { SPACING } from "../data/spacing";
import { CityOperations } from "../features/city/components/city-operations/CityOperations";
import { useLocation } from "react-router-dom";
import {
  ROUTE_CITY_ACTIVE_REQUESTS,
  ROUTE_CITY_ARCHIVED_REQUESTS,
  ROUTE_CITY_REJECTED_REQUESTS,
  ROUTE_CITY_REQUESTS,
  ROUTE_CITY_AWAITING_PAYMENT_REQUESTS,
  ROUTE_CITY_AWAITING_INSPECTION_REQUESTS,
  ROUTE_CITY_NEW_REQUESTS,
  ROUTE_CITY_FREE_SALES_REQUESTS,
} from "../routes/routes";
import { CityNewRequests } from "../features/city/components/city-new-requests/CityNewRequests";
import { AvicultureArchivedRequests } from "../features/aviculture/components/aviculture-archived-requests/AvicultureArchivedRequests";
import { CityActiveRequests } from "../features/city/components/city-active-requests/CityActiveRequests";
import { CityRejectedRequests } from "../features/city/components/city-rejected-requests/CityRejectedRequests";
import { RequestsAwaitingInspections } from "../components/requests-awaiting-inspections/RequestsAwaitingInspections";
import { RequestsAwaitingPayment } from "../components/requests-awaiting-payment/RequestsAwaitingPayment";
import { BackButton } from "../components/back-button/BackButton";
import { ProvinceFreeSales } from "../features/province/components/province-free-sales/ProvinceFreeSales";

const CityRequests = () => {
  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_CITY_REQUESTS ? (
            <Grid justifyContent="center" my={SPACING.MEDIUM}>
              <Grid>
                <Typography variant="h6">
                  صفحه مدیریت درخواست ها (شهرستان)
                </Typography>
              </Grid>
              <CityOperations />
            </Grid>
          ) : (
            <BackButton />
          )}

          <Grid container justifyContent="space-between" gap={SPACING.SMALL}>
            <Grid xs={12}>
              {pathname === ROUTE_CITY_NEW_REQUESTS && <CityNewRequests />}
              {pathname === ROUTE_CITY_ACTIVE_REQUESTS && (
                <CityActiveRequests />
              )}
              {pathname === ROUTE_CITY_REJECTED_REQUESTS && (
                <CityRejectedRequests />
              )}
              {pathname === ROUTE_CITY_ARCHIVED_REQUESTS && (
                <AvicultureArchivedRequests />
              )}
              {pathname === ROUTE_CITY_AWAITING_PAYMENT_REQUESTS && (
                <RequestsAwaitingPayment />
              )}

              {pathname === ROUTE_CITY_AWAITING_INSPECTION_REQUESTS && (
                <RequestsAwaitingInspections />
              )}
              {pathname === ROUTE_CITY_FREE_SALES_REQUESTS && (
                <ProvinceFreeSales />
              )}
            </Grid>
          </Grid>
        </Grid>
      </Box>
    </>
  );
};

export default CityRequests;
