From 0fb931d6b2193891eb8cefd002ef941eb6daed75 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 3 Jul 2022 11:00:47 -0700 Subject: Add simple events drawer --- modern/src/main/MainPage.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'modern/src/main/MainPage.js') diff --git a/modern/src/main/MainPage.js b/modern/src/main/MainPage.js index e322dca0..31248271 100644 --- a/modern/src/main/MainPage.js +++ b/modern/src/main/MainPage.js @@ -37,6 +37,7 @@ import MapOverlay from '../map/overlay/MapOverlay'; import MapGeocoder from '../map/geocoder/MapGeocoder'; import MapScale from '../map/MapScale'; import MapNotification from '../map/notification/MapNotification'; +import EventsDrawer from './EventsDrawer'; const useStyles = makeStyles((theme) => ({ root: { @@ -164,17 +165,21 @@ const MainPage = () => { const filterRef = useRef(); const [filterAnchorEl, setFilterAnchorEl] = useState(null); - const [collapsed, setCollapsed] = useState(false); + const [devicesOpen, setDevicesOpen] = useState(false); + const [eventsOpen, setEventsOpen] = useState(false); + + const eventHandler = useCallback(() => setEventsOpen(true), [setEventsOpen]); + const eventsAvailable = useSelector((state) => !!state.events.items.length); const handleClose = () => { - setCollapsed(!collapsed); + setDevicesOpen(!devicesOpen); }; - useEffect(() => setCollapsed(!desktop), [desktop]); + useEffect(() => setDevicesOpen(desktop), [desktop]); useEffect(() => { if (!desktop && mapMapOnSelect && selectedDeviceId) { - setCollapsed(true); + setDevicesOpen(false); } }, [desktop, mapMapOnSelect, selectedDeviceId]); @@ -218,7 +223,7 @@ const MainPage = () => { - + {desktop && } - + {!desktop && ( @@ -329,6 +334,7 @@ const MainPage = () => { )} + setEventsOpen(false)} /> {selectedDeviceId && (