diff --git a/ui/src/App.tsx b/ui/src/App.tsx index a58c188..a05f8a0 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React from "react"; import { connect, ConnectedProps } from "react-redux"; import clsx from "clsx"; import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; @@ -28,6 +28,7 @@ import { AppState } from "./store"; import { paths } from "./paths"; import { useTheme } from "./theme"; import { closeSnackbar } from "./actions/snackbarActions"; +import { toggleDrawer } from "./actions/settingsActions"; import ListItemLink from "./components/ListItemLink"; import SchedulersView from "./views/SchedulersView"; import DashboardView from "./views/DashboardView"; @@ -135,11 +136,13 @@ function mapStateToProps(state: AppState) { return { snackbar: state.snackbar, themePreference: state.settings.themePreference, + isDrawerOpen: state.settings.isDrawerOpen, }; } const mapDispatchToProps = { closeSnackbar, + toggleDrawer, }; const connector = connect(mapStateToProps, mapDispatchToProps); @@ -151,8 +154,6 @@ function SlideUpTransition(props: TransitionProps) { function App(props: ConnectedProps) { const theme = useTheme(props.themePreference); const classes = useStyles(theme)(); - const [open, setOpen] = useState(true); - const toggleDrawer = () => setOpen(!open); return ( @@ -167,7 +168,7 @@ function App(props: ConnectedProps) { edge="start" color="inherit" aria-label="open drawer" - onClick={toggleDrawer} + onClick={props.toggleDrawer} className={classes.menuButton} > @@ -189,10 +190,10 @@ function App(props: ConnectedProps) { classes={{ paper: clsx( classes.drawerPaper, - !open && classes.drawerPaperClose + !props.isDrawerOpen && classes.drawerPaperClose ), }} - open={open} + open={props.isDrawerOpen} >