import { Box, Typography } from "@mui/material";
import { Grid } from "../components/grid/Grid";
import { SPACING } from "../data/spacing";
import { RequestsOperations } from "../features/aviculture/components/requests-operations/RequestsOperations";
import { useLocation } from "react-router-dom";
import {
  ROUTE_AVICULTURE_ARCHIVED_REQUESTS,
  ROUTE_AVICULTURE_REJECTED_REQUESTS,
  ROUTE_AVICULTURE_REQUESTS,
  ROUTE_AVICULTURE_HATCHING,
  ROUTE_AVICULTURE_CREATE_NEW_REQUEST,
  ROUTE_AVICULTURE_AWAITING_PAYMENT_REQUESTS,
  ROUTE_AVICULTURE_AWAITING_INSPECTION_REQUESTS,
  ROUTE_AVICULTURE_SUBMIT_REQUEST,
  ROUTE_AVICULTURE_GIVE_PERMISSION,
} from "../routes/routes";
import { AvicultureNewRequest } from "../features/aviculture/components/aviculture-new-request/AvicultureNewRequest";
import { AvicultureActiveRequests } from "../features/aviculture/components/aviculture-active-requests/AvicultureActiveRequests";
import { AvicultureRejectedRequests } from "../features/aviculture/components/aviculture-rejected-requests/AvicultureRejectedRequests";
import { AvicultureArchivedRequests } from "../features/aviculture/components/aviculture-archived-requests/AvicultureArchivedRequests";
import { AvicultureHatching } from "../features/aviculture/components/aviculture-hatching/AvicultureHatching";
import { RequestsAwaitingPayment } from "../components/requests-awaiting-payment/RequestsAwaitingPayment";
import { RequestsAwaitingInspections } from "../components/requests-awaiting-inspections/RequestsAwaitingInspections";
import { BackButton } from "../components/back-button/BackButton";
import { AvicultureGivePermission } from "../features/aviculture/components/aviculture-give-permission/AvicultureGivePermission";

const AvicultureRequests = () => {
  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_AVICULTURE_REQUESTS ? (
          <>
            <Grid mt={SPACING.MEDIUM}>
              <Typography variant="h6">صفحه درخواست های مرغدار</Typography>
            </Grid>
            <Grid justifyContent="center" alignItems="center">
              <RequestsOperations />
            </Grid>
          </>
        ) : (
          <BackButton />
        )}

        <Grid container justifyContent="space-between" gap={SPACING.SMALL}>
          <Grid xs={12}>
            {pathname === ROUTE_AVICULTURE_CREATE_NEW_REQUEST && (
              <AvicultureNewRequest />
            )}
            {pathname === ROUTE_AVICULTURE_HATCHING && <AvicultureHatching />}
            {pathname === ROUTE_AVICULTURE_SUBMIT_REQUEST && (
              <AvicultureActiveRequests />
            )}
            {pathname === ROUTE_AVICULTURE_REJECTED_REQUESTS && (
              <AvicultureRejectedRequests />
            )}
            {pathname === ROUTE_AVICULTURE_ARCHIVED_REQUESTS && (
              <AvicultureArchivedRequests />
            )}
            {pathname === ROUTE_AVICULTURE_AWAITING_PAYMENT_REQUESTS && (
              <RequestsAwaitingPayment />
            )}
            {pathname === ROUTE_AVICULTURE_AWAITING_INSPECTION_REQUESTS && (
              <RequestsAwaitingInspections />
            )}
            {pathname === ROUTE_AVICULTURE_GIVE_PERMISSION && (
              <AvicultureGivePermission />
            )}
          </Grid>
        </Grid>
      </Grid>
    </Box>
  );
};

export default AvicultureRequests;
