"use client";

import { FC, PropsWithChildren, useState } from "react";
import { Grid, Box } from "@mui/material";
import { Sidebar } from "./Sidebar";
import { SetupModeWarning } from "./SetupModeWarning";

interface InternalLayoutProps extends PropsWithChildren {
  setupModeActive: boolean;
  leafcutterEnabled: boolean;
}

export const InternalLayout: FC<InternalLayoutProps> = ({
  children,
  setupModeActive,
  leafcutterEnabled,
}) => {
  const [open, setOpen] = useState(true);

  return (
    <Box sx={{ position: "relative" }}>
      <SetupModeWarning setupModeActive={setupModeActive} />
      <Grid container direction="row">
        <Sidebar
          open={open}
          setOpen={setOpen}
          leafcutterEnabled={leafcutterEnabled}
        />
        <Grid
          item
          sx={{ ml: open ? "270px" : "70px", width: "100%", height: "100vh" }}
        >
          {children as any}
        </Grid>
      </Grid>
    </Box>
  );
};
