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.

add customer avatars to partner earnings table

Steven Tey969ff14c6cd3
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-table.tsx
index 51a41a935e..55a9ab331b 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/commissions/commission-table.tsx
@@ -90,12 +90,8 @@ const CommissionTableInner = memo(
},
{
header: "Customer",
- cell: ({ row }) => {
- if (!row.original.customer) {
- return "-";
- }
-
- return (
+ cell: ({ row }) =>
+ row.original.customer ? (
<div className="flex items-center gap-2">
<img
src={
@@ -115,8 +111,9 @@ const CommissionTableInner = memo(
{row.original.customer.email ?? row.original.customer.name}
</Link>
</div>
- );
- },
+ ) : (
+ "-"
+ ),
meta: {
filterParams: ({ row }) =>
row.original.customer
diff --git a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page-client.tsx b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page-client.tsx
index 6bfc78c5e5..bf61f6c2ad 100644
--- a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page-client.tsx
+++ b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page-client.tsx
@@ -11,8 +11,8 @@ import { CustomerDetailsColumn } from "@/ui/customers/customer-details-column";
import { CustomerSalesTable } from "@/ui/customers/customer-sales-table";
import { ProgramRewardList } from "@/ui/partners/program-reward-list";
import { BackLink } from "@/ui/shared/back-link";
-import { MoneyBill2, Tooltip, User } from "@dub/ui";
-import { fetcher } from "@dub/utils";
+import { MoneyBill2, Tooltip } from "@dub/ui";
+import { fetcher, OG_AVATAR_URL } from "@dub/utils";
import { notFound, useParams } from "next/navigation";
import { memo } from "react";
import useSWR from "swr";
@@ -46,9 +46,15 @@ export function ProgramCustomerPageClient() {
<div className="mb-10 mt-2">
<BackLink href={`/programs/${programSlug}/earnings`}>Earnings</BackLink>
<div className="mt-5 flex items-center gap-4">
- <div className="border-border-subtle flex size-12 items-center justify-center rounded-full border bg-gradient-to-t from-neutral-50">
- <User className="size-4 text-neutral-700" />
- </div>
+ {customer ? (
+ <img
+ src={`${OG_AVATAR_URL}${customer.id}`}
+ alt={customer.email ?? customer.id}
+ className="size-8 rounded-full"
+ />
+ ) : (
+ <div className="size-8 animate-pulse rounded-full bg-neutral-200" />
+ )}
<div className="flex flex-col gap-1">
{customer ? (
diff --git a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
index 512a5b6cfb..538e94c5cd 100644
--- a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
+++ b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
@@ -24,6 +24,7 @@ import {
formatDateTimeSmart,
getApexDomain,
getPrettyUrl,
+ OG_AVATAR_URL,
} from "@dub/utils";
import { Cell } from "@tanstack/react-table";
import Link from "next/link";
@@ -130,8 +131,15 @@ export function EarningsTablePartner({ limit }: { limit?: number }) {
scroll={false}
className="flex w-full items-center justify-between gap-2 px-4 py-2.5 transition-colors hover:bg-stone-100"
>
- <div className="truncate" title={row.original.customer.email}>
- {row.original.customer.email}
+ <div className="flex items-center gap-2">
+ <img
+ src={`${OG_AVATAR_URL}${row.original.customer.id}`}
+ alt={row.original.customer.email}
+ className="size-5 rounded-full"
+ />
+ <div className="truncate" title={row.original.customer.email}>
+ {row.original.customer.email}
+ </div>
</div>
<ChartActivity2 className="size-3.5 shrink-0" />
</Link>
diff --git a/apps/web/lib/zod/schemas/partner-profile.ts b/apps/web/lib/zod/schemas/partner-profile.ts
index 478bcff1a1..3d63f55a40 100644
--- a/apps/web/lib/zod/schemas/partner-profile.ts
+++ b/apps/web/lib/zod/schemas/partner-profile.ts
@@ -21,7 +21,6 @@ export const PartnerEarningsSchema = CommissionSchema.merge(
email: z
.string()
.transform((email) => email.replace(/(?<=^.).+(?=.@)/, "********")),
- avatar: z.string().nullable(),
})
.nullable(),
link: LinkSchema.pick({
diff --git a/apps/web/ui/customers/customer-sales-table.tsx b/apps/web/ui/customers/customer-sales-table.tsx
index 4ee6916146..0a7d017124 100644
--- a/apps/web/ui/customers/customer-sales-table.tsx
+++ b/apps/web/ui/customers/customer-sales-table.tsx
@@ -1,4 +1,4 @@
-import { PartnerEarningsResponse, SaleEvent } from "@/lib/types";
+import { CommissionResponse, SaleEvent } from "@/lib/types";
import { StatusBadge } from "@dub/ui";
import { currencyFormatter, formatDateTimeSmart } from "@dub/utils";
import {
@@ -18,7 +18,7 @@ export function CustomerSalesTable({
sales?:
| Pick<SaleEvent, "timestamp" | "eventName" | "saleAmount">[]
| Pick<
- PartnerEarningsResponse,
+ CommissionResponse,
"createdAt" | "amount" | "earnings" | "status"
>[];
totalSales?: number;
@@ -27,10 +27,7 @@ export function CustomerSalesTable({
}) {
const table = useReactTable<
| Pick<SaleEvent, "timestamp" | "eventName" | "saleAmount">
- | Pick<
- PartnerEarningsResponse,
- "createdAt" | "amount" | "earnings" | "status"
- >
+ | Pick<CommissionResponse, "createdAt" | "amount" | "earnings" | "status">
>({
data: sales || [],
columns: [
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 8e25526634..ec5aea02f0 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -1,7 +1,7 @@
{
"name": "@dub/ui",
"description": "UI components for Dub.co",
- "version": "0.2.31",
+ "version": "0.2.32",
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.mjs",