Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@steven-tey
Copy link
Collaborator

@steven-tey steven-tey commented Nov 9, 2025

Summary by CodeRabbit

  • Refactor
    • Reorganized internal constants into domain-specific modules for clearer structure.
    • Consolidated bounty submission validation and standardized rejection reasons into a dedicated constants module; submission limits and messages are now centralized.
  • Bug Fix
    • Minor fix to PDF response handling to improve reliability of invoice downloads.

@vercel
Copy link
Contributor

vercel bot commented Nov 9, 2025

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

Project Deployment Preview Updated (UTC)
dub Ready Ready Preview Nov 9, 2025 8:35pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 9, 2025

Walkthrough

Constants were reorganized from a single partners module into domain-specific modules (bounties, program, payouts, partner-profile, misc); import paths updated across many files. One functional change: an invoice PDF response body is now wrapped in a Uint8Array.

Changes

Cohort / File(s) Summary
New constants modules
apps/web/lib/constants/bounties.ts, apps/web/lib/constants/misc.ts, apps/web/lib/constants/partner-profile.ts, apps/web/lib/constants/program.ts
Added domain-specific constant modules: bounty limits/reasons, misc limits, partner-profile limits, and program limits/import sources.
Removed from payouts aggregate
apps/web/lib/constants/payouts.ts
Removed several previously-exported constants that were moved to new domain modules; payouts-specific constants remain.
Bounty validation, schemas & types
apps/web/lib/zod/schemas/bounties.ts, apps/web/lib/types.ts, apps/web/lib/actions/partners/create-bounty-submission.ts, apps/web/lib/actions/partners/reject-bounty-submission.ts, apps/web/ui/partners/bounties/claim-bounty-modal.tsx, apps/web/ui/partners/reject-bounty-submission-modal.tsx
Switched bounty-related constants and rejection reasons to @/lib/constants/bounties; schema and type imports updated to centralize limits and requirements.
Program constants & onboarding
apps/web/lib/zod/schemas/program-onboarding.ts, apps/web/lib/swr/use-program-enrollment.ts, apps/web/app/app.dub.co/(dashboard)/.../program/partners/import-export-buttons.tsx
PROGRAM_ONBOARDING_PARTNERS_LIMIT, LARGE_PROGRAM_MIN_TOTAL_COMMISSIONS_CENTS, and PROGRAM_IMPORT_SOURCES moved to @/lib/constants/program; imports updated.
Payout & payment constants usage
apps/web/lib/actions/partners/confirm-payouts.ts, apps/web/lib/partners/create-stripe-transfer.ts, apps/web/lib/stripe/payment-methods.ts, apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts, apps/web/app/(ee)/api/stripe/webhook/utils/process-payout-invoice-failure.ts, apps/web/app/api/workspaces/[idOrSlug]/billing/payment-methods/route.ts, apps/web/ui/partners/confirm-payouts-sheet.tsx, apps/web/ui/modals/add-payment-method-modal.tsx, apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/*, apps/web/app/app.dub.co/(dashboard)/.../payouts/*
Import paths updated to @/lib/constants/payouts for payout/payment-related constants; logic unchanged.
Referral & customer limits
apps/web/lib/constants/misc.ts, apps/web/app/(ee)/api/embed/referrals/earnings/route.ts, apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsx, apps/web/app/(ee)/partners.dub.co/.../customers/[customerId]/page-client.tsx, apps/web/app/app.dub.co/.../customers/[customerId]/page-client.tsx
REFERRALS_EMBED_EARNINGS_LIMIT and CUSTOMER_PAGE_EVENTS_LIMIT added to @/lib/constants/misc; imports updated accordingly.
Partner-profile limits & invite UI
apps/web/lib/constants/partner-profile.ts, apps/web/app/(ee)/api/partner-profile/invites/route.ts, apps/web/ui/modals/invite-partner-user-modal.tsx
MAX_INVITES_PER_REQUEST and MAX_PARTNER_USERS moved to @/lib/constants/partner-profile; imports updated.
Invoice / billing routes & UI
apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx, apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx, apps/web/app/app.dub.co/(dashboard)/.../settings/billing/invoices/page-client.tsx, apps/web/app/app.dub.co/(dashboard)/.../settings/billing/payment-methods.tsx
Import paths updated to new constants modules; [payoutId]/route.tsx now wraps PDF buffer in new Uint8Array(pdf) before sending the Response.
Scripts & migrations
apps/web/scripts/migrations/backfill-invoice-payment-method.ts, apps/web/scripts/stripe/fix-processed-payouts.ts
Updated imports to @/lib/constants/payouts for payment normalization and withdrawal constants.
Misc UI & small updates
various UI components referenced in summary (e.g., apps/web/ui/partners/payout-status-descriptions.ts, apps/web/ui/partners/payout-table.tsx, apps/web/ui/modals/*)
Adjusted imports to the new constants modules; no logic changes beyond import sources.

Sequence Diagram(s)

sequenceDiagram
  participant Route as invoices/[payoutId]/route.tsx
  participant PDFGen as generateInvoicePdf()
  participant Response as HTTP Response

  Note right of Route: Request -> generate PDF
  Route->>PDFGen: generate invoice PDF (Buffer)
  PDFGen-->>Route: pdf (Buffer)

  alt previous behavior
    Note left of Route: sent raw Buffer (may be accepted)
    Route->>Response: new Response(pdf, { headers })
  else new behavior
    Note left of Route: wrap Buffer in typed array
    Route->>Route: pdfTyped = new Uint8Array(pdf)
    Route->>Response: new Response(pdfTyped, { headers })
  end

  Response-->>Client: PDF body
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Areas requiring extra attention:

  • apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx — verify PDF wrapping (Uint8Array) produces identical client behavior and correct headers.
  • New modules: validate numeric values, array/object shapes (PROGRAM_IMPORT_SOURCES, REJECT_BOUNTY_SUBMISSION_REASONS, BOUNTY_SUBMISSION_REQUIREMENTS).
  • Removal of exports from zod schemas: ensure no external consumers still import the removed symbols.

Possibly related PRs

Suggested reviewers

  • devkiran
  • TWilson023

Poem

🐰 I hopped through code to tidy each name,
Bounties and payouts moved into frames,
Constants now cozy in folders so neat,
Little rabbit cheers — the repo’s complete! 🥕✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 'Rearrange constants files' directly and concisely summarizes the main change: reorganizing constants across multiple files into new dedicated constant modules.
✨ 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 rearrange-constants

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7f5c97 and 0b581e3.

📒 Files selected for processing (47)
  • apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts (1 hunks)
  • apps/web/app/(ee)/api/embed/referrals/earnings/route.ts (1 hunks)
  • apps/web/app/(ee)/api/partner-profile/invites/route.ts (1 hunks)
  • apps/web/app/(ee)/api/partner-profile/programs/[programId]/analytics/route.ts (1 hunks)
  • apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/[customerId]/route.ts (1 hunks)
  • apps/web/app/(ee)/api/partner-profile/programs/[programId]/events/route.ts (1 hunks)
  • apps/web/app/(ee)/api/stripe/webhook/utils/process-payout-invoice-failure.ts (1 hunks)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/partners/form.tsx (1 hunks)
  • apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsx (1 hunks)
  • apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx (1 hunks)
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-details-sheet.tsx (1 hunks)
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx (1 hunks)
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx (1 hunks)
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page-client.tsx (1 hunks)
  • apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx (2 hunks)
  • apps/web/app/api/workspaces/[idOrSlug]/billing/payment-methods/route.ts (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/customers/[customerId]/page-client.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty-sheet.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/import-export-buttons.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-details-sheet.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/program-payout-settings-sheet.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page-client.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/payment-methods.tsx (1 hunks)
  • apps/web/lib/actions/partners/confirm-payouts.ts (1 hunks)
  • apps/web/lib/actions/partners/create-bounty-submission.ts (2 hunks)
  • apps/web/lib/actions/partners/reject-bounty-submission.ts (1 hunks)
  • apps/web/lib/constants/bounties.ts (1 hunks)
  • apps/web/lib/constants/misc.ts (1 hunks)
  • apps/web/lib/constants/partner-profile.ts (1 hunks)
  • apps/web/lib/constants/payouts.ts (0 hunks)
  • apps/web/lib/constants/program.ts (1 hunks)
  • apps/web/lib/partners/create-stripe-transfer.ts (1 hunks)
  • apps/web/lib/stripe/payment-methods.ts (1 hunks)
  • apps/web/lib/swr/use-program-enrollment.ts (1 hunks)
  • apps/web/lib/types.ts (2 hunks)
  • apps/web/lib/zod/schemas/bounties.ts (3 hunks)
  • apps/web/lib/zod/schemas/program-onboarding.ts (1 hunks)
  • apps/web/lib/zod/schemas/programs.ts (1 hunks)
  • apps/web/scripts/migrations/backfill-invoice-payment-method.ts (1 hunks)
  • apps/web/scripts/stripe/fix-processed-payouts.ts (1 hunks)
  • apps/web/ui/modals/add-payment-method-modal.tsx (1 hunks)
  • apps/web/ui/modals/invite-partner-user-modal.tsx (1 hunks)
  • apps/web/ui/partners/bounties/claim-bounty-modal.tsx (4 hunks)
  • apps/web/ui/partners/confirm-payouts-sheet.tsx (1 hunks)
  • apps/web/ui/partners/payout-status-descriptions.ts (1 hunks)
  • apps/web/ui/partners/reject-bounty-submission-modal.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/web/lib/constants/payouts.ts
🧰 Additional context used
🧠 Learnings (16)
📚 Learning: 2025-10-15T01:05:43.266Z
Learnt from: steven-tey
Repo: dubinc/dub PR: 2958
File: apps/web/app/app.dub.co/(dashboard)/[slug]/settings/members/page-client.tsx:432-457
Timestamp: 2025-10-15T01:05:43.266Z
Learning: In apps/web/app/app.dub.co/(dashboard)/[slug]/settings/members/page-client.tsx, defer refactoring the custom MenuItem component (lines 432-457) to use the shared dub/ui MenuItem component to a future PR, as requested by steven-tey.

Applied to files:

  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/customers/[customerId]/page-client.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/program-payout-settings-sheet.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-details-sheet.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/payment-methods.tsx
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page-client.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/import-export-buttons.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page-client.tsx
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/partners/form.tsx
📚 Learning: 2025-08-25T21:03:24.285Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2736
File: apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx:1-1
Timestamp: 2025-08-25T21:03:24.285Z
Learning: In Next.js App Router, Server Components that use hooks can work without "use client" directive if they are only imported by Client Components, as they get "promoted" to run on the client side within the Client Component boundary.

Applied to files:

  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/customers/[customerId]/page-client.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/import-export-buttons.tsx
📚 Learning: 2025-10-06T15:48:14.205Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2935
File: apps/web/lib/actions/partners/invite-partner-from-network.ts:21-28
Timestamp: 2025-10-06T15:48:14.205Z
Learning: For the network invites limit check in apps/web/lib/actions/partners/invite-partner-from-network.ts, the team accepts that concurrent invites may bypass the limit due to race conditions. Perfect atomicity is not required for this feature.

Applied to files:

  • apps/web/lib/constants/partner-profile.ts
  • apps/web/app/(ee)/api/partner-profile/invites/route.ts
  • apps/web/lib/zod/schemas/program-onboarding.ts
  • apps/web/ui/modals/invite-partner-user-modal.tsx
📚 Learning: 2025-05-29T04:45:18.504Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2448
File: packages/email/src/templates/partner-program-summary.tsx:0-0
Timestamp: 2025-05-29T04:45:18.504Z
Learning: In the PartnerProgramSummary email template (packages/email/src/templates/partner-program-summary.tsx), the stat titles are hardcoded constants ("Clicks", "Leads", "Sales", "Earnings") that will always match the ICONS object keys after toLowerCase() conversion, so icon lookup failures are not possible.

Applied to files:

  • apps/web/app/(ee)/api/partner-profile/programs/[programId]/analytics/route.ts
  • apps/web/lib/constants/program.ts
  • apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsx
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-details-sheet.tsx
📚 Learning: 2025-09-12T17:36:09.551Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2833
File: apps/web/app/(ee)/api/bounties/[bountyId]/route.ts:100-107
Timestamp: 2025-09-12T17:36:09.551Z
Learning: For performance bounties in the bounty system, names cannot be provided by users - they are always auto-generated based on the performance condition using generateBountyName(). This ensures consistency and clarity about what the bounty actually measures. Any provided name should be overridden for performance bounties when a performanceCondition exists.

Applied to files:

  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty-sheet.tsx
📚 Learning: 2025-07-11T16:28:55.693Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2635
File: packages/prisma/schema/payout.prisma:24-25
Timestamp: 2025-07-11T16:28:55.693Z
Learning: In the Dub codebase, multiple payout records can now share the same stripeTransferId because payouts are grouped by partner and processed as single Stripe transfers. This is why the unique constraint was removed from the stripeTransferId field in the Payout model - a single transfer can include multiple payouts for the same partner.

Applied to files:

  • apps/web/lib/partners/create-stripe-transfer.ts
  • apps/web/lib/actions/partners/confirm-payouts.ts
  • apps/web/scripts/migrations/backfill-invoice-payment-method.ts
📚 Learning: 2025-08-26T14:32:33.851Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2736
File: apps/web/lib/actions/partners/create-bounty-submission.ts:105-112
Timestamp: 2025-08-26T14:32:33.851Z
Learning: Non-performance bounties are required to have submissionRequirements. In create-bounty-submission.ts, it's appropriate to let the parsing fail if submissionRequirements is null for non-performance bounties, as this indicates a data integrity issue that should be caught.

Applied to files:

  • apps/web/lib/types.ts
  • apps/web/lib/actions/partners/reject-bounty-submission.ts
  • apps/web/ui/partners/reject-bounty-submission-modal.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
  • apps/web/lib/zod/schemas/bounties.ts
  • apps/web/ui/partners/bounties/claim-bounty-modal.tsx
  • apps/web/lib/constants/bounties.ts
  • apps/web/lib/actions/partners/create-bounty-submission.ts
📚 Learning: 2025-09-12T17:31:10.548Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2833
File: apps/web/lib/actions/partners/approve-bounty-submission.ts:53-61
Timestamp: 2025-09-12T17:31:10.548Z
Learning: In approve-bounty-submission.ts, the logic `bounty.rewardAmount ?? rewardAmount` is intentional. Bounties with preset reward amounts should use those fixed amounts, and the rewardAmount override parameter is only used when bounty.rewardAmount is null/undefined (for custom reward bounties). This follows the design pattern where bounties are either "flat rate" (fixed amount) or "custom" (variable amount set during approval).

Applied to files:

  • apps/web/lib/types.ts
  • apps/web/lib/actions/partners/reject-bounty-submission.ts
  • apps/web/ui/partners/reject-bounty-submission-modal.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
  • apps/web/lib/zod/schemas/bounties.ts
  • apps/web/ui/partners/bounties/claim-bounty-modal.tsx
  • apps/web/lib/constants/bounties.ts
  • apps/web/lib/actions/partners/create-bounty-submission.ts
📚 Learning: 2025-08-26T14:20:23.943Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2736
File: apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts:13-14
Timestamp: 2025-08-26T14:20:23.943Z
Learning: The updateNotificationPreference action in apps/web/lib/actions/update-notification-preference.ts already handles all notification preference types dynamically, including newBountySubmitted, through its schema validation using the notificationTypes enum and Prisma's dynamic field update pattern.

Applied to files:

  • apps/web/lib/types.ts
  • apps/web/lib/actions/partners/reject-bounty-submission.ts
  • apps/web/ui/partners/reject-bounty-submission-modal.tsx
  • apps/web/lib/zod/schemas/bounties.ts
  • apps/web/ui/partners/bounties/claim-bounty-modal.tsx
  • apps/web/lib/constants/bounties.ts
  • apps/web/lib/actions/partners/create-bounty-submission.ts
📚 Learning: 2025-07-30T15:25:13.936Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2673
File: apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx:56-66
Timestamp: 2025-07-30T15:25:13.936Z
Learning: In apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx, the form schema uses partial condition objects to allow users to add empty/unconfigured condition fields without type errors, while submission validation uses strict schemas to ensure data integrity. This two-stage validation pattern improves UX by allowing progressive completion of complex forms.

Applied to files:

  • apps/web/lib/types.ts
  • apps/web/lib/zod/schemas/bounties.ts
  • apps/web/lib/zod/schemas/program-onboarding.ts
📚 Learning: 2025-10-17T08:18:19.278Z
Learnt from: devkiran
Repo: dubinc/dub PR: 0
File: :0-0
Timestamp: 2025-10-17T08:18:19.278Z
Learning: In the apps/web codebase, `@/lib/zod` should only be used for places that need OpenAPI extended zod schema. All other places should import from the standard `zod` package directly using `import { z } from "zod"`.

Applied to files:

  • apps/web/lib/zod/schemas/programs.ts
📚 Learning: 2025-09-17T17:44:03.965Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2857
File: apps/web/lib/actions/partners/update-program.ts:96-0
Timestamp: 2025-09-17T17:44:03.965Z
Learning: In apps/web/lib/actions/partners/update-program.ts, the team prefers to keep the messagingEnabledAt update logic simple by allowing client-provided timestamps rather than implementing server-controlled timestamp logic to avoid added complexity.

Applied to files:

  • apps/web/lib/zod/schemas/programs.ts
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/partners/form.tsx
  • apps/web/lib/zod/schemas/program-onboarding.ts
📚 Learning: 2025-09-19T18:46:43.787Z
Learnt from: CR
Repo: dubinc/dub PR: 0
File: packages/hubspot-app/CLAUDE.md:0-0
Timestamp: 2025-09-19T18:46:43.787Z
Learning: Applies to packages/hubspot-app/app/settings/**/*.{js,jsx,ts,tsx} : Only use components exported by hubspot/ui-extensions in settings components

Applied to files:

  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/import-export-buttons.tsx
📚 Learning: 2025-08-25T17:39:38.965Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2736
File: apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx:45-56
Timestamp: 2025-08-25T17:39:38.965Z
Learning: In the bounty system, each partner can only submit to the same bounty once. This means totalSubmissions (pending + approved + rejected) equals the number of unique partners who have submitted, making UI text like "X of Y partners completed" accurate when using totalSubmissions.

Applied to files:

  • apps/web/lib/zod/schemas/bounties.ts
  • apps/web/ui/partners/bounties/claim-bounty-modal.tsx
  • apps/web/lib/actions/partners/create-bounty-submission.ts
📚 Learning: 2025-07-30T15:29:54.131Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2673
File: apps/web/ui/partners/rewards/rewards-logic.tsx:268-275
Timestamp: 2025-07-30T15:29:54.131Z
Learning: In apps/web/ui/partners/rewards/rewards-logic.tsx, when setting the entity field in a reward condition, dependent fields (attribute, operator, value) should be reset rather than preserved because different entities (customer vs sale) have different available attributes. Maintaining existing fields when the entity changes would create invalid state combinations and confusing UX.

Applied to files:

  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/partners/form.tsx
📚 Learning: 2025-05-29T09:49:19.604Z
Learnt from: devkiran
Repo: dubinc/dub PR: 2433
File: apps/web/ui/modals/add-payment-method-modal.tsx:60-62
Timestamp: 2025-05-29T09:49:19.604Z
Learning: The `/api/workspaces/${slug}/billing/payment-methods` POST endpoint in the billing API returns either an error (handled by response.ok check) or a response object containing a `url` property for successful requests.

Applied to files:

  • apps/web/app/api/workspaces/[idOrSlug]/billing/payment-methods/route.ts
🔇 Additional comments (49)
apps/web/app/api/workspaces/[idOrSlug]/billing/payment-methods/route.ts (1)

4-8: Import path reorganization aligns with constants refactoring.

The import path has been updated from @/lib/partners/constants to @/lib/constants/payouts in line with the PR's domain-specific module reorganization. All three constants (DIRECT_DEBIT_PAYMENT_METHOD_TYPES, DIRECT_DEBIT_PAYMENT_TYPES_INFO, PAYMENT_METHOD_TYPES) are payment-method/payout-related and appropriately placed in the new payouts module. Usage throughout the file (lines 16, 32, 75) remains correct and consistent.

apps/web/app/(ee)/api/stripe/webhook/utils/process-payout-invoice-failure.ts (1)

1-4: Import path update is clean and correct.

The constants DIRECT_DEBIT_PAYMENT_METHOD_TYPES and PAYOUT_FAILURE_FEE_CENTS are now appropriately imported from the domain-specific @/lib/constants/payouts module instead of the generic partners module. The change aligns with the constants reorganization objective and all usages throughout the file remain unchanged and correct.

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/payment-methods.tsx (1)

3-3: LGTM! Clean import path update.

The reorganization of DIRECT_DEBIT_PAYMENT_METHOD_TYPES from the general partners constants to the domain-specific payouts module improves code organization and aligns with the PR objectives.

apps/web/lib/zod/schemas/programs.ts (1)

5-5: Import path change verified—no issues found.

The constant ALLOWED_MIN_PAYOUT_AMOUNTS is properly exported from the new location at apps/web/lib/constants/payouts.ts:9. The import path update aligns with the PR objective to reorganize constants into domain-specific modules.

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/program-payout-settings-sheet.tsx (1)

5-5: LGTM! Clean import path refactor.

The import path change from @/lib/partners/constants to @/lib/constants/payouts is semantically appropriate for payout-related constants and aligns with the PR's objective of reorganizing constants into domain-specific modules. The constant usage throughout the file (lines 152, 154-156, 159, 171) remains unaffected.

apps/web/scripts/stripe/fix-processed-payouts.ts (1)

1-1: LGTM! Clean refactor.

The import path update correctly reflects the reorganization of constants into domain-specific modules. Moving MIN_WITHDRAWAL_AMOUNT_CENTS to @/lib/constants/payouts improves code organization by grouping payout-related constants together.

apps/web/ui/partners/payout-status-descriptions.ts (1)

1-1: LGTM! Import path refactored for better organization.

The import path has been updated to use the new domain-specific constants module, improving code organization by consolidating payout-related constants in a dedicated location.

apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx (1)

4-7: LGTM! Clean refactoring to domain-specific constants.

The import path change appropriately moves payout-related constants to a dedicated module, improving code organization and maintainability.

apps/web/lib/stripe/payment-methods.ts (1)

1-1: LGTM! Clean refactor to domain-specific constants module.

The import path change from "../partners/constants" to "@/lib/constants/payouts" appropriately moves the constant to a more specific, domain-focused module. This aligns well with the PR objective of reorganizing constants.

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-details-sheet.tsx (1)

1-1: LGTM! Clean refactoring to domain-specific constants module.

The import path update moves PAYOUTS_SHEET_ITEMS_LIMIT to the dedicated payouts constants module, improving code organization and maintainability.

apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/partner-payout-details-sheet.tsx (1)

1-4: LGTM! Effective consolidation of payout-related constants.

Both INVOICE_AVAILABLE_PAYOUT_STATUSES and PAYOUTS_SHEET_ITEMS_LIMIT are appropriately moved to the dedicated payouts constants module, improving code organization and discoverability.

apps/web/ui/modals/add-payment-method-modal.tsx (1)

3-3: Import path correctly updated — constant verified at new location.

The DIRECT_DEBIT_PAYMENT_TYPES_INFO constant is properly exported from apps/web/lib/constants/payouts.ts (line 14), and the import refactor on line 3 is valid. No further changes needed.

apps/web/scripts/migrations/backfill-invoice-payment-method.ts (1)

1-1: Import path change verified and correct.

The verification confirms that STRIPE_PAYMENT_METHOD_NORMALIZATION is properly exported from @/lib/constants/payouts and the import in the migration script is correctly updated. Related files have also been updated to use the new import path.

apps/web/lib/actions/partners/confirm-payouts.ts (1)

8-12: LGTM! Import path refactoring verified as complete and correct.

Verification confirms:

  • No remaining imports from the old @/lib/partners/constants location
  • New constants file (@/lib/constants/payouts) properly exports PAYMENT_METHOD_TYPES and STRIPE_PAYMENT_METHOD_NORMALIZATION
  • All codebase references updated to use the new path
  • Constants unchanged, only relocated for better organization
apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/partner-payout-invoice.tsx (1)

1-1: No action needed – import path is valid and constant value is preserved.

The import path change is correct. The constant FAST_ACH_FEE_CENTS is properly exported from @/lib/constants/payouts.ts at line 6 with its original value of 2500 ($25). This is the only import of this constant in the codebase, confirming the refactoring is complete and consistent.

apps/web/ui/partners/confirm-payouts-sheet.tsx (1)

4-7: Refactoring verified as complete and correct.

The import path change from @/lib/partners/constants to @/lib/constants/payouts is properly implemented:

  • New constants file exists and exports both FAST_ACH_FEE_CENTS and DIRECT_DEBIT_PAYMENT_METHOD_TYPES
  • No remaining imports from the old path
  • Constants are used correctly in the file
apps/web/lib/partners/create-stripe-transfer.ts (1)

1-4: Import path migration is correct and verified.

The constants have been successfully migrated to the centralized @/lib/constants/payouts module. Verification confirms:

  • ✓ Module exists and correctly exports BELOW_MIN_WITHDRAWAL_FEE_CENTS and MIN_WITHDRAWAL_AMOUNT_CENTS
  • ✓ The import in this file uses the correct new path
  • ✓ The migration is consistent across the codebase (other files also import from this location)
apps/web/app/(ee)/api/cron/payouts/process/process-payouts.ts (1)

5-10: Good refactoring - payout constants moved to dedicated module.

The reorganization of payout-related constants into @/lib/constants/payouts improves code organization and domain separation. All three imported constants (DIRECT_DEBIT_PAYMENT_METHOD_TYPES, FAST_ACH_FEE_CENTS, FOREX_MARKUP_RATE) are properly exported from the new module and correctly used throughout the file.

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page-client.tsx (1)

3-3: LGTM: Import path refactor.

The import path update aligns with the PR's goal of reorganizing constants into domain-specific modules.

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/import-export-buttons.tsx (1)

3-3: LGTM: Import path refactor.

The import path update consolidates program-related constants as intended.

apps/web/lib/constants/misc.ts (1)

1-2: LGTM: Clean constant definitions.

The new miscellaneous constants module provides clear, straightforward constant definitions.

apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx (1)

3-3: LGTM: Import path refactor.

The import path consolidation for payout-related constants is appropriate.

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx (1)

4-4: LGTM: Improved separation of concerns.

Moving constants out of zod schemas into a dedicated constants module is a good practice that improves code organization.

apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx (2)

3-3: LGTM: Import path refactor.

The import path consolidation is consistent with the PR's reorganization objectives.


255-255: Verify the necessity of Uint8Array wrapping.

The PDF buffer is now explicitly wrapped in Uint8Array. Since renderToBuffer returns a Node.js Buffer (which extends Uint8Array), the explicit conversion should be functionally equivalent. However, this could be:

  • A fix for type compatibility in certain environments (e.g., edge runtime)
  • Defensive coding for cross-environment compatibility

Please verify whether this change addresses a specific issue or is purely precautionary.

apps/web/lib/constants/program.ts (1)

1-29: LGTM: Well-structured program constants module.

The new program constants module provides clean, well-organized constant definitions with appropriate TypeScript type safety (as const).

apps/web/lib/swr/use-program-enrollment.ts (1)

1-1: LGTM: Import path refactor.

The change from relative to absolute import path improves maintainability and aligns with the centralized constants organization.

apps/web/app/(ee)/api/partner-profile/programs/[programId]/analytics/route.ts (1)

5-5: LGTM! Clean refactoring.

The import path update for LARGE_PROGRAM_MIN_TOTAL_COMMISSIONS_CENTS aligns with the PR's objective to organize constants into domain-specific modules. The constant usage remains unchanged.

apps/web/app/(ee)/api/partner-profile/programs/[programId]/customers/[customerId]/route.ts (1)

6-6: LGTM! Consistent refactoring.

Import path updated consistently with the broader constants reorganization.

apps/web/app/(ee)/api/partner-profile/programs/[programId]/events/route.ts (1)

5-5: LGTM! Consistent with the refactoring pattern.

The import path update maintains consistency across the codebase.

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/customers/[customerId]/page-client.tsx (1)

3-3: LGTM! Appropriate categorization.

Moving CUSTOMER_PAGE_EVENTS_LIMIT to the misc constants module is a logical choice for this UI-level constant.

apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/partners/form.tsx (1)

4-4: LGTM! Well-organized.

Centralizing program-related constants improves code organization and discoverability.

apps/web/app/(ee)/api/partner-profile/invites/route.ts (1)

5-8: LGTM! Clear domain separation.

Grouping partner profile-related constants in a dedicated module enhances maintainability.

apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page-client.tsx (1)

3-3: LGTM! Consistent refactoring.

Import path updated consistently with other files using CUSTOMER_PAGE_EVENTS_LIMIT.

apps/web/ui/modals/invite-partner-user-modal.tsx (1)

1-1: LGTM! Consistent with API route changes.

The import path aligns with the same constant's relocation in the API route handlers.

apps/web/app/(ee)/api/embed/referrals/earnings/route.ts (1)

1-1: LGTM! Clean import reorganization.

The constant has been appropriately moved to the misc module, improving code organization without affecting functionality.

apps/web/lib/actions/partners/reject-bounty-submission.ts (1)

5-5: LGTM! Better separation of concerns.

Moving the rejection reasons constant from the schema file to the dedicated bounties constants module improves code organization.

apps/web/app/(ee)/app.dub.co/embed/referrals/earnings.tsx (1)

1-1: LGTM! Consistent with API route changes.

The import path update aligns with the constant reorganization across the codebase, maintaining consistency between frontend and backend.

apps/web/lib/constants/partner-profile.ts (1)

1-2: LGTM! Clean constant definitions.

The partner-profile constants are now properly organized in their own module with clear, descriptive names.

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty-sheet.tsx (1)

3-3: LGTM! Appropriate domain-specific organization.

The bounty description constant is now properly located in the bounties constants module, aligning with the PR's goal of domain-specific organization.

apps/web/lib/zod/schemas/program-onboarding.ts (1)

1-1: LGTM! Domain-specific constant organization.

Moving the program onboarding limit to the program constants module improves code organization and maintainability.

apps/web/lib/actions/partners/create-bounty-submission.ts (1)

6-10: LGTM! Improved naming convention and organization.

The constant renaming from MAX_BOUNTY_SUBMISSION_* to BOUNTY_MAX_SUBMISSION_* improves consistency by prefixing with the domain name, making related constants easier to discover and group together.

apps/web/ui/partners/reject-bounty-submission-modal.tsx (1)

2-5: LGTM! Consistent constant reorganization.

The constants are now properly sourced from the centralized bounties module, while the schema appropriately remains in the zod schemas module. The naming convention aligns with other bounty constants in this PR.

apps/web/lib/types.ts (1)

26-26: LGTM! Clean refactoring to centralized constants.

The import path and type definition have been correctly updated to reference the new centralized constants module, maintaining type safety and consistency.

Also applies to: 594-594

apps/web/ui/partners/bounties/claim-bounty-modal.tsx (2)

3-8: LGTM! Imports updated correctly.

The import statement has been properly updated to reference the centralized constants module, improving code organization and maintainability.


375-377: LGTM! Constants used consistently.

All references to bounty submission limits and rejection reasons have been correctly updated to use the centralized constants, maintaining consistency throughout the component.

Also applies to: 503-505, 556-556, 589-589, 595-595, 603-605

apps/web/lib/zod/schemas/bounties.ts (2)

1-5: LGTM! Clean separation of concerns.

The schema file now correctly imports constants from the centralized module, eliminating the need to co-locate constants with schemas and improving maintainability.


22-22: LGTM! Schema validations updated correctly.

The schema definitions correctly reference the centralized constants for validation rules, maintaining the same validation behavior while improving code organization.

Also applies to: 157-157

apps/web/lib/constants/bounties.ts (1)

1-19: LGTM! Well-structured centralized constants.

This new constants file successfully centralizes all bounty-related configuration values with proper typing (as const for type narrowing) and clear, consistent naming conventions. The organization significantly improves maintainability and provides a single source of truth for bounty-related limits and validation rules.


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.

@steven-tey
Copy link
Collaborator Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 9, 2025

✅ Actions performed

Full review triggered.

@steven-tey steven-tey merged commit 590bb54 into main Nov 9, 2025
9 of 10 checks passed
@steven-tey steven-tey deleted the rearrange-constants branch November 9, 2025 20:39
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