import { Box, Typography } from "@mui/material";
import { Grid } from "../components/grid/Grid";
import { SPACING } from "../data/spacing";
import {
  ROUTE_INSPECTOR_ARCHIVED_REQUESTS,
  ROUTE_INSPECTOR_REJECTED_REQUESTS,
  ROUTE_INSPECTOR_REQUESTS,
  ROUTE_INSPECTOR_REQUESTS_NEW_REQUESTS,
  ROUTE_PROVINCE_INSPECTOR_AWAITING_INSPECTION_REQUESTS,
  ROUTE_PROVINCE_INSPECTOR_AWAITING_PAYMENT_REQUESTS,
} from "../routes/routes";
import { useLocation } from "react-router-dom";
import { InspectorNewRequests } from "../features/inspector/components/inspector-new-requests/InspectorNewRequests";
import { InspectorOperations } from "../features/inspector/components/inspector-operations/InspectorOperations";
import { InspectorRejectedRequests } from "../features/inspector/components/inspector-rejected-requests/InspectorRejectedRequests";
import { InspectorArchivedRequests } from "../features/inspector/components/inspector-archived-requests/InspectorArchivedRequests";
import { RequestsAwaitingPayment } from "../components/requests-awaiting-payment/RequestsAwaitingPayment";
import { RequestsAwaitingInspections } from "../components/requests-awaiting-inspections/RequestsAwaitingInspections";
import { BackButton } from "../components/back-button/BackButton";

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

          <Grid container justifyContent="space-between" gap={SPACING.SMALL}>
            <Grid xs={12}>
              {pathname === ROUTE_INSPECTOR_REQUESTS_NEW_REQUESTS && (
                <InspectorNewRequests />
              )}
              {pathname === ROUTE_INSPECTOR_REJECTED_REQUESTS && (
                <InspectorRejectedRequests />
              )}
              {pathname === ROUTE_INSPECTOR_ARCHIVED_REQUESTS && (
                <InspectorArchivedRequests />
              )}

              {pathname ===
                ROUTE_PROVINCE_INSPECTOR_AWAITING_PAYMENT_REQUESTS && (
                <RequestsAwaitingPayment />
              )}

              {pathname ===
                ROUTE_PROVINCE_INSPECTOR_AWAITING_INSPECTION_REQUESTS && (
                <RequestsAwaitingInspections />
              )}
            </Grid>
          </Grid>
        </Grid>
      </Box>
    </>
  );
};
export default Inspector;
