From b71590267237e6dde0ab2e5438f0e6ba80fc0338 Mon Sep 17 00:00:00 2001 From: Aaron Pepper Date: Fri, 27 Dec 2024 13:20:57 +0100 Subject: [PATCH] finish copy referral code setup ui --- public/locales/en/airdrop.json | 6 +- .../hooks/useAirdropAuth.ts | 6 +- .../sections/LoggedOut/LoggedOut.tsx | 60 +------- src/containers/phase/Setup/Setup.styles.ts | 2 +- src/containers/phase/Setup/Setup.tsx | 7 - .../components/AirdropLogin/AirdropLogin.tsx | 17 ++- .../Setup/components/AirdropLogin/styles.ts | 10 +- .../AirdropPermission/AirdropPermission.tsx | 8 +- .../components/AirdropShare/AirdropShare.tsx | 75 +++++++-- .../Setup/components/AirdropShare/styles.ts | 144 +++++++++++++++++- .../phase/Setup/components/Footer.tsx | 23 ++- 11 files changed, 262 insertions(+), 96 deletions(-) diff --git a/public/locales/en/airdrop.json b/public/locales/en/airdrop.json index b9f3f4804..da7c25562 100644 --- a/public/locales/en/airdrop.json +++ b/public/locales/en/airdrop.json @@ -9,7 +9,6 @@ "claimModalTitle": "EARN REWARDS FOR MINING ON TESTNET", "claimReferralCode": "Claim your referral code {{gems}} gems.", "claimReferralGifts": "Claim your referral code and earn {{gems}} gems. Once you connect your account, you’ll be awarded your gems.", - "claimSetlupText": "Earn gems while mining to increase your airdrop reward during testnet! Connect your airdrop account to start earning.", "doLater": "I'll do this later", "giftReferralCode": "Earn {{gems}} gems for each friend you invite to Tari Universe. Once they connect their account, you’ll be awarded your gems.", "giftReferralCodeHeader": "Claim your referral code {{gems}} gems.", @@ -36,5 +35,8 @@ "topTooltipTitle": "Testnet Rewards", "unclaimedGems": "Unclaimed Gems", "you-reached-your-giftinh-goal": "You reached your gifting goal!", - "your-friend-accepted-gift": "One of your friends accepted your gift!" + "your-friend-accepted-gift": "One of your friends accepted your gift!", + "setupLoginText": "Earn gems while mining to increase your airdrop reward during testnet! Connect your airdrop account to start earning.", + "setupInviteTitle": "invite friends & earn {{gems}} Gems", + "setupCopyButton": "Copy" } \ No newline at end of file diff --git a/src/containers/main/Airdrop/AirdropGiftTracker/hooks/useAirdropAuth.ts b/src/containers/main/Airdrop/AirdropGiftTracker/hooks/useAirdropAuth.ts index c1678ec02..d5595af08 100644 --- a/src/containers/main/Airdrop/AirdropGiftTracker/hooks/useAirdropAuth.ts +++ b/src/containers/main/Airdrop/AirdropGiftTracker/hooks/useAirdropAuth.ts @@ -18,7 +18,8 @@ export const useAirdropAuth = () => { ); } }, - [backendInMemoryConfig?.airdropTwitterAuthUrl, setAuthUuid] + // eslint-disable-next-line react-hooks/exhaustive-deps + [backendInMemoryConfig?.airdropTwitterAuthUrl] ); const checkAuth = useCallback(() => { @@ -54,7 +55,8 @@ export const useAirdropAuth = () => { clearTimeout(timeout); }; } - }, [authUuid, backendInMemoryConfig?.airdropApiUrl, restartMining, setAirdropTokens, setAuthUuid]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [authUuid, backendInMemoryConfig?.airdropApiUrl]); return { handleAuth, checkAuth }; }; diff --git a/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx b/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx index 0b9f6ee8c..7daec9e25 100644 --- a/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx +++ b/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx @@ -1,69 +1,21 @@ import { GIFT_GEMS, useAirdropStore } from '@app/store/useAirdropStore'; import { ClaimButton, GemPill, Image, Title, Wrapper } from './styles'; -import { useCallback, useEffect, useState } from 'react'; -import { open } from '@tauri-apps/plugin-shell'; -import { v4 as uuidv4 } from 'uuid'; +import { useEffect, useState } from 'react'; import ClaimModal from '../../components/ClaimModal/ClaimModal'; import { useTranslation } from 'react-i18next'; import gemImage from '../../images/gem.png'; -import { useMiningStore } from '@app/store/useMiningStore'; +import { useAirdropAuth } from '../../hooks/useAirdropAuth'; export default function LoggedOut() { const [modalIsOpen, setModalIsOpen] = useState(false); const { t } = useTranslation(['airdrop'], { useSuspense: false }); - const restartMining = useMiningStore((s) => s.restartMining); - const { referralQuestPoints, authUuid, setAuthUuid, setAirdropTokens, setUserPoints, backendInMemoryConfig } = - useAirdropStore(); + const { referralQuestPoints } = useAirdropStore(); - const handleAuth = useCallback( - (code?: string) => { - const token = uuidv4(); - if (backendInMemoryConfig?.airdropTwitterAuthUrl) { - setAuthUuid(token); - open( - `${backendInMemoryConfig?.airdropTwitterAuthUrl}?tauri=${token}${code ? `&universeReferral=${code}` : ''}` - ); - } - }, - // eslint-disable-next-line react-hooks/exhaustive-deps - [backendInMemoryConfig?.airdropTwitterAuthUrl] - ); + const { handleAuth, checkAuth } = useAirdropAuth(); useEffect(() => { - if (authUuid && backendInMemoryConfig?.airdropApiUrl) { - const interval = setInterval(() => { - if (authUuid) { - fetch(`${backendInMemoryConfig?.airdropApiUrl}/auth/twitter/get-token/${authUuid}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - }) - .then((response) => response.json()) - .then((data) => { - if (!data.error) { - clearInterval(interval); - setAirdropTokens(data); - restartMining(); - } - }); - } - }, 1000); - const timeout = setTimeout( - () => { - clearInterval(interval); - setAuthUuid(''); - }, - 1000 * 60 * 5 - ); - - return () => { - clearInterval(interval); - clearTimeout(timeout); - }; - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [authUuid, backendInMemoryConfig?.airdropApiUrl]); + checkAuth(); + }, [checkAuth]); const gemsValue = (referralQuestPoints?.pointsForClaimingReferral || GIFT_GEMS).toLocaleString(); diff --git a/src/containers/phase/Setup/Setup.styles.ts b/src/containers/phase/Setup/Setup.styles.ts index e9376ba62..09cb0df66 100644 --- a/src/containers/phase/Setup/Setup.styles.ts +++ b/src/containers/phase/Setup/Setup.styles.ts @@ -4,7 +4,7 @@ export const SetupWrapper = styled.div<{ $bg?: string }>` position: fixed; top: 0; left: 0; - z-index: 1; + z-index: 3; width: 100%; height: 100%; diff --git a/src/containers/phase/Setup/Setup.tsx b/src/containers/phase/Setup/Setup.tsx index 901c41d17..419624dd0 100644 --- a/src/containers/phase/Setup/Setup.tsx +++ b/src/containers/phase/Setup/Setup.tsx @@ -4,19 +4,12 @@ import HeroText from './components/HeroText'; import InfoNav from './components/InfoNav/InfoNav'; import { SetupWrapper } from '@app/containers/phase/Setup/Setup.styles'; import grain from '/assets/img/grain.png'; -import AirdropLogin from './components/AirdropLogin/AirdropLogin'; -import { useAirdropStore } from '@app/store/useAirdropStore'; -import AirdropShare from './components/AirdropShare/AirdropShare'; export default function Setup() { useSetUp(); - const { airdropTokens } = useAirdropStore(); - const isLoggedIn = !!airdropTokens; - return ( - {isLoggedIn ? : }