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_PROVINCE_FINANCIAL_ACTIVE_REQUESTS,
  ROUTE_PROVINCE_FINANCIAL_ARCHIVED_REQUESTS,
  ROUTE_PROVINCE_FINANCIAL_AWAITING_INSPECTION_REQUESTS,
  ROUTE_PROVINCE_FINANCIAL_AWAITING_PAYMENT_REQUESTS,
  ROUTE_PROVINCE_FINANCIAL_CHECK_PAYED_FACTOR_REQUESTS,
  ROUTE_PROVINCE_FINANCIAL_FINAL_FACTORS_REQUESTS,
  ROUTE_PROVINCE_FINANCIAL_NEW_REQUESTS,
  ROUTE_PROVINCE_FINANCIAL_PENDING_REQUESTS,
  ROUTE_PROVINCE_FINANCIAL_REQUESTS,
} from "../routes/routes";
import { ProvinceFinancialOperations } from "../features/province-finacial/components/province-financial-operations/ProvinceFinancialOperations";
import { ProvinceFinancialActiveRequests } from "../features/province-finacial/components/province-financial-active-requests/ProvinceFinancialActiveRequests";
import { AvicultureArchivedRequests } from "../features/aviculture/components/aviculture-archived-requests/AvicultureArchivedRequests";
import { ProvinceFinancialNewRequests } from "../features/province-finacial/components/province-financial-new-requests/ProvinceFinancialNewRequests";
import { RequestsAwaitingPayment } from "../components/requests-awaiting-payment/RequestsAwaitingPayment";
import { RequestsAwaitingInspections } from "../components/requests-awaiting-inspections/RequestsAwaitingInspections";
import { ProvinceFinancialPendingRequests } from "../features/province-finacial/components/province-financial-pending-requests/ProvinceFinancialPendingRequests";
import { ProvinceFinancialCheckPayedFactorRequests } from "../features/province-finacial/components/province-financial-check-payed-factor-requests/ProvinceFinancialCheckPayedFactorRequests";
import { FinalFactorsRequests } from "../features/province-finacial/components/final-factors-requests/FinalFactorsRequests";
import { BackButton } from "../components/back-button/BackButton";

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

          <Grid container justifyContent="space-between" gap={SPACING.SMALL}>
            <Grid xs={12}>
              {pathname === ROUTE_PROVINCE_FINANCIAL_PENDING_REQUESTS && (
                <ProvinceFinancialPendingRequests />
              )}
              {pathname === ROUTE_PROVINCE_FINANCIAL_ACTIVE_REQUESTS && (
                <ProvinceFinancialActiveRequests />
              )}
              {pathname === ROUTE_PROVINCE_FINANCIAL_ARCHIVED_REQUESTS && (
                <AvicultureArchivedRequests />
              )}

              {pathname === ROUTE_PROVINCE_FINANCIAL_NEW_REQUESTS && (
                <ProvinceFinancialNewRequests />
              )}

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

              {pathname ===
                ROUTE_PROVINCE_FINANCIAL_AWAITING_INSPECTION_REQUESTS && (
                <RequestsAwaitingInspections />
              )}

              {pathname ===
                ROUTE_PROVINCE_FINANCIAL_CHECK_PAYED_FACTOR_REQUESTS && (
                <ProvinceFinancialCheckPayedFactorRequests />
              )}

              {pathname === ROUTE_PROVINCE_FINANCIAL_FINAL_FACTORS_REQUESTS && (
                <FinalFactorsRequests />
              )}
            </Grid>
          </Grid>
        </Grid>
      </Box>
    </>
  );
};

export default ProvinceFinancial;
