diff --git a/src/components/modals/SanctionedModal.tsx b/src/components/modals/SanctionedModal.tsx index da8ccdbcb9..0bd4a9a169 100644 --- a/src/components/modals/SanctionedModal.tsx +++ b/src/components/modals/SanctionedModal.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { brandColors, Button, @@ -21,12 +21,26 @@ interface SanctionModalProps { export const SanctionModal: React.FC = ({ closeModal }) => { const { formatMessage } = useIntl(); + const [isRedirecting, setIsRedirecting] = useState(false); const router = useRouter(); const navigateToAllProjects = () => { + setIsRedirecting(true); router.push(Routes.AllProjects); - closeModal(); }; + useEffect(() => { + const handleRouteChangeComplete = () => { + closeModal(); + setIsRedirecting(false); + }; + if(isRedirecting) { + router.events.on('routeChangeComplete', handleRouteChangeComplete); + } + return () => { + router.events.off('routeChangeComplete', handleRouteChangeComplete); + }; + }, [isRedirecting]); + return (