import { Box, Typography, Container } from "@mui/material";
import Vehicle from "./Vehicle";
import Personal from "./Personal";
import { Navigate } from "react-router-dom";
import Divider from "../../components/Divider";

const AdminMainPage = () => {
  const isAuth = localStorage.getItem("token") !== null;

  // Перенаправление на страницу логина, если пользователь не авторизован
  if (!isAuth) {
    return <Navigate to="/administrator" replace />;
  }

  return (
    <Box sx={{ width: "100%", color: "black", minHeight: "100vh" }}>
      <Container maxWidth="xl" sx={{ pt: "1vw" }}>
        <Box id="vehicles">
          <Typography
            variant="h5"
            component="h2"
            sx={{
              fontFamily: "Unbounded",
              fontWeight: "bold",
            }}
          ></Typography>
          <Vehicle />
        </Box>

        <Divider marginBottomDivider="1vw" marginTopDivider="5vw" />

        <Box id="personal">
          <Typography
            variant="h5"
            component="h2"
            sx={{
              fontFamily: "Unbounded",
              fontWeight: "bold",
            }}
          ></Typography>
          <Personal />
        </Box>
      </Container>
    </Box>
  );
};

export default AdminMainPage;
