From f847dbdb555a455c68e9b84bc33ffdac0a095b8b Mon Sep 17 00:00:00 2001 From: isaac Date: Mon, 6 May 2024 12:20:47 -0700 Subject: [PATCH 1/3] Fix progress label formatting --- .../ChallengeRewardsTile.tsx | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx b/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx index 67e03d10de8..b5397a22e4d 100644 --- a/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx +++ b/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx @@ -99,6 +99,18 @@ const messages = { } } +const formatProgressLabel = ( + label?: string, + current?: number, + max?: number +) => { + return fillString( + label ?? '', + formatNumberCommas(current?.toString() ?? ''), + formatNumberCommas(max?.toString() ?? '') + ) +} + type RewardPanelProps = { title: string icon: ReactNode @@ -147,45 +159,32 @@ const RewardPanel = ({ isAudioMatchingChallenge(id) && !needsDisbursement let progressLabelFilled: string + if (challenge?.challenge_id === 'track-upload') { + console.log('asdf challenge: ', challenge) + } if (shouldShowCompleted) { progressLabelFilled = messages.completeLabel - } else if (challenge && challenge?.cooldown_days > 0) { - if (needsDisbursement) { - progressLabelFilled = messages.readyToClaim - } else if (pending) { - progressLabelFilled = messages.pendingRewards - } else if (challenge?.challenge_type === 'aggregate') { - // Count down - progressLabelFilled = fillString( - remainingLabel ?? '', - formatNumberCommas( - (challenge?.max_steps - challenge?.current_step_count)?.toString() ?? - '' - ), - formatNumberCommas(challenge?.max_steps?.toString() ?? '') - ) - } else { - progressLabelFilled = progressLabel ?? '' - } + } else if (needsDisbursement) { + progressLabelFilled = messages.readyToClaim + } else if (pending) { + progressLabelFilled = messages.pendingRewards } else if (challenge?.challenge_type === 'aggregate') { // Count down - progressLabelFilled = fillString( + progressLabelFilled = formatProgressLabel( remainingLabel ?? '', - formatNumberCommas( - (challenge?.max_steps - challenge?.current_step_count)?.toString() ?? '' - ), - formatNumberCommas(challenge?.max_steps?.toString() ?? '') + challenge?.max_steps - challenge?.current_step_count, + challenge.max_steps + ) + } else if (progressLabel?.includes('%')) { + progressLabelFilled = formatProgressLabel( + progressLabel, + challenge?.current_step_count, + challenge?.max_steps ) } else { - // Count up - progressLabelFilled = progressLabel - ? fillString( - progressLabel, - formatNumberCommas(challenge?.current_step_count?.toString() ?? ''), - formatNumberCommas(challenge?.max_steps?.toString() ?? '') - ) - : '' + progressLabelFilled = progressLabel ?? '' } + const buttonMessage = needsDisbursement ? messages.claimReward : hasDisbursed From 5d6574b031555a5630f7a1a4e18ea530393a2ca4 Mon Sep 17 00:00:00 2001 From: isaac Date: Mon, 6 May 2024 12:41:47 -0700 Subject: [PATCH 2/3] clean --- .../web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx b/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx index b5397a22e4d..a69623b2bc5 100644 --- a/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx +++ b/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx @@ -159,9 +159,6 @@ const RewardPanel = ({ isAudioMatchingChallenge(id) && !needsDisbursement let progressLabelFilled: string - if (challenge?.challenge_id === 'track-upload') { - console.log('asdf challenge: ', challenge) - } if (shouldShowCompleted) { progressLabelFilled = messages.completeLabel } else if (needsDisbursement) { From c357d9cd9fdb2513e6388fdb0ccc461be10751fd Mon Sep 17 00:00:00 2001 From: isaac Date: Mon, 6 May 2024 13:34:00 -0700 Subject: [PATCH 3/3] minimal changes --- .../ChallengeRewardsTile.tsx | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx b/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx index a69623b2bc5..3e91e9bfd3c 100644 --- a/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx +++ b/packages/web/src/pages/audio-rewards-page/ChallengeRewardsTile.tsx @@ -99,18 +99,6 @@ const messages = { } } -const formatProgressLabel = ( - label?: string, - current?: number, - max?: number -) => { - return fillString( - label ?? '', - formatNumberCommas(current?.toString() ?? ''), - formatNumberCommas(max?.toString() ?? '') - ) -} - type RewardPanelProps = { title: string icon: ReactNode @@ -161,27 +149,45 @@ const RewardPanel = ({ let progressLabelFilled: string if (shouldShowCompleted) { progressLabelFilled = messages.completeLabel - } else if (needsDisbursement) { - progressLabelFilled = messages.readyToClaim - } else if (pending) { - progressLabelFilled = messages.pendingRewards + } else if (challenge && challenge?.cooldown_days > 0) { + if (needsDisbursement) { + progressLabelFilled = messages.readyToClaim + } else if (pending) { + progressLabelFilled = messages.pendingRewards + } else if (challenge?.challenge_type === 'aggregate') { + // Count down + progressLabelFilled = fillString( + remainingLabel ?? '', + formatNumberCommas( + (challenge?.max_steps - challenge?.current_step_count)?.toString() ?? + '' + ), + formatNumberCommas(challenge?.max_steps?.toString() ?? '') + ) + } else { + progressLabelFilled = fillString( + progressLabel ?? '', + formatNumberCommas(challenge?.current_step_count?.toString() ?? ''), + formatNumberCommas(challenge?.max_steps?.toString() ?? '') + ) + } } else if (challenge?.challenge_type === 'aggregate') { // Count down - progressLabelFilled = formatProgressLabel( + progressLabelFilled = fillString( remainingLabel ?? '', - challenge?.max_steps - challenge?.current_step_count, - challenge.max_steps - ) - } else if (progressLabel?.includes('%')) { - progressLabelFilled = formatProgressLabel( - progressLabel, - challenge?.current_step_count, - challenge?.max_steps + formatNumberCommas( + (challenge?.max_steps - challenge?.current_step_count)?.toString() ?? '' + ), + formatNumberCommas(challenge?.max_steps?.toString() ?? '') ) } else { - progressLabelFilled = progressLabel ?? '' + // Count up + progressLabelFilled = fillString( + progressLabel ?? '', + formatNumberCommas(challenge?.current_step_count?.toString() ?? ''), + formatNumberCommas(challenge?.max_steps?.toString() ?? '') + ) } - const buttonMessage = needsDisbursement ? messages.claimReward : hasDisbursed