From a78b0720396b6b35634c9db7125bbc608da506fe Mon Sep 17 00:00:00 2001 From: BaskarMitrah <113968869+BaskarMitrah@users.noreply.github.com> Date: Tue, 23 Apr 2024 03:35:49 +0200 Subject: [PATCH] build : Fixed the page load issues in the get credential component (#1574) --- .../GetCredential/CredentialForm.js | 28 +++++++++++++++---- .../src/components/GetCredential/Loading.js | 14 ++++++---- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/packages/gatsby-theme-aio/src/components/GetCredential/CredentialForm.js b/packages/gatsby-theme-aio/src/components/GetCredential/CredentialForm.js index 4cb17d01ab..b902d767d5 100644 --- a/packages/gatsby-theme-aio/src/components/GetCredential/CredentialForm.js +++ b/packages/gatsby-theme-aio/src/components/GetCredential/CredentialForm.js @@ -18,7 +18,7 @@ const credentialNameRegex = /^(?=[A-Za-z0-9\s]{6,}$)[A-Za-z0-9\s]*$/; const CredentialForm = ({ formProps, credentialType, service }) => { - const [loading, setLoading] = useState(false); + const [loading, setLoading] = useState(true); const [isError, setIsError] = useState(false); const [response, setResponse] = useState({}); const [errResp, setErrorResp] = useState(""); @@ -84,6 +84,17 @@ const CredentialForm = ({ formProps, credentialType, service }) => { } + useEffect(() => { + if (window.adobeIMS?.isSignedInUser()) { + setTimeout(()=>{ + setLoading(false) + },1000) + } + else { + setLoading(true) + } + }, [window.adobeIMS?.isSignedInUser()]) + useEffect(() => { setTimeout(() => { setOrganization(false); @@ -111,10 +122,15 @@ const CredentialForm = ({ formProps, credentialType, service }) => { if (!organization) { setOrganizationValue(undefined); setShowCreateForm(false); - setIsError(true) + setLoading(true); } else if (organization && Object.keys(organization)?.length !== 0) { setShowCreateForm(true) + setIsError(true) + setTimeout(() => { + setLoading(false) + setIsError(false) + }, 2000) } else { if (Object.keys(organization)?.length === 0) { @@ -378,7 +394,7 @@ const CredentialForm = ({ formProps, credentialType, service }) => { } } - {loading && !showCredential && } + {loading && !showCredential && !isError && !showCreateForm && organization && } {modalOpen && ( { setOrganizationValue={setOrganizationValue} /> )} - {isError && !showCreateForm && !showCredential && } + {(!organization || isError) && loading && } + {isError && !showCreateForm && !showCredential && !organization && } {showCredential && !showCreateForm && } {redirectToBeta && } - {!showCreateForm && !organization && !isError && } - + {!showCreateForm && !organization && !isError && !loading && } ) } diff --git a/packages/gatsby-theme-aio/src/components/GetCredential/Loading.js b/packages/gatsby-theme-aio/src/components/GetCredential/Loading.js index 276a3e3841..399738eee7 100644 --- a/packages/gatsby-theme-aio/src/components/GetCredential/Loading.js +++ b/packages/gatsby-theme-aio/src/components/GetCredential/Loading.js @@ -1,13 +1,14 @@ -import React, {useEffect, useRef} from 'react'; +import React, { useEffect, useRef } from 'react'; import { css } from "@emotion/react"; const Loading = ({ credentials, - downloadStatus + downloadStatus, + isCreateCredential }) => { const divRef = useRef(null); - useEffect(() =>{ - if(divRef.current){ + useEffect(() => { + if (divRef.current) { divRef.current.scrollIntoView({ behavior: 'smooth', block: 'center', @@ -15,9 +16,10 @@ const Loading = ({ }); } }, []) + return ( <> - {credentials?.heading &&

{credentials?.heading}

} + {credentials?.title &&

{credentials?.title}

}
- Creating credentials... + {isCreateCredential && "Creating credentials..."}
{downloadStatus &&