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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/web/lib/webhook/sample-events/commission-created.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"totalLeads": 15,
"totalConversions": 10,
"totalSales": 10,
"totalSaleAmount": 100000,
"totalCommissions": 50000
},
"customer": {
Expand Down
1 change: 1 addition & 0 deletions apps/web/lib/zod/schemas/commissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const CommissionWebhookSchema = CommissionSchema.merge(
totalLeads: z.number(),
totalConversions: z.number(),
totalSales: z.number(),
totalSaleAmount: z.number(),
totalCommissions: z.number(),
}),
),
Expand Down
6 changes: 4 additions & 2 deletions apps/web/ui/customers/customer-partner-earnings-table.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CommissionResponse } from "@/lib/types";
import { StatusBadge } from "@dub/ui";
import { currencyFormatter, formatDateTimeSmart } from "@dub/utils";
import { currencyFormatter, formatDateTimeSmart, nFormatter } from "@dub/utils";
import {
flexRender,
getCoreRowModel,
Expand Down Expand Up @@ -124,7 +124,9 @@ export function CustomerPartnerEarningsTable({
href={viewAllHref ?? "#"}
className="flex items-center gap-1.5 font-medium text-neutral-700 hover:text-neutral-900"
>
{totalCommissions ?? (
{totalCommissions ? (
nFormatter(totalCommissions, { full: true })
) : (
<div className="size-3 animate-pulse rounded-md bg-neutral-100" />
Comment on lines +127 to 130
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Bug: Truthiness check hides valid 0 totals (shows loader instead of “0”).

Same issue here—0 commissions should render “0”, not the loading placeholder.

Apply this diff:

-              {totalCommissions ? (
+              {totalCommissions != null ? (
                 nFormatter(totalCommissions, { full: true })
               ) : (
                 <div className="size-3 animate-pulse rounded-md bg-neutral-100" />
               )}{" "}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{totalCommissions ? (
nFormatter(totalCommissions, { full: true })
) : (
<div className="size-3 animate-pulse rounded-md bg-neutral-100" />
{totalCommissions != null ? (
nFormatter(totalCommissions, { full: true })
) : (
<div className="size-3 animate-pulse rounded-md bg-neutral-100" />
)}{" "}
🤖 Prompt for AI Agents
In apps/web/ui/customers/customer-partner-earnings-table.tsx around lines
127-130, the current truthiness check treats 0 as falsy and shows the loading
placeholder; change the condition to explicitly check for null/undefined so zero
renders correctly — e.g. replace "totalCommissions ? ( ... ) : ( loader )" with
a nullish check like "totalCommissions != null ? (nFormatter(totalCommissions, {
full: true })) : (loader)" (or use "totalCommissions !== null &&
totalCommissions !== undefined") so 0 will display as "0" instead of the loader.

)}{" "}
results
Expand Down
6 changes: 4 additions & 2 deletions apps/web/ui/customers/customer-sales-table.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CommissionResponse, SaleEvent } from "@/lib/types";
import { StatusBadge } from "@dub/ui";
import { currencyFormatter, formatDateTimeSmart } from "@dub/utils";
import { currencyFormatter, formatDateTimeSmart, nFormatter } from "@dub/utils";
import {
flexRender,
getCoreRowModel,
Expand Down Expand Up @@ -143,7 +143,9 @@ export function CustomerSalesTable({
href={viewAllHref ?? "#"}
className="flex items-center gap-1.5 font-medium text-neutral-700 hover:text-neutral-900"
>
{totalSales ?? (
{totalSales ? (
nFormatter(totalSales, { full: true })
) : (
<div className="size-3 animate-pulse rounded-md bg-neutral-100" />
Comment on lines +146 to 149
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Bug: Truthiness check hides valid 0 totals (shows loader instead of “0”).

0 is a valid total; use a null/undefined check instead of a truthy check.

Apply this diff:

-              {totalSales ? (
+              {totalSales != null ? (
                 nFormatter(totalSales, { full: true })
               ) : (
                 <div className="size-3 animate-pulse rounded-md bg-neutral-100" />
               )}{" "}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{totalSales ? (
nFormatter(totalSales, { full: true })
) : (
<div className="size-3 animate-pulse rounded-md bg-neutral-100" />
{totalSales != null ? (
nFormatter(totalSales, { full: true })
) : (
<div className="size-3 animate-pulse rounded-md bg-neutral-100" />
)}{" "}
🤖 Prompt for AI Agents
In apps/web/ui/customers/customer-sales-table.tsx around lines 146 to 149, the
current truthy check hides valid zero totals and renders the loader for 0;
change the condition to explicitly check for null/undefined (e.g., totalSales !=
null) so 0 is treated as a valid value and rendered via nFormatter, while the
loader is shown only when totalSales is null or undefined.

)}{" "}
results
Expand Down