From 0d1add60c2a4e0ee8b51e83c81f1e039db194aec Mon Sep 17 00:00:00 2001 From: leandrofars Date: Wed, 30 Oct 2024 09:22:22 -0300 Subject: [PATCH] fix(frontend): alert component handler --- frontend/src/layouts/dashboard/layout.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/src/layouts/dashboard/layout.js b/frontend/src/layouts/dashboard/layout.js index 104db95..3dddca3 100644 --- a/frontend/src/layouts/dashboard/layout.js +++ b/frontend/src/layouts/dashboard/layout.js @@ -4,6 +4,8 @@ import { styled } from '@mui/material/styles'; import { withAuthGuard } from 'src/hocs/with-auth-guard'; import { SideNav } from './side-nav'; import { TopNav } from './top-nav'; +import { useAlertContext } from 'src/contexts/error-context'; +import { Alert, AlertTitle, Snackbar } from '@mui/material'; const SIDE_NAV_WIDTH = 280; @@ -28,6 +30,8 @@ export const Layout = withAuthGuard((props) => { const pathname = usePathname(); const [openNav, setOpenNav] = useState(false); + const {alert, setAlert} = useAlertContext(); + const handlePathnameChange = useCallback( () => { if (openNav) { @@ -57,6 +61,21 @@ export const Layout = withAuthGuard((props) => { {children} + {alert && setAlert(null)} + > + + {alert?.title && {alert.title}} + {alert?.message} + + } ); }); \ No newline at end of file