diff --git a/client/i18n/locales/english/translations.json b/client/i18n/locales/english/translations.json
index afee76b2d58..3ec36079106 100644
--- a/client/i18n/locales/english/translations.json
+++ b/client/i18n/locales/english/translations.json
@@ -463,7 +463,8 @@
"iframe-preview": "{{title}} preview",
"iframe-alert": "Normally this link would bring you to another website! It works. This is a link to: {{externalLink}}",
"iframe-form-submit-alert": "Normally this form would be submitted! It works. This will be submitted to: {{externalLink}}",
- "document-notfound": "document not found"
+ "document-notfound": "document not found",
+ "slow-load-msg": "Looks like this is taking longer than usual, please try refreshing the page."
},
"icons": {
"gold-cup": "Gold Cup",
diff --git a/client/src/components/helpers/__snapshots__/loader.test.tsx.snap b/client/src/components/helpers/__snapshots__/loader.test.tsx.snap
index 6dab24a5651..d754d42ea67 100644
--- a/client/src/components/helpers/__snapshots__/loader.test.tsx.snap
+++ b/client/src/components/helpers/__snapshots__/loader.test.tsx.snap
@@ -14,6 +14,12 @@ exports[`
+ misc.slow-load-msg +
`; diff --git a/client/src/components/helpers/loader.css b/client/src/components/helpers/loader.css index 5acf705bd85..2182772d777 100644 --- a/client/src/components/helpers/loader.css +++ b/client/src/components/helpers/loader.css @@ -2,8 +2,10 @@ height: 100%; width: 100%; display: flex; + flex-direction: column; justify-content: center; align-items: center; + gap: 1em; } .fcc-loader .sk-spinner, diff --git a/client/src/components/helpers/loader.tsx b/client/src/components/helpers/loader.tsx index 9e5aa9b2aa4..dd265c19e56 100644 --- a/client/src/components/helpers/loader.tsx +++ b/client/src/components/helpers/loader.tsx @@ -1,27 +1,49 @@ import React, { useState, useEffect } from 'react'; +import { useTranslation } from 'react-i18next'; import Spinner from 'react-spinkit'; import './loader.css'; interface LoaderProps { fullScreen?: boolean; - timeout?: number; + loaderDelay?: number; + messageDelay?: number; } -function Loader({ fullScreen, timeout }: LoaderProps): JSX.Element { - const [showSpinner, setShowSpinner] = useState(!timeout); +function Loader({ + fullScreen, + loaderDelay, + messageDelay +}: LoaderProps): JSX.Element { + const { t } = useTranslation(); + + const [showSpinner, setShowSpinner] = useState(!loaderDelay); + const [showMessage, setShowMessage] = useState(!messageDelay); useEffect(() => { - let timerId: ReturnType{t('misc.slow-load-msg')}
+ > + )}