Lead and sales rewards metadata condition#4032
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds complete support for metadata-based reward conditions in the partner rewards system. It introduces a new ChangesMetadata-Based Reward Conditions Feature
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/ui/partners/program-reward-modifiers-tooltip.tsx (1)
179-220:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRender numeric
0condition values in tooltip text.At Line 182,
condition.value && ...suppresses valid falsy operands like0(e.g.,greater_than 0), so the tooltip can render an incomplete condition.Suggested fix
- {condition.value && + {condition.value !== undefined && + condition.value !== null && + (typeof condition.value !== "string" || + condition.value.trim() !== "") && (condition.attribute === "country" ? // Country names Array.isArray(condition.value)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/ui/partners/program-reward-modifiers-tooltip.tsx` around lines 179 - 220, The tooltip logic is skipping falsy but valid values like 0 because it uses "condition.value && ..."; update the check to explicitly allow 0 by replacing that truthy check with an explicit null/undefined check (e.g., condition.value !== undefined && condition.value !== null, or condition.value != null) before the big rendering expression so all the downstream branches (country lookup using COUNTRIES, subscription formatting via formatSubscriptionDuration, product label handling, Array.isArray branches using attribute?.options, currencyFormatter, formatDateTime, and options lookup on attribute) still run for numeric 0 or other valid falsy values; keep the rest of the rendering logic and symbols (CONDITION_OPERATOR_LABELS, COUNTRIES, formatSubscriptionDuration, currencyFormatter, formatDateTime, attribute) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/.env.example`:
- Line 32: The QSTASH_URL variable is quoted and triggers dotenv-linter's
QuoteCharacter rule; update the QSTASH_URL entry (the QSTASH_URL key in the .env
example) to use an unquoted URL value (remove the surrounding double quotes) so
the line reads a bare URL and passes the linter.
---
Outside diff comments:
In `@apps/web/ui/partners/program-reward-modifiers-tooltip.tsx`:
- Around line 179-220: The tooltip logic is skipping falsy but valid values like
0 because it uses "condition.value && ..."; update the check to explicitly allow
0 by replacing that truthy check with an explicit null/undefined check (e.g.,
condition.value !== undefined && condition.value !== null, or condition.value !=
null) before the big rendering expression so all the downstream branches
(country lookup using COUNTRIES, subscription formatting via
formatSubscriptionDuration, product label handling, Array.isArray branches using
attribute?.options, currencyFormatter, formatDateTime, and options lookup on
attribute) still run for numeric 0 or other valid falsy values; keep the rest of
the rendering logic and symbols (CONDITION_OPERATOR_LABELS, COUNTRIES,
formatSubscriptionDuration, currencyFormatter, formatDateTime, attribute)
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7834f79f-5668-4266-bea9-f64a458aa69d
📒 Files selected for processing (13)
.github/workflows/e2e.yaml.github/workflows/playwright.yamlapps/web/.env.exampleapps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.tsapps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.tsapps/web/lib/api/conversions/track-lead.tsapps/web/lib/api/conversions/track-sale.tsapps/web/lib/partners/evaluate-reward-conditions.tsapps/web/lib/zod/schemas/rewards.tsapps/web/tests/rewards/reward-conditions.test.tsapps/web/ui/partners/program-reward-modifiers-tooltip.tsxapps/web/ui/partners/rewards/add-edit-reward-sheet.tsxapps/web/ui/partners/rewards/rewards-logic.tsx
Always include lead in commission context and simplify metadata spreading in track lead/sale.
…nc/dub into lead-sales-rewards-metadata
Summary by CodeRabbit
Release Notes
New Features
contains/not_contains.Bug Fixes
Tests
Chores
QSTASH_URLto E2E workflows and the web environment example.