From bc9c1fe46367646056e99cc2610cb33c231428df Mon Sep 17 00:00:00 2001 From: corlard3y Date: Wed, 10 Jul 2024 09:58:30 +0100 Subject: [PATCH 1/3] add reject modal icon --- .../chat/unlockProfile/UnlockProfile.tsx | 4 +- .../unlockProfile/UnlockProfileWrapper.tsx | 6 +- src/modules/rewards/Rewards.tsx | 4 +- .../components/ActivityVerificationButton.tsx | 63 ++++++++----------- .../components/RewardsActivitiesList.tsx | 1 + src/modules/rewards/hooks/useRewardsAuth.tsx | 12 ++++ .../rewards/hooks/useWithAuthButton.tsx | 12 +++- 7 files changed, 58 insertions(+), 44 deletions(-) diff --git a/src/components/chat/unlockProfile/UnlockProfile.tsx b/src/components/chat/unlockProfile/UnlockProfile.tsx index ef8d3dd221..5bf92b13a6 100644 --- a/src/components/chat/unlockProfile/UnlockProfile.tsx +++ b/src/components/chat/unlockProfile/UnlockProfile.tsx @@ -112,8 +112,8 @@ const UnlockProfile = ({ InnerComponentProps, onClose }: UnlockProfileModalProps } diff --git a/src/components/chat/unlockProfile/UnlockProfileWrapper.tsx b/src/components/chat/unlockProfile/UnlockProfileWrapper.tsx index b94e61741e..4d5abc0b7c 100644 --- a/src/components/chat/unlockProfile/UnlockProfileWrapper.tsx +++ b/src/components/chat/unlockProfile/UnlockProfileWrapper.tsx @@ -13,7 +13,7 @@ interface IntroContainerProps { type?: UNLOCK_PROFILE_TYPE; showConnectModal?: boolean; description?: string; - onClose?: () => void; + handleClose?: () => void; closeIcon?: boolean; } @@ -25,7 +25,7 @@ const UnlockProfileWrapper = ({ type = DEFAULT_PROPS.type, showConnectModal, description, - onClose, + handleClose, closeIcon, }: IntroContainerProps) => { const { @@ -38,7 +38,7 @@ const UnlockProfileWrapper = ({ if (type === UNLOCK_PROFILE_TYPE.MODAL && showConnectModal) { showProfileModal(); } - }, [type]); + }, [type, showConnectModal]); if (type === UNLOCK_PROFILE_TYPE.MODAL) { return ( diff --git a/src/modules/rewards/Rewards.tsx b/src/modules/rewards/Rewards.tsx index 39a0090fbc..eba782dbab 100644 --- a/src/modules/rewards/Rewards.tsx +++ b/src/modules/rewards/Rewards.tsx @@ -49,7 +49,7 @@ const Rewards: FC = () => { const { activeTab, handleSetActiveTab } = useRewardsTabs(); - const { showConnectModal, setShowConnectModal, status, connectUserWallet } = useRewardsAuth(); + const { showConnectModal, setShowConnectModal, status, connectUserWallet, toggleModalOff } = useRewardsAuth(); useCreateRewardsUser(); @@ -115,6 +115,8 @@ const Rewards: FC = () => { toggleModalOff()} + closeIcon={true} description="Unlock your profile to proceed." /> diff --git a/src/modules/rewards/components/ActivityVerificationButton.tsx b/src/modules/rewards/components/ActivityVerificationButton.tsx index 5e8829e57d..6b70a86b99 100644 --- a/src/modules/rewards/components/ActivityVerificationButton.tsx +++ b/src/modules/rewards/components/ActivityVerificationButton.tsx @@ -18,7 +18,6 @@ import { UserStoreType } from 'types'; // components import { Box, Button } from 'blocks'; import UnlockProfileWrapper, { UNLOCK_PROFILE_TYPE } from 'components/chat/unlockProfile/UnlockProfileWrapper'; -import { useRewardsAuth } from '../hooks/useRewardsAuth'; type ActivityVerificationButtonProps = { userId: string; @@ -38,8 +37,6 @@ export const ActivityVerificationButton = ({ const { isWalletConnected } = useAccount(); const { userPushSDKInstance } = useSelector((state: UserStoreType) => state.user); - // const { setShowConnectModal } = useRewardsAuth(); - const { handleTwitterVerification } = useVerifyTwitter({ activityTypeId, refetchActivity, @@ -70,42 +67,10 @@ export const ActivityVerificationButton = ({ } }, [activityType, userPushSDKInstance]); - const { isAuthenticated, authButton, showConnectModal, setShowConnectModal } = useAuthWithButton({ + const { isAuthenticated, authButton, showConnectModal, toggleModalOff } = useAuthWithButton({ onSuccess: (userDetails) => activityData?.action(userDetails?.userId), }); - const handleCloseModal = () => { - setShowConnectModal(false); - }; - - console.log('Modal closed'); - console.log('isAuthenticated:', isAuthenticated); - console.log('isWalletConnected:', isWalletConnected); - console.log('showConnectModal:', showConnectModal); - - if (userPushSDKInstance && userPushSDKInstance?.readmode() && showConnectModal) { - return ( - - - - ); - } - if (isAuthenticated && isWalletConnected && !userPushSDKInstance?.readmode()) { return ( ), - [isWalletConnected, showConnectModal] + [isWalletConnected, isAuthModalVisible] ); return { authButton, isAuthenticated: isWalletConnectedAndProfileUnlocked, - showConnectModal: showConnectModal, - setShowConnectModal: setShowConnectModal, - toggleModalOff: toggleModalOff, - toggleModalOn: toggleModalOn, + isAuthModalVisible, + hideAuthModal, }; }; From 6bafa251790b4f837b2b2a13358d48e9881b83af Mon Sep 17 00:00:00 2001 From: corlard3y Date: Wed, 10 Jul 2024 10:35:09 +0100 Subject: [PATCH 3/3] fix additional comments --- src/modules/rewards/Rewards.tsx | 4 ++-- src/modules/rewards/hooks/useRewardsAuth.tsx | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/modules/rewards/Rewards.tsx b/src/modules/rewards/Rewards.tsx index f6d55c602e..b467ebe19b 100644 --- a/src/modules/rewards/Rewards.tsx +++ b/src/modules/rewards/Rewards.tsx @@ -49,7 +49,7 @@ const Rewards: FC = () => { const { activeTab, handleSetActiveTab } = useRewardsTabs(); - const { isAuthModalVisible, setIsAuthModalVisible, status, connectUserWallet, hideAuthModal } = useRewardsAuth(); + const { isAuthModalVisible, status, connectUserWallet, hideAuthModal } = useRewardsAuth(); useCreateRewardsUser(); @@ -58,7 +58,7 @@ const Rewards: FC = () => { useEffect(() => { if (isErrorPresent && isAuthModalVisible && status === 'error' && errorExists && activeTab === 'dashboard') { setHasError(isErrorPresent); - setIsAuthModalVisible(false); + hideAuthModal(); } }, [isErrorPresent, isAuthModalVisible, errorExists]); diff --git a/src/modules/rewards/hooks/useRewardsAuth.tsx b/src/modules/rewards/hooks/useRewardsAuth.tsx index ab60df62b8..5a6a05a859 100644 --- a/src/modules/rewards/hooks/useRewardsAuth.tsx +++ b/src/modules/rewards/hooks/useRewardsAuth.tsx @@ -124,17 +124,12 @@ const useRewardsAuth = () => { }, [status, isVerifyClicked, isDashClicked]); return { - caip10WalletAddress, status, - unlockProfile, isAuthModalVisible, - setIsAuthModalVisible, connectWallet, handleVerify, userDetails, - isVerifyClicked, connectUserWallet, - isDashClicked, hideAuthModal, showAuthModal, };