From dda668f3e966f15dcf2e150c6a9824eab52e00e1 Mon Sep 17 00:00:00 2001 From: srikanth716 Date: Mon, 18 Nov 2024 14:46:32 +0530 Subject: [PATCH] [INJIVER-387] fix offline screen rendering Signed-off-by: srikanth716 --- ui/src/components/SomethingWentWrong/index.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/src/components/SomethingWentWrong/index.tsx b/ui/src/components/SomethingWentWrong/index.tsx index dce9b188..bb0775c1 100644 --- a/ui/src/components/SomethingWentWrong/index.tsx +++ b/ui/src/components/SomethingWentWrong/index.tsx @@ -1,15 +1,31 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import StyledButton from "../Home/VerificationSection/commons/StyledButton"; import {useNavigate} from "react-router-dom"; import {useAppDispatch} from "../../redux/hooks"; import {updateInternetConnectionStatus} from "../../redux/features/application-state/application-state.slice"; import { ReactComponent as UnderConstruction } from "../../assets/images/under-construction.svg"; import { useTranslation } from 'react-i18next'; +import { checkInternetStatus } from '../../utils/misc'; function SomethingWentWrong(props: any) { const navigate = useNavigate(); const dispatch = useAppDispatch(); const {t} = useTranslation('Offline') + useEffect(() => { + async function fetchIsOnline() { + let isOnline = await checkInternetStatus(); + dispatch( + updateInternetConnectionStatus({ + internetConnectionStatus: isOnline ? "ONLINE" : "OFFLINE", + }) + ); + if (isOnline) { + navigate("/"); + } + } + fetchIsOnline(); + + }, [dispatch, navigate]); return (