import { Box, Card } from "@mui/material";
import { Grid } from "../components/grid/Grid";
import { SPACING } from "../data/spacing";
import { DriverOperations } from "../features/driver/components/driver-operations/DriverOperations";
import { useLocation } from "react-router-dom";
import { ROUTE_DRIVER_CARS, ROUTE_DRIVER_REQUESTS } from "../routes/routes";
import { DriverRequests } from "../features/driver/components/driver-requests/DriverRequests";
import { DriverCars } from "../features/driver/components/driver-cars/DriverCars";

const Driver = () => {
  const { pathname } = useLocation();

  return (
    <>
      <Box display={"flex"} justifyContent="center">
        <Grid
          container
          direction="column"
          justifyContent="center"
          xs={12}
          sm={12}
          md={10}
          lg={10}
        >
          <Grid justifyContent="center" my={SPACING.MEDIUM}>
            <Card>
              <DriverOperations />
            </Card>
          </Grid>
          <Grid container justifyContent="space-between" gap={SPACING.SMALL}>
            <Grid xs={12}>
              {pathname === ROUTE_DRIVER_REQUESTS && <DriverRequests />}
              {pathname === ROUTE_DRIVER_CARS && <DriverCars />}
            </Grid>
          </Grid>
        </Grid>
      </Box>
    </>
  );
};

export default Driver;
