Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Hide sale amount on partner customer earnings table when revenue is hidden.

Kiran Kc121cf82b460
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page-client.tsx
index c911a37d48..030adea58b 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page-client.tsx
@@ -1,6 +1,7 @@
"use client";
import { CUSTOMER_PAGE_EVENTS_LIMIT } from "@/lib/constants/misc";
+import { isPartnerRevenueHidden } from "@/lib/partners/is-partner-revenue-hidden";
import usePartnerCustomer from "@/lib/swr/use-partner-customer";
import {
usePartnerProfileEarnings,
@@ -162,6 +163,7 @@ export function ProgramCustomerPageClient() {
const EarningsTable = memo(({ customerId }: { customerId: string }) => {
const { programSlug } = useParams();
+ const { programEnrollment } = useProgramEnrollment();
const { data: earningsData, isLoading: isEarningsLoading } =
usePartnerProfileEarnings({
@@ -190,6 +192,7 @@ const EarningsTable = memo(({ customerId }: { customerId: string }) => {
}
viewAllHref={`/programs/${programSlug}/earnings?interval=all&customerId=${customerId}`}
isLoading={isEarningsLoading}
+ hideSaleAmount={isPartnerRevenueHidden(programEnrollment?.group)}
/>
);
});
diff --git a/apps/web/ui/customers/customer-sales-table.tsx b/apps/web/ui/customers/customer-sales-table.tsx
index 6be0f54e9e..d6b4eea7f6 100644
--- a/apps/web/ui/customers/customer-sales-table.tsx
+++ b/apps/web/ui/customers/customer-sales-table.tsx
@@ -1,4 +1,4 @@
-import { CommissionResponse, SaleEvent } from "@/lib/types";
+import { PartnerEarningsResponse, SaleEvent } from "@/lib/types";
import { StatusBadge, TimestampTooltip } from "@dub/ui";
import { currencyFormatter, formatDateTimeSmart, nFormatter } from "@dub/utils";
import {
@@ -9,26 +9,27 @@ import {
import Link from "next/link";
import { CommissionStatusBadges } from "../partners/commission-status-badges";
+type SalesTableRow =
+ | Pick<SaleEvent, "timestamp" | "eventName" | "saleAmount">
+ | Pick<
+ PartnerEarningsResponse,
+ "createdAt" | "amount" | "earnings" | "status"
+ >;
+
export function CustomerSalesTable({
sales,
totalSales,
isLoading,
viewAllHref,
+ hideSaleAmount,
}: {
- sales?:
- | Pick<SaleEvent, "timestamp" | "eventName" | "saleAmount">[]
- | Pick<
- CommissionResponse,
- "createdAt" | "amount" | "earnings" | "status"
- >[];
+ sales?: SalesTableRow[];
totalSales?: number;
isLoading?: boolean;
viewAllHref?: string;
+ hideSaleAmount?: boolean;
}) {
- const table = useReactTable<
- | Pick<SaleEvent, "timestamp" | "eventName" | "saleAmount">
- | Pick<CommissionResponse, "createdAt" | "amount" | "earnings" | "status">
- >({
+ const table = useReactTable<SalesTableRow>({
data: sales || [],
columns: [
{
@@ -55,11 +56,18 @@ export function CustomerSalesTable({
},
]
: []),
- {
- header: "Amount",
- accessorFn: (d) => ("saleAmount" in d ? d.saleAmount : d.amount),
- cell: ({ getValue }) => <span>{currencyFormatter(getValue())}</span>,
- },
+ ...(!hideSaleAmount
+ ? [
+ {
+ header: "Amount",
+ accessorFn: (d) =>
+ ("saleAmount" in d ? d.saleAmount : d.amount) ?? 0,
+ cell: ({ getValue }) => (
+ <span>{currencyFormatter(getValue())}</span>
+ ),
+ },
+ ]
+ : []),
...(sales?.length && "earnings" in sales?.[0]
? [
{