Skip to content

Commit

Permalink
[C-4401] Fix reward in cooldown button (#8537)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsolo authored May 20, 2024
1 parent 284df24 commit 60ff81e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ export const ChallengeRewardsDrawerContent = ({
)
: messages.incomplete

const claimedAmountText = `(${formatNumberCommas(claimedAmount)} ${
messages.claimedLabel
})`
const claimableAmountText = `${formatNumberCommas(claimableAmount)} ${
messages.claimableLabel
}`
Expand Down Expand Up @@ -213,7 +210,6 @@ export const ChallengeRewardsDrawerContent = ({
</Text>
</View>
</View>
{children}
<View style={styles.claimRewardsContainer}>
{isClaimable && onClaim ? (
isCooldownChallenge && isRewardsCooldownEnabled ? (
Expand Down Expand Up @@ -241,18 +237,9 @@ export const ChallengeRewardsDrawerContent = ({
</>
)
) : null}
{claimedAmount > 0 && challengeState !== 'disbursed' ? (
<Text
variant='label'
color='subdued'
textAlign='center'
strength='strong'
>
{claimedAmountText}
</Text>
) : null}
{claimError ? <ClaimError aaoErrorCode={aaoErrorCode} /> : null}
</View>
{children}
</ScrollView>
{isClaimable &&
onClaim &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ export const ChallengeRewardsDrawerProvider = () => {
if (challenge?.challenge_type === 'aggregate') {
audioToClaim = challenge.claimableAmount
audioClaimedSoFar = challenge.disbursed_amount
} else if (challenge?.state === 'completed') {
} else if (challenge?.state === 'completed' && challenge?.cooldown_days) {
audioToClaim = challenge.claimableAmount
} else if (challenge?.state === 'completed' && !challenge?.cooldown_days) {
audioToClaim = challenge.totalAmount
audioClaimedSoFar = 0
} else if (challenge?.state === 'disbursed') {
audioToClaim = 0
audioClaimedSoFar = challenge.totalAmount
}

Expand Down Expand Up @@ -143,7 +143,7 @@ export const ChallengeRewardsDrawerProvider = () => {

// Challenge drawer contents
let contents: Maybe<React.ReactElement>
if (challenge?.state && challenge?.state !== 'completed') {
if (!audioToClaim) {
switch (modalType) {
case 'referrals':
case 'ref-v':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const useStyles = makeStyles(({ palette, spacing, typography }) => ({
width: '100%'
},
claimRewardsContainer: {
marginTop: spacing(4),
marginVertical: spacing(4),
width: '100%'
},
claimRewardsError: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ const ChallengeRewardsBody = ({ dismissModal }: BodyProps) => {
if (challenge?.challenge_type === 'aggregate') {
audioToClaim = challenge.claimableAmount
audioClaimedSoFar = challenge.disbursed_amount
} else if (challenge?.state === 'completed') {
} else if (challenge?.state === 'completed' && challenge?.cooldown_days) {
audioToClaim = challenge.claimableAmount
} else if (challenge?.state === 'completed' && !challenge?.cooldown_days) {
audioToClaim = challenge.totalAmount
audioClaimedSoFar = 0
} else if (challenge?.state === 'disbursed') {
audioToClaim = 0
audioClaimedSoFar = challenge.totalAmount
}

Expand Down Expand Up @@ -563,7 +563,7 @@ const ChallengeRewardsBody = ({ dismissModal }: BodyProps) => {
)}
{renderReferralContent()}
{renderMobileInstallContent()}
{buttonLink && challenge?.state !== 'completed' ? (
{buttonLink && !audioToClaim ? (
<Button
variant='primary'
fullWidth={isMobile}
Expand Down

0 comments on commit 60ff81e

Please sign in to comment.