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

Skip to content

Conversation

@steven-tey
Copy link
Collaborator

@steven-tey steven-tey commented Jun 11, 2025

Summary by CodeRabbit

  • New Features

    • Added support for a new "custom" commission type, including filter options and icon representation in the UI.
  • Bug Fixes

    • Prevented marking "custom" commissions as duplicates, fraud, or canceled to maintain data integrity.
  • Style

    • Updated UI labels to use "Reward Details," "Reward structure," and "Reward amount" for improved clarity.
  • Refactor

    • Standardized and renamed enums related to commission and reward types for consistency across models and schemas.
    • Centralized commission type definitions and updated validation schemas accordingly.
    • Updated icon mappings and menu rendering logic to accommodate the new "custom" commission type.
  • Chores

    • Updated database schema and internal references to reflect new enum structures and naming conventions.
    • Added a script to convert manual payout records into commission entries for better data management.

@vercel
Copy link
Contributor

vercel bot commented Jun 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
dub ✅ Ready (Inspect) Visit Preview Jun 11, 2025 4:45pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 11, 2025

Warning

Rate limit exceeded

@devkiran has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between c07c88c and ed57990.

📒 Files selected for processing (1)
  • apps/web/scripts/convert-manual-commissions.ts (1 hunks)

Walkthrough

This change refactors commission and reward type handling across the codebase, introducing new enums (RewardStructure, EventType) and updating schema, validation, and UI logic accordingly. It adds support for a new "custom" commission type, prevents certain actions for this type, and updates UI labels and icons to reflect these changes.

Changes

Files/Group Change Summary
packages/prisma/schema/commission.prisma
.../discount.prisma
.../program.prisma
.../reward.prisma
Refactored enums: introduced EventType and RewardStructure, removed old CommissionType, updated model fields, and added "custom" type.
packages/prisma/client.ts Replaced export of CommissionType with RewardStructure.
apps/web/lib/zod/schemas/commissions.ts
.../discount.ts
.../program-onboarding.ts
.../rewards.ts
Updated Zod schemas to use new enums, centralized and extended allowed types, especially for "custom".
apps/web/lib/actions/partners/mark-commission-duplicate.ts
.../mark-commission-fraud-or-canceled.ts
Added validation to prevent marking "custom" commissions as duplicate, fraud, or canceled.
apps/web/lib/api/sales/construct-reward-amount.ts
.../rewardful/import-campaign.ts
.../scripts/tella/update-commissions.ts
Updated imports and type usage to reference new enums.
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/overview/page-client.tsx Updated type casting to use RewardStructure instead of CommissionType.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/use-commission-filters.tsx Added "custom" to commission type filter options.
apps/web/ui/partners/add-edit-reward-sheet.tsx Updated UI text labels for reward-related fields.
apps/web/ui/partners/comission-type-icon.tsx Added icon for "custom" type; renamed and extended icon mapping.
apps/web/ui/partners/commission-row-menu.tsx Prevented menu rendering for "custom" commission rows.
apps/web/scripts/convert-manual-commissions.ts Added new script to convert manual payouts into commission records.
apps/web/app/(ee)/api/partner-profile/programs/[programId]/earnings/count/route.ts Filtered out null linkId values before querying commissions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant Backend
    participant DB

    User->>UI: Selects commission type (e.g., "custom")
    UI->>Backend: Submits commission action (e.g., mark as duplicate)
    Backend->>DB: Fetch commission details
    DB-->>Backend: Return commission (with type)
    alt If commission type is "custom"
        Backend-->>UI: Throw error ("You cannot mark a custom commission as ...")
    else
        Backend->>DB: Proceed with action (update status)
        DB-->>Backend: Confirm update
        Backend-->>UI: Action successful
    end
Loading

Possibly related PRs

Suggested reviewers

  • steven-tey

Poem

In the fields of code where enums grow,
A "custom" commission joins the show.
Icons shine and labels gleam,
Schemas updated, validation supreme.
No fraud or duplicate for custom's fate—
The bunnies hop to celebrate! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@steven-tey steven-tey marked this pull request as ready for review June 11, 2025 15:57
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🔭 Outside diff range comments (1)
packages/prisma/client.ts (1)

1-20: 💡 Verification agent

❓ Verification inconclusive

CommissionType is still implicitly re-exported via export *

Although CommissionType was removed from the explicit list (👍), the wildcard export on line 1 still exposes every enum from @prisma/client, so downstream code can continue to import CommissionType and bypass the refactor.

-export * from "@prisma/client";
+// Re-export selected members to avoid leaking deprecated enums.
+export {
+  CommissionStatus,
+  EventType,
+  FolderType,
+  FolderUserRole,
+  InvoiceStatus,
+  LinkStructure,
+  PartnerBannedReason,
+  PartnerProfileType,
+  PartnerRole,
+  PartnerStatus,
+  PayoutStatus,
+  Prisma,
+  ProgramEnrollmentStatus,
+  RewardStructure,
+  Role,
+  WebhookReceiver,
+} from "@prisma/client";

Alternatively, keep the wildcard and add an explicit export type CommissionType = never to cause compile-time failures wherever the old enum is referenced.


Avoid wildcard re-export to prevent leaking deprecated enums

The top-level export * from "@prisma/client" still exposes every enum—including the deprecated CommissionType—so downstream code can continue to import it. To fully remove CommissionType, either:

  • Replace the wildcard export with an explicit list of allowed exports:
    - export * from "@prisma/client";
    + // Re-export only supported members to avoid leaking deprecated enums
    + export {
    +   CommissionStatus,
    +   EventType,
    +   FolderType,
    +   FolderUserRole,
    +   InvoiceStatus,
    +   LinkStructure,
    +   PartnerBannedReason,
    +   PartnerProfileType,
    +   PartnerRole,
    +   PartnerStatus,
    +   PayoutStatus,
    +   Prisma,
    +   ProgramEnrollmentStatus,
    +   RewardStructure,
    +   Role,
    +   WebhookReceiver,
    + } from "@prisma/client";
  • Or keep the wildcard but explicitly block CommissionType:
    export * from "@prisma/client";
    export type CommissionType = never;

File: packages/prisma/client.ts
Lines: 1–20

🧹 Nitpick comments (8)
apps/web/scripts/tella/update-commissions.ts (1)

20-38: Concurrent DB calls: throttle to avoid connection exhaustion

Promise.all fires 50 commission.update queries in parallel.
If this script is ever pointed at a larger batch (or the default take is removed), it can easily exceed the pool size. Consider p-map with a concurrency limit or a simple for … of loop with await.

apps/web/lib/rewardful/import-campaign.ts (1)

36-40: Handle unexpected reward_type values explicitly

reward_type === "amount" ? … : … silently treats every non-amount value as percentage.
A defensive switch improves clarity and surfaces API drifts:

-let newType =
-  reward_type === "amount"
-    ? RewardStructure.flat
-    : RewardStructure.percentage;
+let newType: RewardStructure;
+switch (reward_type) {
+  case "amount":
+    newType = RewardStructure.flat;
+    break;
+  case "percentage":
+    newType = RewardStructure.percentage;
+    break;
+  default:
+    throw new Error(`Unsupported reward_type: ${reward_type}`);
+}
apps/web/ui/partners/commission-row-menu.tsx (1)

48-50: Good guard, but rely on enum constant not magic string

Prefer the generated enum to avoid typos and refactor churn:

-import { CommissionType } from "@dub/prisma/client";
-
-if (row.original.type === "custom") {
+if (row.original.type === CommissionType.custom) {
   return null;
 }
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/use-commission-filters.tsx (1)

79-83: Hard-coded filter list duplicated across files

The literal array ["click", "lead", "sale", "custom"] is now the third place this list appears. Consider extracting to a shared constant (e.g. COMMISSION_EVENT_TYPES) to avoid drift when another type is added.

- options: ["click", "lead", "sale", "custom"].map((slug) => ({
+ import { COMMISSION_EVENT_TYPES } from "@/lib/constants";
+ options: COMMISSION_EVENT_TYPES.map((slug) => ({
apps/web/lib/api/sales/construct-reward-amount.ts (1)

1-12: Compare against the enum value instead of string literal

RewardStructure is emitted by Prisma as both a value object and a type union.
Using the value object prevents silent breakage if the enum member is renamed:

-return type === "percentage"
+return type === RewardStructure.percentage

This keeps the comparison type-safe and discoverable by IDE refactors.

packages/prisma/schema/commission.prisma (1)

11-16: Consider documenting / constraining the new custom type

custom commissions don’t clearly map to either amount (sale) or quantity (click/lead).
Without nullable fields or a check constraint, consumers may have to populate both columns with sentinel values to satisfy NOT NULL.

Options:

  • Make amount & quantity nullable and add a @@check ensuring exactly one is non-null per type.
  • Keep them required but add a migration script & code-level guard that enforces one or the other.

This avoids bad data and simplifies downstream logic.

apps/web/ui/partners/comission-type-icon.tsx (2)

11-16: Mark the icon map as immutable for safer typings

Add as const to preserve literal types and prevent accidental mutation:

-const ICONS_MAP = {
+const ICONS_MAP = {
   click: { icon: CursorRays, className: "text-blue-500" },
   lead: { icon: UserCheck, className: "text-purple-500" },
   sale: { icon: InvoiceDollar, className: "text-teal-500" },
   custom: { icon: MoneyBills2, className: "text-gray-500" },
-};
+} as const;

25-27: Graceful fallback for unexpected types

ICONS_MAP[type] will throw if an unknown type is passed.
Provide a default icon to avoid runtime errors:

-const { icon: Icon, className: iconClassName } = ICONS_MAP[type];
+const { icon: Icon, className: iconClassName } =
+  ICONS_MAP[type] ?? ICONS_MAP.sale; // fallback
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39cfbfd and f15da9a.

📒 Files selected for processing (19)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/overview/page-client.tsx (2 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/use-commission-filters.tsx (1 hunks)
  • apps/web/lib/actions/partners/mark-commission-duplicate.ts (1 hunks)
  • apps/web/lib/actions/partners/mark-commission-fraud-or-canceled.ts (1 hunks)
  • apps/web/lib/api/sales/construct-reward-amount.ts (1 hunks)
  • apps/web/lib/rewardful/import-campaign.ts (2 hunks)
  • apps/web/lib/zod/schemas/commissions.ts (2 hunks)
  • apps/web/lib/zod/schemas/discount.ts (2 hunks)
  • apps/web/lib/zod/schemas/program-onboarding.ts (2 hunks)
  • apps/web/lib/zod/schemas/rewards.ts (3 hunks)
  • apps/web/scripts/tella/update-commissions.ts (2 hunks)
  • apps/web/ui/partners/add-edit-reward-sheet.tsx (3 hunks)
  • apps/web/ui/partners/comission-type-icon.tsx (2 hunks)
  • apps/web/ui/partners/commission-row-menu.tsx (1 hunks)
  • packages/prisma/client.ts (1 hunks)
  • packages/prisma/schema/commission.prisma (2 hunks)
  • packages/prisma/schema/discount.prisma (1 hunks)
  • packages/prisma/schema/program.prisma (0 hunks)
  • packages/prisma/schema/reward.prisma (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/prisma/schema/program.prisma
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (14)
packages/prisma/schema/discount.prisma (1)

4-6: Migration reminder: existing rows need enum translation

Changing type from CommissionTypeRewardStructure will leave existing rows with the old enum value.
Ensure the migration script updates stored values (flat/percentage) before applying the new enum, otherwise deploys will fail.

apps/web/lib/rewardful/import-campaign.ts (1)

32-48: findFirst equality check ignores undefined but not null

maxDuration is included in the where clause even when it is null, restricting the lookup to rewards whose maxDuration IS NULL.
If the intention is to ignore the field when the API omits it, pass undefined instead of null (or remove the property when falsy).

apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/overview/page-client.tsx (2)

8-8: Switched to RewardStructure enum – looks good

Import correctly aligns with the schema refactor.


76-76:

Details

❓ Verification inconclusive

Verify RewardStructure still contains the "flat" literal

(data.type ?? "flat") as RewardStructure assumes "flat" exists in the new enum. If the enum was also renamed or its members were changed (e.g. FIXED instead of flat), this will compile-error or, worse, cast an invalid value at runtime in JS.


🏁 Script executed:

#!/bin/bash
# Confirm that "flat" is still a member of RewardStructure in the Prisma schema
rg -n '"flat"' packages/prisma | head

Length of output: 39


Verify RewardStructure still includes the "flat" literal

Please confirm that the Prisma schema’s RewardStructure enum (in packages/prisma/schema.prisma) and the generated client still define a member named flat. The expression

type: (data.type ?? "flat") as RewardStructure,

will either fail to compile or cast an invalid value at runtime if flat was renamed, removed, or changed (e.g. to FIXED).

• Location: apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/overview/page-client.tsx line 76
• Snippet:

type: (data.type ?? "flat") as RewardStructure,
apps/web/lib/actions/partners/mark-commission-fraud-or-canceled.ts (1)

35-39: Good guard against invalid state transitions

Early-out prevents "custom" commissions from being marked fraud/canceled, matching new business rules.

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

1-1: Enum import updated correctly

RewardStructure replaces CommissionType without changing external API.


36-36: Schema now tied to RewardStructure – ensure default value handled

Because type is now nullish, callers relying on a default "flat" need to set it explicitly (as done in page-client.tsx). Just double-check tests cover the null case.

apps/web/ui/partners/add-edit-reward-sheet.tsx (1)

602-636: Copy changes only – UI strings consistent with new terminology

Renaming to “Reward …” keeps the UI aligned with backend enums. No functional impact detected.

packages/prisma/schema/commission.prisma (1)

28-31: Default value missing for the renamed enum

type CommissionType lost its @default after the refactor.
If legacy inserts relied on the previous default, they will now fail.
Add an explicit default (e.g., @default(sale)) or migrate application code to always supply type.

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

1-2: Good move to RewardStructure

Importing the new enum keeps schemas consistent with the DB layer.


24-30: Verify default value alignment

createDiscountSchema defaults type to "flat" while the Prisma model’s default (per migration summary) is "percentage".
Confirm this intentional divergence; otherwise, choose one authoritative default to avoid confusion.

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

1-1: Import looks good – verify dead-code

EventType is still imported but no longer changed in this diff. If it’s unused after the wider refactor, drop the import to keep tree-shaking tight.


23-24: Schema now enforces RewardStructure – ✅

Switching to the dedicated enum tightens validation and matches the Prisma schema.

packages/prisma/schema/reward.prisma (1)

1-10: Enums introduced cleanly

Introducing EventType and RewardStructure directly in the schema makes downstream typing clearer. Values follow Prisma’s convention and the defaults line up with existing data, so no concerns here.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🔭 Outside diff range comments (1)
apps/web/scripts/convert-manual-commissions.ts (1)

74-75: 🛠️ Refactor suggestion

Exit with proper error code on failure

Unhandled promise rejections will be swallowed under some Node versions. Attach a catcher so CI/cron jobs fail loudly.

-main();
+main().catch((err) => {
+  console.error(err);
+  process.exit(1);
+});
🧹 Nitpick comments (1)
apps/web/scripts/convert-manual-commissions.ts (1)

9-19: Limit the SELECT list for better IO and privacy

include: { partner: true } fetches the entire partner record, but the script only needs partner.name. Use select to reduce payload and avoid unintentionally loading PII.

-    include: {
-      partner: true,
-    },
+    select: {
+      id: true,
+      amount: true,
+      partnerId: true,
+      programId: true,
+      partner: { select: { name: true } },
+    },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f15da9a and 312ec79.

📒 Files selected for processing (2)
  • apps/web/scripts/convert-manual-commissions.ts (1 hunks)
  • packages/prisma/schema/commission.prisma (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/prisma/schema/commission.prisma
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (2)
apps/web/scripts/convert-manual-commissions.ts (2)

52-65: Consider setting amount instead of earnings only

Down-stream code often expects amount to reflect the original transaction value. Storing it as zero while duplicating it in earnings may break metrics or validations.

Confirm the domain rules; if zero is intentional, leave a comment explaining why to avoid future confusion.


1-5: Imports & env bootstrapping look good

dotenv-flow/config early-loads env vars before Prisma is touched – nice touch, keeps local execution friction-free.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
apps/web/app/(ee)/api/partner-profile/programs/[programId]/earnings/count/route.ts (2)

69-71: Deduplicate IDs before querying Prisma

Filtering out null IDs is a solid fix.
However, the resulting array can still include duplicates, creating unnecessary work for the database and transferring redundant data over the wire. De-dupe cheaply with Set:

-              in: counts
-                .map(({ linkId }) => linkId)
-                .filter((id): id is string => id !== null),
+              in: Array.from(
+                new Set(
+                  counts
+                    .map(({ linkId }) => linkId)
+                    .filter((id): id is string => id !== null)
+                )
+              ),

This keeps the query lean without changing behaviour.


75-85: Drop the any escape hatch and keep type safety

as any[] sacrifices compile-time guarantees and can hide future regressions.
Define an explicit result shape and rely on inference:

interface LinkCount {
  id: string | null;
  domain?: string | null;
  key?: string | null;
  url?: string | null;
  _count: number;
}

counts = counts.map(({ linkId, _count }): LinkCount => {
  const link = links.find((l) => l.id === linkId);
  return {
    id: linkId,
    domain: link?.domain,
    key: link?.key,
    url: link?.url,
    _count,
  };
});

You retain type safety with minimal extra code.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 312ec79 and 93f4da4.

📒 Files selected for processing (1)
  • apps/web/app/(ee)/api/partner-profile/programs/[programId]/earnings/count/route.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@bug0-qa-agent
Copy link

bug0-qa-agent bot commented Jun 11, 2025

🤖 Bug0 QA Agent

Here are the results of the automated tests for PR #2513:

To re-run the tests, please comment /bug0 run or push a new commit to this PR.

@steven-tey steven-tey merged commit 529499e into main Jun 11, 2025
8 checks passed
@steven-tey steven-tey deleted the manual-commission branch June 11, 2025 16:49
@coderabbitai coderabbitai bot mentioned this pull request Jun 12, 2025
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.

3 participants