Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Elson9 committed Sep 19, 2024
2 parents d6e85bb + b95e4f5 commit 549d9a5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as React from 'react';
import { useToast } from '@chakra-ui/react';
import { useRouter } from 'next/router';

const GatewayToastHandler = () => {
const toast = useToast();
const router = useRouter();

React.useEffect(() => {
const handleRouteChange = () => {
const showToast = localStorage.getItem('showNoGatewayToast');
if (showToast === 'true') {
toast.closeAll();
toast({
title: `First select a Gateway to view that page`,
status: 'error',
isClosable: true,
duration: 5000,
});
localStorage.removeItem('showNoGatewayToast');
}
};

router.events.on('routeChangeComplete', handleRouteChange);

return () => {
router.events.off('routeChangeComplete', handleRouteChange);
};
}, [toast, router]);

return null;
};

export default GatewayToastHandler;
Empty file.
2 changes: 2 additions & 0 deletions src/nextapp/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import '@/shared/styles/global.css';
import { AppWrapper } from './context';
import '../../mocks';
import CompleteProfile from '@/components/complete-profile';
import GatewayToastHandler from '@/components/no-gateway-redirect/gateway-toast-handler';

const footerItems = [
{ href: 'http://www2.gov.bc.ca/gov/content/home', text: 'Home' },
Expand Down Expand Up @@ -114,6 +115,7 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
}}
>
<AppWrapper router={router}>
<GatewayToastHandler />
<Component {...pageProps} />
</AppWrapper>
</Box>
Expand Down

0 comments on commit 549d9a5

Please sign in to comment.