Skip to content

Add GET /api/payouts#3444

Merged
steven-tey merged 8 commits intomainfrom
payout-apis
Feb 9, 2026
Merged

Add GET /api/payouts#3444
steven-tey merged 8 commits intomainfrom
payout-apis

Conversation

@devkiran
Copy link
Collaborator

@devkiran devkiran commented Feb 9, 2026

Summary by CodeRabbit

  • New Features

    • Added tenantId query support for more flexible payout filtering.
  • Documentation

    • Payout endpoints and operations added to the OpenAPI docs.
  • Improvements

    • Simplified payout endpoints to a consolidated workspace-level path.
    • Query shapes refined (fields and descriptions) for clearer filtering behavior.
    • UI updates to refresh generic payouts endpoints after actions.
  • Bug Fixes

    • Better handling and clear error when tenantId cannot be resolved.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel
Copy link
Contributor

vercel bot commented Feb 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dub Ready Ready Preview Feb 9, 2026 6:41pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

Routes and client hooks for payouts were migrated from program-scoped endpoints to generic /api/payouts and /api/payouts/count. Query schemas were updated to add tenantId, restructure programId/eligibility placement, and OpenAPI docs for payouts were added.

Changes

Cohort / File(s) Summary
API Route Handlers
apps/web/app/(ee)/api/payouts/route.ts, apps/web/app/(ee)/api/payouts/count/route.ts
Switched from program-scoped routes to generic /api/payouts and /api/payouts/count. Added tenantId query support, resolving partnerId via programEnrollment lookup and returning a not_found DubApiError if lookup fails.
SWR Data Fetching Hooks
apps/web/lib/swr/use-payouts.ts, apps/web/lib/swr/use-payouts-count.ts
Updated fetch URLs to use /api/payouts and /api/payouts/count (removed programId in path); query composition unchanged.
Zod Schema Validation
apps/web/lib/zod/schemas/payouts.ts, apps/web/lib/zod/schemas/partner-profile.ts
Added tenantId to payouts query schema, moved programId/eligibility to optional extended fields for count queries, and added optional programId to partner-profile payouts query shape; added descriptive metadata to several fields.
OpenAPI Documentation
apps/web/lib/openapi/index.ts, apps/web/lib/openapi/payouts/index.ts, apps/web/lib/openapi/payouts/list-payouts.ts
Added payouts OpenAPI paths and a listPayouts GET operation for /payouts, and integrated these paths into the main OpenAPI document.
Frontend Components & UI
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx, apps/web/ui/partners/mark-commission-*.tsx
Frontend fetches switched to generic endpoints; removed reliance on defaultProgramId from workspace in partner modals and updated cache invalidation to include /api/payouts.
OpenAPI Metadata tweaks
apps/web/lib/openapi/bounties/list-bounty-submissions.ts, apps/web/lib/openapi/commissions/list-commissions.ts
Minor description and parameter description updates for bounty submissions and commissions operations.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant API as Payouts API (/api/payouts)
    participant Enrollment as ProgramEnrollment Service/DB
    participant PayoutSvc as Payouts Service/DB

    Client->>API: GET /api/payouts?tenantId=...&otherQuery
    API->>Enrollment: find programEnrollment by tenantId
    Enrollment-->>API: programEnrollment (or null)
    alt programEnrollment found
        API->>PayoutSvc: query payouts (resolved partnerId, filters)
        PayoutSvc-->>API: payouts list
        API-->>Client: 200 OK (payouts)
    else not found
        API-->>Client: 404 DubApiError ("no program enrollment found for tenant")
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • steven-tey

Poem

🐰 Hopping through the code, I found a new route,
From program paths we leap, now payouts roam about.
tenantId whispers, enrollments reply,
Partner IDs settle, lists fetch by and by.
Docs bloom, hooks point true — a rabbit's small cheer, hooray!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective of this PR: adding a new GET /api/payouts endpoint. All file changes support this goal, including route implementation, schema updates, and integration with the OpenAPI specification.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch payout-apis

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
apps/web/lib/zod/schemas/payouts.ts (1)

69-71: programId and eligibility added without .describe() metadata.

Other fields in payoutsQuerySchema have .describe() for OpenAPI documentation. These two fields in the count schema lack descriptions, which may result in undocumented query parameters in the generated API spec.

Proposed fix
-    programId: z.string().optional(),
+    programId: z.string().optional().describe("Filter payouts count by program ID."),
     groupBy: z.enum(["status"]).optional(),
-    eligibility: z.enum(["eligible", "ineligible"]).optional(),
+    eligibility: z.enum(["eligible", "ineligible"]).optional().describe("Filter payouts count by eligibility status."),

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

devkiran and others added 3 commits February 9, 2026 22:45
@devkiran devkiran marked this pull request as ready for review February 9, 2026 17:43
@devkiran devkiran requested a review from steven-tey February 9, 2026 17:57
@steven-tey steven-tey merged commit ed3bdc8 into main Feb 9, 2026
10 checks passed
@steven-tey steven-tey deleted the payout-apis branch February 9, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants