feat(referral): switch to link-based claims with flat $5 rewards#546
Conversation
…structure - Transitioned to a link-based referral system offering a one-time $5 credit to both the referrer and the referred user upon the first subscription payment. - Removed the previous reward rate in basis points and eliminated recurring rewards, ensuring clarity in the referral process. - Updated API endpoints and service methods to reflect the new `claimReferral` functionality, enhancing user experience and eligibility checks. - Revised documentation and tests to align with the new referral structure, ensuring comprehensive coverage and understanding of the changes.
… function - Streamlined the `handle_referral_claim` function by removing unnecessary `as_deref()` and `filter()` calls, enhancing code clarity and performance. - Updated the JSON response construction to eliminate redundant line breaks, improving readability without altering functionality.
📝 WalkthroughWalkthroughThe referral system transitions from a percentage-based apply-code model with configurable recurring rewards to a link-based flat-$5 one-time claim model. Both referrer and referred user receive $5 credit upon the referred user's first confirmed subscription payment. The API endpoint changes from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/src/types/referral.ts (1)
33-34: Consider renamingcanApplyReferraltocanClaimReferralfor consistency.The JSDoc correctly describes the "claim" semantics, but the property name still uses "apply" terminology. While this is a minor inconsistency and doesn't affect functionality, renaming it would align with the new endpoint naming throughout the codebase.
♻️ Suggested rename
- /** When false, user likely cannot claim (e.g. already subscribed); optional from backend */ - canApplyReferral?: boolean; + /** When false, user likely cannot claim (e.g. already subscribed); optional from backend */ + canClaimReferral?: boolean;Note: This would require updating usages in
ReferralRewardsSection.tsxandreferralApi.tsnormalization logic.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/src/types/referral.ts` around lines 33 - 34, The property name canApplyReferral should be renamed to canClaimReferral to match the "claim" semantics; update the type declaration (canApplyReferral?: boolean → canClaimReferral?: boolean in the referral type), refactor all uses of canApplyReferral (including UI consumption in ReferralRewardsSection.tsx) to canClaimReferral, and adjust the referral API normalization logic in referralApi.ts to map the backend field to canClaimReferral so runtime data binding stays correct.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@app/src/types/referral.ts`:
- Around line 33-34: The property name canApplyReferral should be renamed to
canClaimReferral to match the "claim" semantics; update the type declaration
(canApplyReferral?: boolean → canClaimReferral?: boolean in the referral type),
refactor all uses of canApplyReferral (including UI consumption in
ReferralRewardsSection.tsx) to canClaimReferral, and adjust the referral API
normalization logic in referralApi.ts to map the backend field to
canClaimReferral so runtime data binding stays correct.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0ac3b9f8-d7e0-4c37-8cbf-08150ec8b3d9
📒 Files selected for processing (9)
Referral-doc.mdapp/src/components/referral/ReferralRewardsSection.tsxapp/src/pages/onboarding/steps/ReferralApplyStep.tsxapp/src/services/api/__tests__/referralApi.test.tsapp/src/services/api/referralApi.tsapp/src/types/referral.tsscripts/mock-api-core.mjssrc/openhuman/referral/ops.rssrc/openhuman/referral/schemas.rs
…yhumansai#546) * refactor(referral): update referral system to a one-time flat reward structure - Transitioned to a link-based referral system offering a one-time $5 credit to both the referrer and the referred user upon the first subscription payment. - Removed the previous reward rate in basis points and eliminated recurring rewards, ensuring clarity in the referral process. - Updated API endpoints and service methods to reflect the new `claimReferral` functionality, enhancing user experience and eligibility checks. - Revised documentation and tests to align with the new referral structure, ensuring comprehensive coverage and understanding of the changes. * refactor(referral): simplify JSON response handling in referral claim function - Streamlined the `handle_referral_claim` function by removing unnecessary `as_deref()` and `filter()` calls, enhancing code clarity and performance. - Updated the JSON response construction to eliminate redundant line breaks, improving readability without altering functionality.
Summary
POST /referral/apply→POST /referral/claim(Rust RPC + frontend API client)rewardRateBpsfrom types, API normalization, and UI displayReferral-doc.mdto reflect the new systemMirrors backend changes from tinyhumansai/backend#631.
Test plan
cargo check)tsc --noEmit)vitest)/referral/claimSummary by CodeRabbit
New Features
UI Updates