#773 feat(campaign): Campaign milestone achievements -unlock visual b… - #829
Merged
Conversation
… -unlock visual badges at 25%, 50%, 75%, 100% FIXED
|
@veloura-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…n-milestone-achievements-unlock-visual-badges-at-25%,-50%,-75%,100%-FIX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CLOSE #773
Findings (root causes)
1. No milestone badge UI existed at all.
The campaign detail page (
apps/web/src/app/(overview)/campaigns/[id]/page.tsx) rendered a funding progress bar but never surfaced the 25/50/75/100% milestones.2. The funding progress math was wrong.
The original calculation parsed amount strings that contained thousands separators:
Since milestone state is derived from this percentage, any incorrect figure would unlock the wrong badges.
3. Pre-existing runtime blocker that prevented the page from rendering.
apps/web/src/lib/utils.tscalledclxx(undefined) instead ofclsx:cn()is used by 41 files (Button,Badge,Tabs, etc.), so the campaign page couldn't render at all — the badge feature was impossible to display until this was fixed.Fix features
A. Pure milestone/percentage helpers —
lib/campaign-milestones.tsMILESTONE_PERCENTAGES = [25, 50, 75, 100]— canonical milestones.parseFundingAmount()— safely parses"33,850","50,000","33,850 XLM", and numbers; returns0for invalid input (neverNaN).calculateFundingProgress(raised, goal)— correct rounded 0–100 progress, safe against zero/negative/missing goals.getAchievedMilestonePercentages(progress)— which milestones are unlocked.getNextMilestone(progress)— the next locked milestone, ornullwhen done.B. Milestone badge UI + celebratory animation —
components/modules/campaign/CampaignMilestones.tsx(302 lines)Four badges, each with its own custom icon and accent colour:
FlagMedalRocketTrophyCelebratory animation per achieved badge via
framer-motion:scale: [0.85, 1.06, 1], opacity ramp).SparkleBurst) in the milestone colour.Achieved badges show a green
CheckCircle2; locked ones are dimmed with aLock. The section also has a live animated progress track, a status chip ("Next at XX%" / "Goal achieved"), and full accessibility (role="img",aria-label,sr-onlytext, plusdata-testid/data-achievedhooks for tests).C. Wired into the campaign detail page —
page.tsxCampaignMilestones(line 23).progressPctto strip thousands separators before parsing (line 101).<CampaignMilestones raisedAmount={campaign.raisedAmount} goalAmount={campaign.goalAmount} />between the hero banner and the tabs (line 249).D. Required prerequisite fix —
lib/utils.tsValidation summary (re-verified this session)
page.tsx/utils.tslines are free of lint errors (the 2 flaggedpage.tsxerrors are pre-existing, on lines 11–12 & 291, not my lines).tsc --noEmit: zero errors in any file I touched (repo-wide 52 errors are all pre-existing, in files I never opened).matchMedia, Stellar RPC, etc.), in files I never modified.