From ea9f3042c02668978bbab4a8b2bc581e925fe285 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 18 Jul 2022 17:04:06 -0700 Subject: Handle disabled reports --- modern/src/common/components/BottomMenu.js | 41 +++++++++++++++++------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/modern/src/common/components/BottomMenu.js b/modern/src/common/components/BottomMenu.js index 504e642a..b0cd5e84 100644 --- a/modern/src/common/components/BottomMenu.js +++ b/modern/src/common/components/BottomMenu.js @@ -22,6 +22,7 @@ const BottomMenu = () => { const t = useTranslation(); const readonly = useRestriction('readonly'); + const disableReports = useRestriction('disableReports'); const userId = useSelector((state) => state.session.user.id); const socket = useSelector((state) => state.session.socket); @@ -29,13 +30,13 @@ const BottomMenu = () => { const currentSelection = () => { if (location.pathname === `/settings/user/${userId}`) { - return 3; + return 'account'; } if (location.pathname.startsWith('/settings')) { - return 2; + return 'settings'; } if (location.pathname.startsWith('/reports')) { - return 1; + return 'reports'; } if (location.pathname === '/') { - return 0; + return 'map'; } return null; }; @@ -54,21 +55,20 @@ const BottomMenu = () => { const handleSelection = (event, value) => { switch (value) { - case 0: + case 'map': navigate('/'); break; - case 1: + case 'reports': navigate('/reports/route'); break; - case 2: + case 'settings': navigate('/settings/preferences'); break; - case 3: - if (readonly) { - handleLogout(); - } else { - setAnchorEl(event.currentTarget); - } + case 'account': + setAnchorEl(event.currentTarget); + break; + case 'logout': + handleLogout(); break; default: break; @@ -85,12 +85,17 @@ const BottomMenu = () => { )} + value="map" /> - } /> - } /> - {readonly - ? (} />) - : (} />)} + {!disableReports && ( + } value="reports" /> + )} + } value="settings" /> + {readonly ? ( + } value="logout" /> + ) : ( + } value="account" /> + )} setAnchorEl(null)}> -- cgit v1.2.3