Skip to content

Commit 549d9a5

Browse files
committed
Resolve merge conflicts
2 parents d6e85bb + b95e4f5 commit 549d9a5

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import * as React from 'react';
2+
import { useToast } from '@chakra-ui/react';
3+
import { useRouter } from 'next/router';
4+
5+
const GatewayToastHandler = () => {
6+
const toast = useToast();
7+
const router = useRouter();
8+
9+
React.useEffect(() => {
10+
const handleRouteChange = () => {
11+
const showToast = localStorage.getItem('showNoGatewayToast');
12+
if (showToast === 'true') {
13+
toast.closeAll();
14+
toast({
15+
title: `First select a Gateway to view that page`,
16+
status: 'error',
17+
isClosable: true,
18+
duration: 5000,
19+
});
20+
localStorage.removeItem('showNoGatewayToast');
21+
}
22+
};
23+
24+
router.events.on('routeChangeComplete', handleRouteChange);
25+
26+
return () => {
27+
router.events.off('routeChangeComplete', handleRouteChange);
28+
};
29+
}, [toast, router]);
30+
31+
return null;
32+
};
33+
34+
export default GatewayToastHandler;

src/nextapp/components/no-gateway-redirect/no-gateway-redirect.tsx

Whitespace-only changes.

src/nextapp/pages/_app.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import '@/shared/styles/global.css';
3131
import { AppWrapper } from './context';
3232
import '../../mocks';
3333
import CompleteProfile from '@/components/complete-profile';
34+
import GatewayToastHandler from '@/components/no-gateway-redirect/gateway-toast-handler';
3435

3536
const footerItems = [
3637
{ href: 'http://www2.gov.bc.ca/gov/content/home', text: 'Home' },
@@ -114,6 +115,7 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
114115
}}
115116
>
116117
<AppWrapper router={router}>
118+
<GatewayToastHandler />
117119
<Component {...pageProps} />
118120
</AppWrapper>
119121
</Box>

0 commit comments

Comments
 (0)