diff --git a/frontend/src/layout/MainListItems.js b/frontend/src/layout/MainListItems.js
index 879cc0e..fe49700 100644
--- a/frontend/src/layout/MainListItems.js
+++ b/frontend/src/layout/MainListItems.js
@@ -42,7 +42,8 @@ function ListItemLink(props) {
);
}
-const MainListItems = () => {
+const MainListItems = (props) => {
+ const { drawerClose } = props;
const { whatsApps } = useContext(WhatsAppsContext);
const { user } = useContext(AuthContext);
const [connectionWarning, setConnectionWarning] = useState(false);
@@ -70,7 +71,7 @@ const MainListItems = () => {
}, [whatsApps]);
return (
-
+
({
- root: {
- display: "flex",
- height: "100vh",
- },
+const useStyles = makeStyles((theme) => ({
+ root: {
+ display: "flex",
+ height: "100vh",
+ [theme.breakpoints.down("sm")]: {
+ height: "calc(100vh - 56px)",
+ },
+ },
- toolbar: {
- paddingRight: 24, // keep right padding when drawer closed
- },
- toolbarIcon: {
- display: "flex",
- alignItems: "center",
- justifyContent: "flex-end",
- padding: "0 8px",
- minHeight: "48px",
- },
- appBar: {
- zIndex: theme.zIndex.drawer + 1,
- transition: theme.transitions.create(["width", "margin"], {
- easing: theme.transitions.easing.sharp,
- duration: theme.transitions.duration.leavingScreen,
- }),
- },
- appBarShift: {
- marginLeft: drawerWidth,
- width: `calc(100% - ${drawerWidth}px)`,
- transition: theme.transitions.create(["width", "margin"], {
- easing: theme.transitions.easing.sharp,
- duration: theme.transitions.duration.enteringScreen,
- }),
- },
- menuButton: {
- marginRight: 36,
- },
- menuButtonHidden: {
- display: "none",
- },
- title: {
- flexGrow: 1,
- },
- drawerPaper: {
- position: "relative",
- whiteSpace: "nowrap",
- width: drawerWidth,
- transition: theme.transitions.create("width", {
- easing: theme.transitions.easing.sharp,
- duration: theme.transitions.duration.enteringScreen,
- }),
- },
- drawerPaperClose: {
- overflowX: "hidden",
- transition: theme.transitions.create("width", {
- easing: theme.transitions.easing.sharp,
- duration: theme.transitions.duration.leavingScreen,
- }),
- width: theme.spacing(7),
- [theme.breakpoints.up("sm")]: {
- width: theme.spacing(9),
- },
- },
- appBarSpacer: {
- minHeight: "48px",
- },
- content: {
- flex: 1,
- overflow: "auto",
- },
- container: {
- paddingTop: theme.spacing(4),
- paddingBottom: theme.spacing(4),
- },
- paper: {
- padding: theme.spacing(2),
- display: "flex",
- overflow: "auto",
- flexDirection: "column",
- },
+ toolbar: {
+ paddingRight: 24, // keep right padding when drawer closed
+ },
+ toolbarIcon: {
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "flex-end",
+ padding: "0 8px",
+ minHeight: "48px",
+ },
+ appBar: {
+ zIndex: theme.zIndex.drawer + 1,
+ transition: theme.transitions.create(["width", "margin"], {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.leavingScreen,
+ }),
+ },
+ appBarShift: {
+ marginLeft: drawerWidth,
+ width: `calc(100% - ${drawerWidth}px)`,
+ transition: theme.transitions.create(["width", "margin"], {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.enteringScreen,
+ }),
+ },
+ menuButton: {
+ marginRight: 36,
+ },
+ menuButtonHidden: {
+ display: "none",
+ },
+ title: {
+ flexGrow: 1,
+ },
+ drawerPaper: {
+ position: "relative",
+ whiteSpace: "nowrap",
+ width: drawerWidth,
+ transition: theme.transitions.create("width", {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.enteringScreen,
+ }),
+ },
+ drawerPaperClose: {
+ overflowX: "hidden",
+ transition: theme.transitions.create("width", {
+ easing: theme.transitions.easing.sharp,
+ duration: theme.transitions.duration.leavingScreen,
+ }),
+ width: theme.spacing(7),
+ [theme.breakpoints.up("sm")]: {
+ width: theme.spacing(9),
+ },
+ },
+ appBarSpacer: {
+ minHeight: "48px",
+ },
+ content: {
+ flex: 1,
+ overflow: "auto",
+ },
+ container: {
+ paddingTop: theme.spacing(4),
+ paddingBottom: theme.spacing(4),
+ },
+ paper: {
+ padding: theme.spacing(2),
+ display: "flex",
+ overflow: "auto",
+ flexDirection: "column",
+ },
}));
const LoggedInLayout = ({ children }) => {
- const classes = useStyles();
- const [userModalOpen, setUserModalOpen] = useState(false);
- const [anchorEl, setAnchorEl] = useState(null);
- const [menuOpen, setMenuOpen] = useState(false);
- const { handleLogout, loading } = useContext(AuthContext);
- const [drawerOpen, setDrawerOpen] = useLocalStorage("drawerOpen", true);
- const { user } = useContext(AuthContext);
+ const classes = useStyles();
+ const [userModalOpen, setUserModalOpen] = useState(false);
+ const [anchorEl, setAnchorEl] = useState(null);
+ const [menuOpen, setMenuOpen] = useState(false);
+ const { handleLogout, loading } = useContext(AuthContext);
+ const [drawerOpen, setDrawerOpen] = useState(false);
+ const [drawerVariant, setDrawerVariant] = useState("permanent");
+ const { user } = useContext(AuthContext);
- const handleMenu = event => {
- setAnchorEl(event.currentTarget);
- setMenuOpen(true);
- };
+ useEffect(() => {
+ if (document.body.offsetWidth > 600) {
+ setDrawerOpen(true);
+ }
+ }, []);
- const handleCloseMenu = () => {
- setAnchorEl(null);
- setMenuOpen(false);
- };
+ useEffect(() => {
+ if (document.body.offsetWidth < 600) {
+ setDrawerVariant("temporary");
+ } else {
+ setDrawerVariant("permanent");
+ }
+ }, [drawerOpen]);
- const handleOpenUserModal = () => {
- setUserModalOpen(true);
- handleCloseMenu();
- };
+ const handleMenu = (event) => {
+ setAnchorEl(event.currentTarget);
+ setMenuOpen(true);
+ };
- const handleClickLogout = () => {
- handleCloseMenu();
- handleLogout();
- };
+ const handleCloseMenu = () => {
+ setAnchorEl(null);
+ setMenuOpen(false);
+ };
- if (loading) {
- return ;
- }
+ const handleOpenUserModal = () => {
+ setUserModalOpen(true);
+ handleCloseMenu();
+ };
- return (
-
-
-
- setDrawerOpen(!drawerOpen)}>
-
-
-
-
-
-
-
-
-
-
setUserModalOpen(false)}
- userId={user?.id}
- />
-
-
- setDrawerOpen(!drawerOpen)}
- className={clsx(
- classes.menuButton,
- drawerOpen && classes.menuButtonHidden
- )}
- >
-
-
-
- WhaTicket
-
- {user.id && }
+ const handleClickLogout = () => {
+ handleCloseMenu();
+ handleLogout();
+ };
-
-
-
-
-
+ const drawerClose = () => {
+ if (document.body.offsetWidth < 600) {
+ setDrawerOpen(false);
+ }
+ };
- {children ? children : null}
-
-
- );
+ if (loading) {
+ return ;
+ }
+
+ return (
+
+
+
+ setDrawerOpen(!drawerOpen)}>
+
+
+
+
+
+
+
+
+
+
setUserModalOpen(false)}
+ userId={user?.id}
+ />
+
+
+ setDrawerOpen(!drawerOpen)}
+ className={clsx(
+ classes.menuButton,
+ drawerOpen && classes.menuButtonHidden
+ )}
+ >
+
+
+
+ WhaTicket
+
+ {user.id && }
+
+
+
+
+
+
+
+ {children ? children : null}
+
+
+ );
};
export default LoggedInLayout;