diff --git a/packages/web/src/components/Layout/index.tsx b/packages/web/src/components/Layout/index.tsx index 09c738de..e9499d54 100644 --- a/packages/web/src/components/Layout/index.tsx +++ b/packages/web/src/components/Layout/index.tsx @@ -12,6 +12,7 @@ import * as URLS from 'config/urls'; import useVersion from 'hooks/useVersion'; import AppBar from 'components/AppBar'; import Drawer from 'components/Drawer'; +import useAutomatischInfo from 'hooks/useAutomatischInfo'; type PublicLayoutProps = { children: React.ReactNode; @@ -38,19 +39,36 @@ const drawerLinks = [ }, ]; -const generateDrawerBottomLinks = ({ notificationBadgeContent = 0 }) => [ - { - Icon: NotificationsIcon, - primary: 'settingsDrawer.notifications', - to: URLS.UPDATES, - badgeContent: notificationBadgeContent, - }, -]; +type GenerateDrawerBottomLinksOptions = { + isMation: boolean; + loading: boolean; + notificationBadgeContent: number; +}; + +const generateDrawerBottomLinks = ({ + isMation, + loading, + notificationBadgeContent = 0, +}: GenerateDrawerBottomLinksOptions) => { + if (loading || isMation) { + return []; + } + + return [ + { + Icon: NotificationsIcon, + primary: 'settingsDrawer.notifications', + to: URLS.UPDATES, + badgeContent: notificationBadgeContent, + }, + ]; +}; export default function PublicLayout({ children, }: PublicLayoutProps): React.ReactElement { const version = useVersion(); + const { isMation, loading } = useAutomatischInfo(); const theme = useTheme(); const matchSmallScreens = useMediaQuery(theme.breakpoints.down('lg')); const [isDrawerOpen, setDrawerOpen] = React.useState(!matchSmallScreens); @@ -60,6 +78,8 @@ export default function PublicLayout({ const drawerBottomLinks = generateDrawerBottomLinks({ notificationBadgeContent: version.newVersionCount, + loading, + isMation, }); return ( diff --git a/packages/web/src/pages/Notifications/index.tsx b/packages/web/src/pages/Notifications/index.tsx index 43953984..8e5c7bff 100644 --- a/packages/web/src/pages/Notifications/index.tsx +++ b/packages/web/src/pages/Notifications/index.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import { useNavigate } from 'react-router-dom'; import Box from '@mui/material/Box'; import Stack from '@mui/material/Stack'; @@ -7,6 +8,8 @@ import Container from 'components/Container'; import NotificationCard from 'components/NotificationCard'; import PageTitle from 'components/PageTitle'; import useFormatMessage from 'hooks/useFormatMessage'; +import useAutomatischInfo from 'hooks/useAutomatischInfo'; +import * as URLS from 'config/urls'; interface INotification { name: string; @@ -16,8 +19,19 @@ interface INotification { } export default function Updates(): React.ReactElement { + const navigate = useNavigate(); const formatMessage = useFormatMessage(); const { notifications } = useNotifications(); + const { isMation, loading } = useAutomatischInfo(); + + React.useEffect( + function redirectToHomepageInMation() { + if (!loading && isMation) { + navigate(URLS.DASHBOARD); + } + }, + [loading, isMation] + ); return (