From 78836ac45b9c3109c741ca3f8883a324a8f88c86 Mon Sep 17 00:00:00 2001 From: Franco Chau Date: Thu, 25 Nov 2021 12:31:01 +0800 Subject: [PATCH 01/13] fix: banner child key props --- components/Banner/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Banner/index.tsx b/components/Banner/index.tsx index 2f462837..30b050c9 100644 --- a/components/Banner/index.tsx +++ b/components/Banner/index.tsx @@ -33,7 +33,7 @@ const Banner: React.FC = () => { }} > {banners.map((banner) => ( - + ))} From d802c6153cb4561923d382bcf7b63f792eea62df Mon Sep 17 00:00:00 2001 From: Franco Chau Date: Thu, 25 Nov 2021 12:31:12 +0800 Subject: [PATCH 02/13] fix: button styling --- components/DsmAirdrop/CheckAirdrop.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/DsmAirdrop/CheckAirdrop.tsx b/components/DsmAirdrop/CheckAirdrop.tsx index f2580c5b..71b09562 100644 --- a/components/DsmAirdrop/CheckAirdrop.tsx +++ b/components/DsmAirdrop/CheckAirdrop.tsx @@ -151,7 +151,7 @@ const CheckAirdrop: React.FC = ({ onConfirm, setSelectedAddre ) : null} {dataStakingInfo !== null && dataStakingInfo !== undefined ? (
- + diff --git a/components/DsmAirdrop/index.tsx b/components/DsmAirdrop/index.tsx index b4eadcc8..529c676e 100644 --- a/components/DsmAirdrop/index.tsx +++ b/components/DsmAirdrop/index.tsx @@ -70,6 +70,7 @@ const DsmAirdrop: React.FC = () => { ) const [totalDsmAllocated, setTotalDsmAllocated] = useState(0) + const [totalDsmAllocatedLoading, setTotalDsmAllocatedLoading] = useState(false) const [airdropResponse, setAirdropResponse] = useState('') const [claimSuccess, setClaimSuccess] = useState(false) @@ -91,6 +92,7 @@ const DsmAirdrop: React.FC = () => { useEffect(() => { if (chainConnections.length > 0) { + setTotalDsmAllocatedLoading(true) const axiosRequests = chainConnections.map((connection) => axios.get( `${process.env.NEXT_PUBLIC_DSM_AIRDROP_API_URL}/users/${connection.externalAddress}` @@ -109,10 +111,12 @@ const DsmAirdrop: React.FC = () => { .reduce((a, b) => a + b.dsm_allotted, 0) return setTotalDsmAllocated(totalDsmAllocated + chainClaimableAmount) }) + setTotalDsmAllocatedLoading(false) }) ) .catch((error) => { console.log(error) + setTotalDsmAllocatedLoading(false) }) } }, [chainConnections]) @@ -143,6 +147,7 @@ const DsmAirdrop: React.FC = () => { }} amount={totalDsmAllocated} chainConnections={chainConnections} + loading={totalDsmAllocatedLoading} /> ), } @@ -181,10 +186,8 @@ const DsmAirdrop: React.FC = () => { onConfirm={() => { if (!profile.dtag) { setStage(CommonStage.CreateProfileStage) - } else if (chainConnections.length === 0) { - setStage(CommonStage.ConnectChainsStage) } else { - setStage(CommonStage.ClaimableAmountStage) + setStage(CommonStage.ConnectChainsStage) } }} profile={profile} From f6a27ac8f0baa2bb8495a05842535218d9e63879 Mon Sep 17 00:00:00 2001 From: Franco Chau Date: Fri, 26 Nov 2021 03:02:53 +0800 Subject: [PATCH 04/13] fix: add loading when api error --- components/DsmAirdrop/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/DsmAirdrop/index.tsx b/components/DsmAirdrop/index.tsx index 529c676e..c906d4dc 100644 --- a/components/DsmAirdrop/index.tsx +++ b/components/DsmAirdrop/index.tsx @@ -116,7 +116,7 @@ const DsmAirdrop: React.FC = () => { ) .catch((error) => { console.log(error) - setTotalDsmAllocatedLoading(false) + // setTotalDsmAllocatedLoading(false) }) } }, [chainConnections]) From a35fe70af19aee23afc6d8508ab52a71bf703cfe Mon Sep 17 00:00:00 2001 From: Franco Chau Date: Fri, 26 Nov 2021 03:14:21 +0800 Subject: [PATCH 05/13] fix: duplicated loading --- components/DsmAirdrop/ClaimableAmount.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/DsmAirdrop/ClaimableAmount.tsx b/components/DsmAirdrop/ClaimableAmount.tsx index 46e050cb..60f8c308 100644 --- a/components/DsmAirdrop/ClaimableAmount.tsx +++ b/components/DsmAirdrop/ClaimableAmount.tsx @@ -25,13 +25,10 @@ const ClaimableAmount: React.FC = ({ const { currency } = useGeneralContext() const theme = useTheme() - const [loading, setLoading] = React.useState(false) - return ( { event.preventDefault() - setLoading(true) await onConfirm() }} > From ce1cf5035d5cd279dd393a81b4e5952860dd2751 Mon Sep 17 00:00:00 2001 From: Franco Chau Date: Fri, 26 Nov 2021 03:19:35 +0800 Subject: [PATCH 06/13] fix: add on claim loading back --- components/DsmAirdrop/ClaimableAmount.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/DsmAirdrop/ClaimableAmount.tsx b/components/DsmAirdrop/ClaimableAmount.tsx index 60f8c308..31967893 100644 --- a/components/DsmAirdrop/ClaimableAmount.tsx +++ b/components/DsmAirdrop/ClaimableAmount.tsx @@ -25,10 +25,13 @@ const ClaimableAmount: React.FC = ({ const { currency } = useGeneralContext() const theme = useTheme() + const [onClaimLoading, setOnClaimLoading] = React.useState(false) + return ( { event.preventDefault() + setOnClaimLoading(true) await onConfirm() }} > @@ -46,7 +49,7 @@ const ClaimableAmount: React.FC = ({ type="submit" // disabled={amount <= 0} > - {loading ? : t('claim now')} + {onClaimLoading ? : t('claim now')}