diff --git a/apps/web/app/api/customers/[id]/activity/route.ts b/apps/web/app/api/customers/[id]/activity/route.ts index 0188fdb429c..7e7deef5346 100644 --- a/apps/web/app/api/customers/[id]/activity/route.ts +++ b/apps/web/app/api/customers/[id]/activity/route.ts @@ -2,7 +2,6 @@ import { getCustomerEvents } from "@/lib/analytics/get-customer-events"; import { getCustomerOrThrow } from "@/lib/api/customers/get-customer-or-throw"; import { decodeLinkIfCaseSensitive } from "@/lib/api/links/case-sensitivity"; import { withWorkspace } from "@/lib/auth"; -import { verifyFolderAccess } from "@/lib/folder/permissions"; import { customerActivityResponseSchema } from "@/lib/zod/schemas/customer-activity"; import { prisma } from "@dub/prisma"; import { NextResponse } from "next/server"; @@ -16,46 +15,24 @@ export const GET = withWorkspace(async ({ workspace, params, session }) => { id: customerId, }); - if (!customer.linkId) { - return NextResponse.json( - customerActivityResponseSchema.parse({ - customer, - events: [], - ltv: 0, - timeToLead: null, - timeToSale: null, - link: null, - }), - ); - } + const events = await getCustomerEvents({ + customerId: customer.id, + }); - let [events, link] = await Promise.all([ - getCustomerEvents({ - customerId: customer.id, - }), + // get the first partner link that this customer interacted with + const firstLinkId = events[events.length - 1].link_id; - prisma.link.findUniqueOrThrow({ - where: { - id: customer.linkId!, - }, - select: { - id: true, - domain: true, - key: true, - shortLink: true, - folderId: true, - }, - }), - ]); - - if (link.folderId) { - await verifyFolderAccess({ - workspace, - userId: session.user.id, - folderId: link.folderId, - requiredPermission: "folders.read", - }); - } + let link = await prisma.link.findUniqueOrThrow({ + where: { + id: firstLinkId, + }, + select: { + id: true, + domain: true, + key: true, + shortLink: true, + }, + }); link = decodeLinkIfCaseSensitive(link); diff --git a/apps/web/lib/swr/use-partner-earnings-timeseries.ts b/apps/web/lib/swr/use-partner-earnings-timeseries.ts index 9ab49692c36..24eaefa04fd 100644 --- a/apps/web/lib/swr/use-partner-earnings-timeseries.ts +++ b/apps/web/lib/swr/use-partner-earnings-timeseries.ts @@ -32,7 +32,7 @@ export function usePartnerEarningsTimeseries( }), timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, }, - { include: ["type", "linkId", "customerId", "status"] }, + { include: ["type", "linkId", "customerId", "status", "payoutId"] }, )}`, fetcher, { diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx index 89aaebe780f..6602ba67160 100644 --- a/apps/web/ui/analytics/events/events-table.tsx +++ b/apps/web/ui/analytics/events/events-table.tsx @@ -373,7 +373,13 @@ export default function EventsTable({ minSize: 120, cell: ({ getValue }) => (
- {currencyFormatter(getValue() / 100)} + + {currencyFormatter(getValue() / 100, { + maximumFractionDigits: undefined, + // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated + trailingZeroDisplay: "stripIfInteger", + })} + USD
), diff --git a/apps/web/ui/customers/customer-partner-earnings-table.tsx b/apps/web/ui/customers/customer-partner-earnings-table.tsx index 161a7fa129d..337447a4abb 100644 --- a/apps/web/ui/customers/customer-partner-earnings-table.tsx +++ b/apps/web/ui/customers/customer-partner-earnings-table.tsx @@ -70,6 +70,7 @@ export function CustomerPartnerEarningsTable({ getCoreRowModel: getCoreRowModel(), }); + const As = viewAllHref ? Link : "div"; return (
{isLoading ? ( @@ -117,22 +118,18 @@ export function CustomerPartnerEarningsTable({ ))} - {viewAllHref && ( -
- {commissions.length} of - {totalCommissions ? ( - - {totalCommissions} - - ) : ( +
+ {commissions.length} of + + {totalCommissions ?? (
- )} + )}{" "} results -
- )} +
+
)}
diff --git a/apps/web/ui/customers/customer-sales-table.tsx b/apps/web/ui/customers/customer-sales-table.tsx index 9497efeb7ca..71af32542a2 100644 --- a/apps/web/ui/customers/customer-sales-table.tsx +++ b/apps/web/ui/customers/customer-sales-table.tsx @@ -91,6 +91,7 @@ export function CustomerSalesTable({ getCoreRowModel: getCoreRowModel(), }); + const As = viewAllHref ? Link : "div"; return (
{isLoading ? ( @@ -136,22 +137,18 @@ export function CustomerSalesTable({ ))} - {viewAllHref && ( -
- {sales.length} of - {totalSales ? ( - - {totalSales} - - ) : ( +
+ {sales.length} of + + {totalSales ?? (
- )} + )}{" "} results -
- )} +
+
)}
diff --git a/packages/ui/package.json b/packages/ui/package.json index ec5aea02f0d..bfaefc4c017 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.32", + "version": "0.2.34", "sideEffects": false, "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/packages/ui/src/content.ts b/packages/ui/src/content.ts index 865ead818ba..33a9377fba3 100644 --- a/packages/ui/src/content.ts +++ b/packages/ui/src/content.ts @@ -63,7 +63,7 @@ export const FEATURES_LIST = [ title: "Dub Integrations", description: "Connect Dub with your favorite tools", icon: ConnectedDotsFill, - href: "/docs/integrations", + href: "/integrations", }, ]; diff --git a/packages/ui/src/nav/content/product-content.tsx b/packages/ui/src/nav/content/product-content.tsx index 531898e5845..eb4ef3054af 100644 --- a/packages/ui/src/nav/content/product-content.tsx +++ b/packages/ui/src/nav/content/product-content.tsx @@ -23,7 +23,7 @@ const largeLinks = [ title: "Dub Integrations", description: "Connect Dub with your favorite tools", icon: ConnectedDotsFill, - href: "/docs/integrations", + href: "/integrations", }, ]; diff --git a/packages/ui/src/nav/nav.tsx b/packages/ui/src/nav/nav.tsx index 2902e4447c5..9233f2d6d49 100644 --- a/packages/ui/src/nav/nav.tsx +++ b/packages/ui/src/nav/nav.tsx @@ -27,13 +27,13 @@ export const navItems = [ name: "Product", content: ProductContent, childItems: FEATURES_LIST, - segments: ["/home", "/analytics", "/features", "/compare"], + segments: ["/home", "/analytics", "/features", "/compare", "/integrations"], }, { name: "Solutions", content: SolutionsContent, childItems: SOLUTIONS, - segments: ["/solutions"], + segments: ["/solutions", "/sdks"], }, { name: "Resources",