-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Improve reward UI/UX #2504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve reward UI/UX #2504
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Warning Rate limit exceeded@steven-tey has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 56 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis update introduces a comprehensive refactor of the reward system, transitioning from a model with a single default reward per program to one supporting multiple default rewards categorized by event types ("click", "lead", "sale"). The changes affect database schemas, backend logic, API endpoints, frontend components, and validation schemas to consistently support event-based default rewards and partner-specific reward associations. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant API
participant DB
User->>Frontend: Request program details
Frontend->>API: GET /programs/[programId]
API->>DB: Query Program (include default rewards by event)
DB-->>API: Return Program with rewards [{event, type, amount, default}]
API-->>Frontend: Return Program + rewards[]
Frontend->>User: Display default rewards for click, lead, sale
User->>Frontend: Create new reward (for event type)
Frontend->>API: POST /rewards (with isDefault, event)
API->>DB: Validate uniqueness, create reward, update enrollments
DB-->>API: Confirmation
API-->>Frontend: Reward created
User->>Frontend: Enroll partner with reward
Frontend->>API: POST /enroll-partner (with reward for event)
API->>DB: Upsert ProgramEnrollment, set event-specific rewardId
DB-->>API: Enrollment confirmation
API-->>Frontend: Enrollment success
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
… retrieval logic in partner profile components.
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
- Introduced `sortRewardsByEvent` function to organize rewards by event type. - Updated `getProgramViaEdge` to fetch rewards more efficiently and return them in a structured format. - Modified the API response in `route.tsx` to utilize the new rewards sorting logic. - Adjusted the rendering logic to display the first reward based on the sorted list.
- Renamed parameters for clarity, changing `includeDefaultReward` and `includeRewards` to `includeDefaultRewards`. - Updated the logic in `getProgramOrThrow` to utilize the new `sortRewardsByEvent` function for sorting rewards. - Adjusted API response handling in `route.ts` to reflect the updated reward inclusion logic.
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
packages/prisma/schema/reward.prisma (3)
22-24: Avoid using SQL reserved keyword for field name
Naming the Boolean columndefaultmay conflict with SQL’sDEFAULTkeyword. Consider renaming it to something likeisDefaultordefaultRewardto prevent quoting issues in migrations.
32-33: Evaluate need for separate single-column index onevent
You already have a composite@@index([programId, event]). If the only use case for filtering byeventis within a specific program, the composite index suffices. Otherwise, the standalone@@index(event)makes sense for cross-program queries (e.g. the cron job).
36-36: Plan removal of deprecatedPartnerRewardtable
This TODO notes the table’s eventual drop. Confirm that you’ll include a Prisma migration to dropPartnerRewardand clean up related code once consumers have migrated.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/web/app/api/og/program/route.tsx(4 hunks)apps/web/lib/planetscale/get-program-via-edge.ts(0 hunks)apps/web/lib/planetscale/types.ts(0 hunks)apps/web/lib/rewardful/import-campaign.ts(3 hunks)packages/prisma/schema/reward.prisma(2 hunks)
💤 Files with no reviewable changes (2)
- apps/web/lib/planetscale/types.ts
- apps/web/lib/planetscale/get-program-via-edge.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- apps/web/lib/rewardful/import-campaign.ts
- apps/web/app/api/og/program/route.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (2)
packages/prisma/schema/reward.prisma (2)
13-14: Field definitions foridandprogramIdlook correct
The primary key and foreign key scalar fields are properly declared.
26-30: Verify relation consistency for event-based enrollments
Ensure that inProgramEnrollmentyou have matching relation fields (e.g.clickReward,leadReward,saleReward) with the same@relation("ClickRewardEnrollments"), etc., so Prisma can link both sides correctly.
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
|
@CodeRabbit final review please |
|
Tip For best results, initiate chat on the files or code changes. Final Review: PR #2504 - Improve Reward UI/UXThis is a comprehensive and well-architected refactor that successfully modernizes the reward system from a single-default model to an event-based multi-reward structure. Here's my final assessment: ✅ StrengthsArchitectural Consistency
Migration Strategy
Code Quality
|
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2504:
To re-run the tests, please comment |
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Chores