From 90b28b201a790d6b0c04fb5be5a407ba3a747345 Mon Sep 17 00:00:00 2001 From: nael Date: Wed, 31 Jan 2024 10:42:26 +0100 Subject: [PATCH] :bug: Fix loading --- apps/embedded-catalog/react/src/lib/index.tsx | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/apps/embedded-catalog/react/src/lib/index.tsx b/apps/embedded-catalog/react/src/lib/index.tsx index e202975be..288345840 100644 --- a/apps/embedded-catalog/react/src/lib/index.tsx +++ b/apps/embedded-catalog/react/src/lib/index.tsx @@ -1,9 +1,10 @@ import config from '@/helpers/config'; -import { getDescription } from '@/helpers/utils'; +import { getDescription } from '@/helpers/utils'; import useLinkedUserMutation from '@/hooks/mutations/useLinkedUserMutation'; import useLinkedUser from '@/hooks/queries/useLinkedUserId'; import useOAuth from '@/hooks/useOAuth'; import { useEffect, useState } from 'react'; +import { TailSpin } from 'react-loader-spinner' interface RemoteUserInfo { @@ -20,7 +21,8 @@ interface ProviderCardProp { const ProviderCard = ({name, projectId, linkedUserIdOrRemoteUserInfo}: ProviderCardProp) => { const [providerClicked, setProviderClicked] = useState(false); const [originId, setOriginId] = useState("") - + const [loading, setLoading] = useState(false) + const { mutate } = useLinkedUserMutation(); const {data: linkedUser} = useLinkedUser(originId); @@ -49,40 +51,67 @@ const ProviderCard = ({name, projectId, linkedUserIdOrRemoteUserInfo}: ProviderC }); const onWindowClose = () => { + setLoading(false); + return; } useEffect(() => { - if (providerClicked && isReady) { + if (loading && providerClicked && isReady) { open(onWindowClose); + return; } - }, [providerClicked, isReady, open]); + }, [providerClicked, isReady, open, loading]); const handleClick = () => { + setLoading(true); setProviderClicked(true); + return; }; return (
+
- + -
Integrate with {name}
+
Integrate with {name}
+ {!loading ? + <>

{getDescription(name.toLowerCase())}

- Integrate in one click + Connect in one click + + : + <> +

Continue in {name}

+
+ +
+ + + }
) };