Conversation
Being able to filter the commissions table by "On hold" status from fraud.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds explicit "hold" status handling across commissions and payouts: routes detect and strip Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant APIRoute as API Route
participant Helper as Helper (getCommissions / getCommissionsCount)
participant DB as Database (Prisma)
Client->>APIRoute: GET /commissions?status=hold
APIRoute->>APIRoute: detect status === "hold"\nstrip status from params\nset isHoldStatus = true
APIRoute->>Helper: call helper with parsedParams + isHoldStatus
Helper->>Helper: build statusFilter (pending|processed)\nbuild programEnrollmentFilter (fraudEventGroups.status = pending)
Helper->>DB: execute Prisma query with statusFilter + programEnrollmentFilter + earnings != 0
DB-->>Helper: return filtered results
Helper-->>APIRoute: aggregated counts / items (includes "hold")
APIRoute-->>Client: JSON response (hold presented as derived category)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Possibly related PRs
Suggested reviewers
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)
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: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/lib/api/commissions/get-commissions-count.ts (1)
85-122:⚠️ Potential issue | 🟠 MajorMissing population of
counts.holdwhenisHoldStatusis true.The type annotation declares
"hold"as a valid key in the return type (types.ts:448-449), butgetCommissionsCountnever populatescounts.hold. WhenisHoldStatusistrue(when callers request?status=hold), the API endpoint returns the entirecountsobject without theholdkey, violating the type contract.When filtering by hold status, set
counts.holdto the aggregated totals:🐛 Proposed fix
counts.all = commissionsCount.reduce( (acc, p) => ({ count: acc.count + p._count, amount: acc.amount + (p._sum.amount ?? 0), earnings: acc.earnings + (p._sum.earnings ?? 0), }), { count: 0, amount: 0, earnings: 0 }, ); + if (isHoldStatus) { + counts.hold = counts.all; + } + return counts;
🧹 Nitpick comments (1)
apps/web/ui/partners/payout-status-badges.tsx (1)
53-59: Consider using ShieldAlert icon for consistency with commission hold status.The hold status in
CommissionStatusBadges(commission-status-badges.tsx:136) usesShieldAlertto convey the fraud-related nature of the hold. UsingCircleXmarkhere creates a visual inconsistency between the two views for what represents the same underlying concept.🔧 Suggested change for icon consistency
+import { + CircleCheck, + CircleHalfDottedCheck, + CircleHalfDottedClock, + CircleWarning, + CircleXmark, + PaperPlane, + ShieldAlert, +} from "@dub/ui/icons"; ... // extra status for hold (not in OpenAPI spec) hold: { label: "On Hold", variant: "error", - icon: CircleXmark, + icon: ShieldAlert, className: "text-red-600 bg-red-100", },
|
@coderabbitai full review, any breaking changes? |
|
🚨 Breaking Changes1.
|
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/lib/api/commissions/get-commissions-count.ts (1)
85-122:⚠️ Potential issue | 🟠 MajorSet
counts.holdexplicitly to match the new public type.The return type now includes
"hold", but this function never assigns it, so consumers will seeundefined. Consider populating it (at least whenisHoldStatusis true) to keep runtime behavior in sync with the type.✅ Suggested fix
counts.all = commissionsCount.reduce( (acc, p) => ({ count: acc.count + p._count, amount: acc.amount + (p._sum.amount ?? 0), earnings: acc.earnings + (p._sum.earnings ?? 0), }), { count: 0, amount: 0, earnings: 0 }, ); + + counts.hold = isHoldStatus + ? { ...counts.all } + : { count: 0, amount: 0, earnings: 0 };
🧹 Nitpick comments (1)
apps/web/ui/partners/payout-status-badges.tsx (1)
53-59: Consider usingShieldAlerticon for consistency with commission status badges.The commission status badges (in
commission-status-badges.tsx) useShieldAlertfor the hold status, but hereCircleXmarkis used. For visual consistency across commissions and payouts when filtering by "On Hold", consider using the same icon.This is a minor UI polish suggestion and can be deferred if the distinction is intentional.
Being able to filter the commissions table by "On hold" status from fraud.
Summary by CodeRabbit
New Features
Data & Metrics
Chores