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 redirects / rename files / remove old scripts & schema

Steven Tey9f9101f6dc8a
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/analytics/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/analytics/page.tsx
index df172c5d59..44549dca69 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/analytics/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/analytics/page.tsx
@@ -1,7 +1,7 @@
import Analytics from "@/ui/analytics";
import { PageContent } from "@/ui/layout/page-content";
-export default function PartnerAnalytics() {
+export default function PartnerProgramAnalyticsPage() {
return (
<PageContent title="Analytics">
<Analytics />
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/page-client.tsx
deleted file mode 100644
index dc8c8842f4..0000000000
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/page-client.tsx
+++ /dev/null
@@ -1,120 +0,0 @@
-"use client";
-
-import { usePartnerProgramBounties } from "@/lib/swr/use-partner-program-bounties";
-import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
-import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
-import { Heart, Trophy } from "@dub/ui/icons";
-import { cn } from "@dub/utils";
-import { useParams } from "next/navigation";
-import { useMemo, useState } from "react";
-import { PartnerBountyCard, PartnerBountyCardSkeleton } from "./bounty-card";
-
-const tabs = [
- {
- label: "Active",
- id: "active",
- },
- {
- label: "Expired",
- id: "expired",
- },
-] as const;
-
-export function BountiesPageClient() {
- const { programSlug } = useParams();
- const [activeTab, setActiveTab] = useState<"active" | "expired">("active");
- const { bounties, bountiesCount, isLoading } = usePartnerProgramBounties();
- // Filter bounties based on active tab
- const filteredBounties = useMemo(() => {
- if (!bounties) return [];
-
- const now = new Date();
- return bounties.filter((bounty) => {
- const isExpired = bounty.endsAt && new Date(bounty.endsAt) <= now;
-
- if (activeTab === "active") {
- return !isExpired;
- } else {
- return isExpired;
- }
- });
- }, [bounties, activeTab]);
-
- return (
- <PageWidthWrapper className="pb-10">
- <div className="mb-4 grid grid-cols-2 gap-2">
- {tabs.map((tab) => {
- const isActive = activeTab === tab.id;
-
- return (
- <button
- key={tab.id}
- type="button"
- className={cn(
- "border-border-subtle flex flex-col gap-1 rounded-lg border p-4 text-left transition-colors duration-100",
- isActive
- ? "border-black ring-1 ring-black"
- : "hover:bg-bg-muted",
- )}
- onClick={() => setActiveTab(tab.id)}
- >
- <span className="text-content-default text-xs font-semibold">
- {tab.label}
- </span>
- {bounties ? (
- <span className="text-content-emphasis text-base font-semibold">
- {bountiesCount[tab.id].toLocaleString()}
- </span>
- ) : (
- <div className="h-6 w-12 animate-pulse rounded-md bg-neutral-200" />
- )}
- </button>
- );
- })}
- </div>
-
- {filteredBounties?.length !== 0 || isLoading ? (
- <div className="grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3">
- {filteredBounties?.length
- ? filteredBounties?.map((bounty) => (
- <PartnerBountyCard
- key={bounty.id}
- bounty={bounty}
- href={`/programs/${programSlug}/bounties/${bounty.id}`}
- />
- ))
- : Array.from({ length: 3 }, (_, index) => (
- <PartnerBountyCardSkeleton key={index} />
- ))}
- </div>
- ) : (
- <AnimatedEmptyState
- title="No bounties to collect"
- description={
- <>
- This program isn't offering any bounties at the moment.{" "}
- <a
- href="https://dub.co/help/article/program-bounties"
- target="_blank"
- rel="noopener noreferrer"
- className="hover:text-content-default underline sm:whitespace-nowrap"
- >
- Learn more about bounties
- </a>
- .
- </>
- }
- cardContent={(idx) => {
- const Icon = [Trophy, Heart][idx % 2];
- return (
- <>
- <Icon className="size-4 text-neutral-700" />
- <div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />
- </>
- );
- }}
- />
- )}
- </PageWidthWrapper>
- );
-}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/page.tsx
index dacdba7159..7258e9378a 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/page.tsx
@@ -1,10 +1,123 @@
+"use client";
+
+import { usePartnerProgramBounties } from "@/lib/swr/use-partner-program-bounties";
import { PageContent } from "@/ui/layout/page-content";
-import { BountiesPageClient } from "./page-client";
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
+import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
+import { Heart, Trophy } from "@dub/ui/icons";
+import { cn } from "@dub/utils";
+import { useParams } from "next/navigation";
+import { useMemo, useState } from "react";
+import { PartnerBountyCard, PartnerBountyCardSkeleton } from "./bounty-card";
+
+const tabs = [
+ {
+ label: "Active",
+ id: "active",
+ },
+ {
+ label: "Expired",
+ id: "expired",
+ },
+] as const;
+
+export default function PartnerProgramBountiesPage() {
+ const { programSlug } = useParams();
+ const [activeTab, setActiveTab] = useState<"active" | "expired">("active");
+ const { bounties, bountiesCount, isLoading } = usePartnerProgramBounties();
+ // Filter bounties based on active tab
+ const filteredBounties = useMemo(() => {
+ if (!bounties) return [];
+
+ const now = new Date();
+ return bounties.filter((bounty) => {
+ const isExpired = bounty.endsAt && new Date(bounty.endsAt) <= now;
+
+ if (activeTab === "active") {
+ return !isExpired;
+ } else {
+ return isExpired;
+ }
+ });
+ }, [bounties, activeTab]);
-export default function BountiesPage() {
return (
<PageContent title="Bounties">
- <BountiesPageClient />
+ <PageWidthWrapper className="pb-10">
+ <div className="mb-4 grid grid-cols-2 gap-2">
+ {tabs.map((tab) => {
+ const isActive = activeTab === tab.id;
+
+ return (
+ <button
+ key={tab.id}
+ type="button"
+ className={cn(
+ "border-border-subtle flex flex-col gap-1 rounded-lg border p-4 text-left transition-colors duration-100",
+ isActive
+ ? "border-black ring-1 ring-black"
+ : "hover:bg-bg-muted",
+ )}
+ onClick={() => setActiveTab(tab.id)}
+ >
+ <span className="text-content-default text-xs font-semibold">
+ {tab.label}
+ </span>
+ {bounties ? (
+ <span className="text-content-emphasis text-base font-semibold">
+ {bountiesCount[tab.id].toLocaleString()}
+ </span>
+ ) : (
+ <div className="h-6 w-12 animate-pulse rounded-md bg-neutral-200" />
+ )}
+ </button>
+ );
+ })}
+ </div>
+
+ {filteredBounties?.length !== 0 || isLoading ? (
+ <div className="grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3">
+ {filteredBounties?.length
+ ? filteredBounties?.map((bounty) => (
+ <PartnerBountyCard
+ key={bounty.id}
+ bounty={bounty}
+ href={`/programs/${programSlug}/bounties/${bounty.id}`}
+ />
+ ))
+ : Array.from({ length: 3 }, (_, index) => (
+ <PartnerBountyCardSkeleton key={index} />
+ ))}
+ </div>
+ ) : (
+ <AnimatedEmptyState
+ title="No bounties to collect"
+ description={
+ <>
+ This program isn't offering any bounties at the moment.{" "}
+ <a
+ href="https://dub.co/help/article/program-bounties"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="hover:text-content-default underline sm:whitespace-nowrap"
+ >
+ Learn more about bounties
+ </a>
+ .
+ </>
+ }
+ cardContent={(idx) => {
+ const Icon = [Trophy, Heart][idx % 2];
+ return (
+ <>
+ <Icon className="size-4 text-neutral-700" />
+ <div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />
+ </>
+ );
+ }}
+ />
+ )}
+ </PageWidthWrapper>
</PageContent>
);
}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/layout.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/layout.tsx
index 9860b364f8..1e0edb18e7 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/layout.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/layout.tsx
@@ -15,7 +15,7 @@ import { useParams, usePathname } from "next/navigation";
import { CSSProperties, ReactNode, useMemo, useState } from "react";
import * as z from "zod/v4";
-export default function PartnerCustomersLayout({
+export default function PartnerProgramCustomersLayout({
children,
}: {
children: ReactNode;
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/leads/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/leads/page.tsx
index e5ec1f97b7..0b42f170cb 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/leads/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/leads/page.tsx
@@ -26,7 +26,7 @@ import { cn, formatDate, nFormatter, OG_AVATAR_URL } from "@dub/utils";
import { Row } from "@tanstack/react-table";
import { useEffect, useMemo, useState } from "react";
-export default function PartnerSubmittedLeadsPage() {
+export default function PartnerProgramSubmittedLeadsPage() {
const { queryParams, searchParams } = useRouterStuff();
const { pagination, setPagination } = usePagination();
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page-client.tsx
deleted file mode 100644
index 8492cb86d0..0000000000
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page-client.tsx
+++ /dev/null
@@ -1,322 +0,0 @@
-"use client";
-
-import { PARTNER_CUSTOMERS_MAX_PAGE_SIZE } from "@/lib/constants/partner-profile";
-import usePartnerCustomers from "@/lib/swr/use-partner-customers";
-import usePartnerCustomersCount from "@/lib/swr/use-partner-customers-count";
-import useProgramEnrollment from "@/lib/swr/use-program-enrollment";
-import { CustomerRowItem } from "@/ui/customers/customer-row-item";
-import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
-import { CountryFlag } from "@/ui/shared/country-flag";
-import { SearchBoxPersisted } from "@/ui/shared/search-box";
-import {
- AnimatedSizeContainer,
- EditColumnsButton,
- Filter,
- LinkLogo,
- Table,
- TimestampTooltip,
- useColumnVisibility,
- usePagination,
- useRouterStuff,
- useTable,
-} from "@dub/ui";
-import { User } from "@dub/ui/icons";
-import { COUNTRIES, formatDate, getApexDomain, getPrettyUrl } from "@dub/utils";
-import { useParams, useRouter } from "next/navigation";
-import { useMemo } from "react";
-import { usePartnerCustomerFilters } from "./use-partner-customer-filters";
-
-export function ProgramCustomersPageClient() {
- const router = useRouter();
- const { searchParams, queryParams } = useRouterStuff();
-
- const { programSlug } = useParams<{ programSlug: string }>();
- const { programEnrollment } = useProgramEnrollment();
-
- const { data: customersCount, error: countError } =
- usePartnerCustomersCount();
- const { data: customers, isLoading, error } = usePartnerCustomers();
-
- const { pagination, setPagination } = usePagination(
- PARTNER_CUSTOMERS_MAX_PAGE_SIZE,
- );
-
- const sortBy = searchParams.get("sortBy") || "createdAt";
- const sortOrder = searchParams.get("sortOrder") === "asc" ? "asc" : "desc";
-
- const {
- filters,
- activeFilters,
- onSelect,
- onRemove,
- onRemoveAll,
- isFiltered,
- setSelectedFilter,
- } = usePartnerCustomerFilters();
-
- const customersColumns = {
- all: [
- "customer",
- "country",
- "link",
- "createdAt",
- "firstSaleAt",
- "subscriptionCanceledAt",
- ],
- defaultVisible: [
- "customer",
- "country",
- "link",
- "createdAt",
- "firstSaleAt",
- "subscriptionCanceledAt",
- ],
- };
-
- const { columnVisibility, setColumnVisibility } = useColumnVisibility(
- "partner-customers-table-columns",
- customersColumns,
- );
-
- const columns = useMemo(
- () =>
- [
- {
- id: "customer",
- header: "Customer",
- enableHiding: false,
- minSize: 250,
- cell: ({ row }) => {
- return <CustomerRowItem customer={row.original} />;
- },
- },
- {
- id: "country",
- header: "Country",
- accessorKey: "country",
- minSize: 150,
- cell: ({ row }) => {
- const country = row.original.country;
- return (
- <div className="flex items-center gap-2">
- {country && <CountryFlag countryCode={country} />}
- <span className="min-w-0 truncate">
- {(country ? COUNTRIES[country] : null) ?? "-"}
- </span>
- </div>
- );
- },
- },
- {
- id: "link",
- header: "Link",
- accessorKey: "activity.link",
- cell: ({ row }) =>
- row.original.activity.link ? (
- <a
- href={`/programs/${programSlug}/analytics?linkId=${row.original.activity.link.id}`}
- target="_blank"
- className="flex cursor-alias items-center gap-3 decoration-dotted underline-offset-2 hover:underline"
- >
- <LinkLogo
- apexDomain={getApexDomain(
- row.original.activity.link.shortLink,
- )}
- className="size-4 shrink-0 sm:size-4"
- />
- <span
- className="truncate"
- title={row.original.activity.link.shortLink}
- >
- {getPrettyUrl(row.original.activity.link.shortLink)}
- </span>
- </a>
- ) : (
- "-"
- ),
- size: 250,
- },
- {
- id: "createdAt",
- header: "Created",
- meta: {
- headerTooltip:
- "The date the customer was created (usually the signup date or trial start date).",
- },
- cell: ({ row }) => (
- <TimestampTooltip
- timestamp={row.original.createdAt}
- rows={["local"]}
- side="left"
- delayDuration={150}
- >
- <span>
- {formatDate(row.original.createdAt, { month: "short" })}
- </span>
- </TimestampTooltip>
- ),
- },
- {
- id: "firstSaleAt",
- header: "Paid",
- meta: {
- headerTooltip: "The date the customer made their first sale.",
- },
- cell: ({ row }) =>
- row.original.firstSaleAt ? (
- <TimestampTooltip
- timestamp={row.original.firstSaleAt}
- rows={["local"]}
- side="left"
- delayDuration={150}
- >
- <span>
- {formatDate(row.original.firstSaleAt, { month: "short" })}
- </span>
- </TimestampTooltip>
- ) : (
- "-"
- ),
- },
- {
- id: "subscriptionCanceledAt",
- header: "Canceled",
- meta: {
- headerTooltip: "The date the customer canceled their subscription.",
- },
- cell: ({ row }) =>
- row.original.subscriptionCanceledAt ? (
- <TimestampTooltip
- timestamp={row.original.subscriptionCanceledAt}
- rows={["local"]}
- side="left"
- delayDuration={150}
- >
- <span>
- {formatDate(row.original.subscriptionCanceledAt, {
- month: "short",
- })}
- </span>
- </TimestampTooltip>
- ) : (
- "-"
- ),
- },
- // Menu
- {
- id: "menu",
- enableHiding: false,
- header: () => <EditColumnsButton table={table} />,
- },
- ].filter((c) => c.id === "menu" || customersColumns.all.includes(c.id)),
- [programSlug],
- );
-
- const { table, ...tableProps } = useTable({
- data: customers || [],
- columns,
- columnPinning: { right: ["menu"] },
- onRowClick: (row, e) => {
- const url = `/programs/${programSlug}/customers/${row.original.id}`;
-
- if (e.metaKey || e.ctrlKey) window.open(url, "_blank");
- else router.push(url);
- },
- onRowAuxClick: (row) =>
- window.open(
- `/programs/${programSlug}/customers/${row.original.id}`,
- "_blank",
- ),
- rowProps: (row) => ({
- onPointerEnter: () => {
- router.prefetch(
- `/programs/${programSlug}/customers/${row.original.id}`,
- );
- },
- }),
- pagination,
- onPaginationChange: setPagination,
- columnVisibility,
- onColumnVisibilityChange: setColumnVisibility,
- sortableColumns: ["createdAt", "firstSaleAt", "subscriptionCanceledAt"],
- sortBy,
- sortOrder,
- onSortChange: ({ sortBy, sortOrder }) =>
- queryParams({
- set: {
- ...(sortBy && { sortBy }),
- ...(sortOrder && { sortOrder }),
- },
- del: "page",
- scroll: false,
- }),
- thClassName: "border-l-0",
- tdClassName: "border-l-0",
- resourceName: (p) => `customer${p ? "s" : ""}`,
- rowCount: customersCount || 0,
- loading: isLoading,
- error:
- error instanceof Error
- ? error.message
- : countError
- ? "Failed to load customers"
- : undefined,
- });
-
- return (
- <div className="flex flex-col gap-4">
- <div>
- <div className="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
- <Filter.Select
- className="w-full md:w-fit"
- filters={filters}
- activeFilters={activeFilters}
- onSelect={onSelect}
- onRemove={onRemove}
- onSelectedFilterChange={setSelectedFilter}
- />
- {Boolean(programEnrollment?.customerDataSharingEnabledAt) && (
- <SearchBoxPersisted
- placeholder="Search by email or name"
- inputClassName="md:w-[16rem]"
- />
- )}
- </div>
- <AnimatedSizeContainer height>
- <div>
- {activeFilters.length > 0 && (
- <div className="pt-3">
- <Filter.List
- filters={filters}
- activeFilters={activeFilters}
- onSelect={onSelect}
- onRemove={onRemove}
- onRemoveAll={onRemoveAll}
- />
- </div>
- )}
- </div>
- </AnimatedSizeContainer>
- </div>
-
- {customers?.length !== 0 ? (
- <Table {...tableProps} table={table} />
- ) : (
- <AnimatedEmptyState
- title={isFiltered ? "No customers found" : "No customers yet"}
- description={
- isFiltered
- ? "No customers found for the selected filters. Adjust your filters to refine your search results."
- : "No customers have been recorded for this program yet. Once customers start converting through your links, they'll appear here."
- }
- cardContent={() => (
- <>
- <User className="size-4 text-neutral-700" />
- <div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />
- </>
- )}
- />
- )}
- </div>
- );
-}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx
index 1738b844c5..20bac3ac8e 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx
@@ -1,5 +1,322 @@
-import { ProgramCustomersPageClient } from "./page-client";
+"use client";
-export default function ProgramCustomers() {
- return <ProgramCustomersPageClient />;
+import { PARTNER_CUSTOMERS_MAX_PAGE_SIZE } from "@/lib/constants/partner-profile";
+import usePartnerCustomers from "@/lib/swr/use-partner-customers";
+import usePartnerCustomersCount from "@/lib/swr/use-partner-customers-count";
+import useProgramEnrollment from "@/lib/swr/use-program-enrollment";
+import { CustomerRowItem } from "@/ui/customers/customer-row-item";
+import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
+import { CountryFlag } from "@/ui/shared/country-flag";
+import { SearchBoxPersisted } from "@/ui/shared/search-box";
+import {
+ AnimatedSizeContainer,
+ EditColumnsButton,
+ Filter,
+ LinkLogo,
+ Table,
+ TimestampTooltip,
+ useColumnVisibility,
+ usePagination,
+ useRouterStuff,
+ useTable,
+} from "@dub/ui";
+import { User } from "@dub/ui/icons";
+import { COUNTRIES, formatDate, getApexDomain, getPrettyUrl } from "@dub/utils";
+import { useParams, useRouter } from "next/navigation";
+import { useMemo } from "react";
+import { usePartnerCustomerFilters } from "./use-partner-customer-filters";
+
+export default function PartnerProgramCustomersPage() {
+ const router = useRouter();
+ const { searchParams, queryParams } = useRouterStuff();
+
+ const { programSlug } = useParams<{ programSlug: string }>();
+ const { programEnrollment } = useProgramEnrollment();
+
+ const { data: customersCount, error: countError } =
+ usePartnerCustomersCount();
+ const { data: customers, isLoading, error } = usePartnerCustomers();
+
+ const { pagination, setPagination } = usePagination(
+ PARTNER_CUSTOMERS_MAX_PAGE_SIZE,
+ );
+
+ const sortBy = searchParams.get("sortBy") || "createdAt";
+ const sortOrder = searchParams.get("sortOrder") === "asc" ? "asc" : "desc";
+
+ const {
+ filters,
+ activeFilters,
+ onSelect,
+ onRemove,
+ onRemoveAll,
+ isFiltered,
+ setSelectedFilter,
+ } = usePartnerCustomerFilters();
+
+ const customersColumns = {
+ all: [
+ "customer",
+ "country",
+ "link",
+ "createdAt",
+ "firstSaleAt",
+ "subscriptionCanceledAt",
+ ],
+ defaultVisible: [
+ "customer",
+ "country",
+ "link",
+ "createdAt",
+ "firstSaleAt",
+ "subscriptionCanceledAt",
+ ],
+ };
+
+ const { columnVisibility, setColumnVisibility } = useColumnVisibility(
+ "partner-customers-table-columns",
+ customersColumns,
+ );
+
+ const columns = useMemo(
+ () =>
+ [
+ {
+ id: "customer",
+ header: "Customer",
+ enableHiding: false,
+ minSize: 250,
+ cell: ({ row }) => {
+ return <CustomerRowItem customer={row.original} />;
+ },
+ },
+ {
+ id: "country",
+ header: "Country",
+ accessorKey: "country",
+ minSize: 150,
+ cell: ({ row }) => {
+ const country = row.original.country;
+ return (
+ <div className="flex items-center gap-2">
+ {country && <CountryFlag countryCode={country} />}
+ <span className="min-w-0 truncate">
+ {(country ? COUNTRIES[country] : null) ?? "-"}
+ </span>
+ </div>
+ );
+ },
+ },
+ {
+ id: "link",
+ header: "Link",
+ accessorKey: "activity.link",
+ cell: ({ row }) =>
+ row.original.activity.link ? (
+ <a
+ href={`/programs/${programSlug}/analytics?linkId=${row.original.activity.link.id}`}
+ target="_blank"
+ className="flex cursor-alias items-center gap-3 decoration-dotted underline-offset-2 hover:underline"
+ >
+ <LinkLogo
+ apexDomain={getApexDomain(
+ row.original.activity.link.shortLink,
+ )}
+ className="size-4 shrink-0 sm:size-4"
+ />
+ <span
+ className="truncate"
+ title={row.original.activity.link.shortLink}
+ >
+ {getPrettyUrl(row.original.activity.link.shortLink)}
+ </span>
+ </a>
+ ) : (
+ "-"
+ ),
+ size: 250,
+ },
+ {
+ id: "createdAt",
+ header: "Created",
+ meta: {
+ headerTooltip:
+ "The date the customer was created (usually the signup date or trial start date).",
+ },
+ cell: ({ row }) => (
+ <TimestampTooltip
+ timestamp={row.original.createdAt}
+ rows={["local"]}
+ side="left"
+ delayDuration={150}
+ >
+ <span>
+ {formatDate(row.original.createdAt, { month: "short" })}
+ </span>
+ </TimestampTooltip>
+ ),
+ },
+ {
+ id: "firstSaleAt",
+ header: "Paid",
+ meta: {
+ headerTooltip: "The date the customer made their first sale.",
+ },
+ cell: ({ row }) =>
+ row.original.firstSaleAt ? (
+ <TimestampTooltip
+ timestamp={row.original.firstSaleAt}
+ rows={["local"]}
+ side="left"
+ delayDuration={150}
+ >
+ <span>
+ {formatDate(row.original.firstSaleAt, { month: "short" })}
+ </span>
+ </TimestampTooltip>
+ ) : (
+ "-"
+ ),
+ },
+ {
+ id: "subscriptionCanceledAt",
+ header: "Canceled",
+ meta: {
+ headerTooltip: "The date the customer canceled their subscription.",
+ },
+ cell: ({ row }) =>
+ row.original.subscriptionCanceledAt ? (
+ <TimestampTooltip
+ timestamp={row.original.subscriptionCanceledAt}
+ rows={["local"]}
+ side="left"
+ delayDuration={150}
+ >
+ <span>
+ {formatDate(row.original.subscriptionCanceledAt, {
+ month: "short",
+ })}
+ </span>
+ </TimestampTooltip>
+ ) : (
+ "-"
+ ),
+ },
+ // Menu
+ {
+ id: "menu",
+ enableHiding: false,
+ header: () => <EditColumnsButton table={table} />,
+ },
+ ].filter((c) => c.id === "menu" || customersColumns.all.includes(c.id)),
+ [programSlug],
+ );
+
+ const { table, ...tableProps } = useTable({
+ data: customers || [],
+ columns,
+ columnPinning: { right: ["menu"] },
+ onRowClick: (row, e) => {
+ const url = `/programs/${programSlug}/customers/${row.original.id}`;
+
+ if (e.metaKey || e.ctrlKey) window.open(url, "_blank");
+ else router.push(url);
+ },
+ onRowAuxClick: (row) =>
+ window.open(
+ `/programs/${programSlug}/customers/${row.original.id}`,
+ "_blank",
+ ),
+ rowProps: (row) => ({
+ onPointerEnter: () => {
+ router.prefetch(
+ `/programs/${programSlug}/customers/${row.original.id}`,
+ );
+ },
+ }),
+ pagination,
+ onPaginationChange: setPagination,
+ columnVisibility,
+ onColumnVisibilityChange: setColumnVisibility,
+ sortableColumns: ["createdAt", "firstSaleAt", "subscriptionCanceledAt"],
+ sortBy,
+ sortOrder,
+ onSortChange: ({ sortBy, sortOrder }) =>
+ queryParams({
+ set: {
+ ...(sortBy && { sortBy }),
+ ...(sortOrder && { sortOrder }),
+ },
+ del: "page",
+ scroll: false,
+ }),
+ thClassName: "border-l-0",
+ tdClassName: "border-l-0",
+ resourceName: (p) => `customer${p ? "s" : ""}`,
+ rowCount: customersCount || 0,
+ loading: isLoading,
+ error:
+ error instanceof Error
+ ? error.message
+ : countError
+ ? "Failed to load customers"
+ : undefined,
+ });
+
+ return (
+ <div className="flex flex-col gap-4">
+ <div>
+ <div className="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
+ <Filter.Select
+ className="w-full md:w-fit"
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ onSelectedFilterChange={setSelectedFilter}
+ />
+ {Boolean(programEnrollment?.customerDataSharingEnabledAt) && (
+ <SearchBoxPersisted
+ placeholder="Search by email or name"
+ inputClassName="md:w-[16rem]"
+ />
+ )}
+ </div>
+ <AnimatedSizeContainer height>
+ <div>
+ {activeFilters.length > 0 && (
+ <div className="pt-3">
+ <Filter.List
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ onRemoveAll={onRemoveAll}
+ />
+ </div>
+ )}
+ </div>
+ </AnimatedSizeContainer>
+ </div>
+
+ {customers?.length !== 0 ? (
+ <Table {...tableProps} table={table} />
+ ) : (
+ <AnimatedEmptyState
+ title={isFiltered ? "No customers found" : "No customers yet"}
+ description={
+ isFiltered
+ ? "No customers found for the selected filters. Adjust your filters to refine your search results."
+ : "No customers have been recorded for this program yet. Once customers start converting through your links, they'll appear here."
+ }
+ cardContent={() => (
+ <>
+ <User className="size-4 text-neutral-700" />
+ <div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />
+ </>
+ )}
+ />
+ )}
+ </div>
+ );
}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx
index b3a2bd6518..10f09a6c1e 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx
@@ -1,5 +1,15 @@
+import { redirect } from "next/navigation";
import { ProgramCustomerPageClient } from "./page-client";
-export default function ProgramCustomer() {
+export default async function PartnerProgramCustomerPage({
+ params,
+}: {
+ params: Promise<{ programSlug: string; customerId: string }>;
+}) {
+ const { programSlug, customerId } = await params;
+
+ if (customerId === "referrals") {
+ redirect(`/programs/${programSlug}/customers/leads`);
+ }
return <ProgramCustomerPageClient />;
}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/page.tsx
index bbbd7b6f1e..5dec68dcda 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/page.tsx
@@ -3,7 +3,7 @@ import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
import { EarningsCompositeChart } from "./earnings-composite-chart";
import { EarningsTablePartner } from "./earnings-table";
-export default function ProgramEarning() {
+export default function PartnerProgramEarningsPage() {
return (
<PageContent title="Earnings">
<PageWidthWrapper className="flex flex-col gap-5 pb-10">
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/events/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/events/page.tsx
index 3b95e88ca0..c530e77fb6 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/events/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/events/page.tsx
@@ -2,7 +2,7 @@ import Events from "@/ui/analytics/events";
import { EventsProvider } from "@/ui/analytics/events/events-provider";
import { PageContent } from "@/ui/layout/page-content";
-export default function ProgramEvents() {
+export default function PartnerProgramEventsPage() {
return (
<PageContent title="Events">
<EventsProvider>
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsx
index ea4aea10f6..5132e3823c 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page-client.tsx
@@ -41,7 +41,7 @@ export function usePartnerLinksContext() {
return context;
}
-export function ProgramLinksPageClient() {
+export function PartnerProgramLinksPageClient() {
const { searchParamsObj } = useRouterStuff();
const { links, error, loading, isValidating } = usePartnerLinks();
const { programEnrollment, showDetailedAnalytics } = useProgramEnrollment();
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page.tsx
index c4854f2f33..83b07350f0 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/page.tsx
@@ -1,13 +1,12 @@
import { PageContent } from "@/ui/layout/page-content";
-
import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
-import { ProgramLinksPageClient } from "./page-client";
+import { PartnerProgramLinksPageClient } from "./page-client";
-export default function ProgramLinks() {
+export default function PartnerProgramLinksPage() {
return (
<PageContent title="Links">
<PageWidthWrapper className="pb-10">
- <ProgramLinksPageClient />
+ <PartnerProgramLinksPageClient />
</PageWidthWrapper>
</PageContent>
);
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/page-client.tsx
index 6b3ee2f203..dae71f85e7 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/page-client.tsx
@@ -67,7 +67,7 @@ const ProgramOverviewContext = createContext<{
interval: DUB_PARTNERS_ANALYTICS_INTERVAL,
});
-export default function ProgramPageClient() {
+export function PartnerProgramOverviewPageClient() {
const { getQueryString, searchParamsObj } = useRouterStuff();
const { programSlug } = useParams();
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/page.tsx
index f11e93606f..977e014c37 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/page.tsx
@@ -1,8 +1,8 @@
import { PageContent } from "@/ui/layout/page-content";
import { HideProgramDetailsButton } from "./hide-program-details-button";
-import ProgramPageClient from "./page-client";
+import { PartnerProgramOverviewPageClient } from "./page-client";
-export default function ProgramPage() {
+export default function PartnerProgramOverviewPage() {
return (
<PageContent
title="Overview"
@@ -13,7 +13,7 @@ export default function ProgramPage() {
}}
controls={<HideProgramDetailsButton />}
>
- <ProgramPageClient />
+ <PartnerProgramOverviewPageClient />
</PageContent>
);
}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/resources/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/resources/page-client.tsx
deleted file mode 100644
index 0789ee2440..0000000000
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/resources/page-client.tsx
+++ /dev/null
@@ -1,154 +0,0 @@
-"use client";
-
-import useProgramResources from "@/lib/swr/use-program-resources";
-import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
-import { ResourceCard } from "@/ui/partners/resources/resource-card";
-import { ResourceSection } from "@/ui/partners/resources/resource-section";
-import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
-import { FileContent, FileZip2, Link4, Palette2, Post } from "@dub/ui/icons";
-import {
- formatFileSize,
- getApexDomain,
- getFileExtension,
- getPrettyUrl,
- GOOGLE_FAVICON_URL,
-} from "@dub/utils";
-
-const emptyStateIcons = [Post, Palette2, FileZip2, Link4];
-
-export function ResourcesPageClient() {
- const { resources, isLoading, isValidating } = useProgramResources();
-
- const isEmpty =
- !isLoading &&
- ["logos", "colors", "files", "links"].every(
- (resource) => !resources?.[resource]?.length,
- );
-
- return (
- <PageWidthWrapper className="pb-10">
- {isLoading || !isEmpty ? (
- <div className="flex flex-col gap-10">
- {(isLoading || !!resources?.logos?.length) && (
- <ResourceSection
- resource="logo"
- title="Brand logos"
- isLoading={isLoading}
- isValidating={isValidating}
- >
- {resources?.logos?.map((logo) => (
- <ResourceCard
- key={logo.id}
- resourceType="logo"
- icon={
- <div className="relative size-8 overflow-hidden">
- <img
- src={logo.url}
- alt="thumbnail"
- className="size-full object-contain"
- />
- </div>
- }
- title={logo.name || "Logo"}
- description={`${getFileExtension(logo.url) || "Unknown"}・${formatFileSize(logo.size, 0)}`}
- downloadUrl={logo.url}
- />
- ))}
- </ResourceSection>
- )}
-
- {(isLoading || !!resources?.links?.length) && (
- <ResourceSection
- resource="link"
- title="Links"
- isLoading={isLoading}
- isValidating={isValidating}
- >
- {resources?.links?.map((link) => (
- <ResourceCard
- key={link.id}
- resourceType="link"
- icon={
- <div className="flex size-full items-center justify-center bg-neutral-50">
- <img
- src={`${GOOGLE_FAVICON_URL}${getApexDomain(link.url)}`}
- alt={link.name}
- className="size-6 rounded-full object-contain"
- />
- </div>
- }
- title={link.name}
- description={getPrettyUrl(link.url)}
- visitUrl={link.url}
- />
- ))}
- </ResourceSection>
- )}
-
- {(isLoading || !!resources?.colors?.length) && (
- <ResourceSection
- resource="color"
- title="Colors"
- isLoading={isLoading}
- isValidating={isValidating}
- >
- {resources?.colors?.map((color) => (
- <ResourceCard
- key={color.id}
- resourceType="color"
- icon={
- <div
- className="size-full"
- style={{ backgroundColor: color.color }}
- />
- }
- title={color.name || "Color"}
- description={color.color.toUpperCase()}
- copyText={color.color.toUpperCase()}
- />
- ))}
- </ResourceSection>
- )}
-
- {(isLoading || !!resources?.files?.length) && (
- <ResourceSection
- resource="file"
- title="Additional files"
- isLoading={isLoading}
- isValidating={isValidating}
- >
- {resources?.files?.map((file) => (
- <ResourceCard
- key={file.id}
- resourceType="file"
- icon={
- <div className="flex size-full items-center justify-center bg-neutral-50">
- <FileContent className="size-4 text-neutral-800" />
- </div>
- }
- title={file.name || "File"}
- description={`${getFileExtension(file.url) || "Unknown"}・${formatFileSize(file.size, 0)}`}
- downloadUrl={file.url}
- />
- ))}
- </ResourceSection>
- )}
- </div>
- ) : (
- <AnimatedEmptyState
- title="Resources"
- description="When this program adds resources, they'll appear here"
- cardContent={(idx) => {
- const Icon = emptyStateIcons[idx % emptyStateIcons.length];
- return (
- <>
- <Icon className="size-4 text-neutral-700" />
- <div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />
- </>
- );
- }}
- />
- )}
- </PageWidthWrapper>
- );
-}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/resources/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/resources/page.tsx
index 6c13c18c9c..6fbd47981c 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/resources/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/resources/page.tsx
@@ -1,10 +1,157 @@
+"use client";
+
+import useProgramResources from "@/lib/swr/use-program-resources";
import { PageContent } from "@/ui/layout/page-content";
-import { ResourcesPageClient } from "./page-client";
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
+import { ResourceCard } from "@/ui/partners/resources/resource-card";
+import { ResourceSection } from "@/ui/partners/resources/resource-section";
+import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
+import { FileContent, FileZip2, Link4, Palette2, Post } from "@dub/ui/icons";
+import {
+ formatFileSize,
+ getApexDomain,
+ getFileExtension,
+ getPrettyUrl,
+ GOOGLE_FAVICON_URL,
+} from "@dub/utils";
+
+const emptyStateIcons = [Post, Palette2, FileZip2, Link4];
+
+export default function PartnerProgramResourcesPage() {
+ const { resources, isLoading, isValidating } = useProgramResources();
+
+ const isEmpty =
+ !isLoading &&
+ ["logos", "colors", "files", "links"].every(
+ (resource) => !resources?.[resource]?.length,
+ );
-export default function ResourcesPage() {
return (
<PageContent title="Resources">
- <ResourcesPageClient />
+ <PageWidthWrapper className="pb-10">
+ {isLoading || !isEmpty ? (
+ <div className="flex flex-col gap-10">
+ {(isLoading || !!resources?.logos?.length) && (
+ <ResourceSection
+ resource="logo"
+ title="Brand logos"
+ isLoading={isLoading}
+ isValidating={isValidating}
+ >
+ {resources?.logos?.map((logo) => (
+ <ResourceCard
+ key={logo.id}
+ resourceType="logo"
+ icon={
+ <div className="relative size-8 overflow-hidden">
+ <img
+ src={logo.url}
+ alt="thumbnail"
+ className="size-full object-contain"
+ />
+ </div>
+ }
+ title={logo.name || "Logo"}
+ description={`${getFileExtension(logo.url) || "Unknown"}・${formatFileSize(logo.size, 0)}`}
+ downloadUrl={logo.url}
+ />
+ ))}
+ </ResourceSection>
+ )}
+
+ {(isLoading || !!resources?.links?.length) && (
+ <ResourceSection
+ resource="link"
+ title="Links"
+ isLoading={isLoading}
+ isValidating={isValidating}
+ >
+ {resources?.links?.map((link) => (
+ <ResourceCard
+ key={link.id}
+ resourceType="link"
+ icon={
+ <div className="flex size-full items-center justify-center bg-neutral-50">
+ <img
+ src={`${GOOGLE_FAVICON_URL}${getApexDomain(link.url)}`}
+ alt={link.name}
+ className="size-6 rounded-full object-contain"
+ />
+ </div>
+ }
+ title={link.name}
+ description={getPrettyUrl(link.url)}
+ visitUrl={link.url}
+ />
+ ))}
+ </ResourceSection>
+ )}
+
+ {(isLoading || !!resources?.colors?.length) && (
+ <ResourceSection
+ resource="color"
+ title="Colors"
+ isLoading={isLoading}
+ isValidating={isValidating}
+ >
+ {resources?.colors?.map((color) => (
+ <ResourceCard
+ key={color.id}
+ resourceType="color"
+ icon={
+ <div
+ className="size-full"
+ style={{ backgroundColor: color.color }}
+ />
+ }
+ title={color.name || "Color"}
+ description={color.color.toUpperCase()}
+ copyText={color.color.toUpperCase()}
+ />
+ ))}
+ </ResourceSection>
+ )}
+
+ {(isLoading || !!resources?.files?.length) && (
+ <ResourceSection
+ resource="file"
+ title="Additional files"
+ isLoading={isLoading}
+ isValidating={isValidating}
+ >
+ {resources?.files?.map((file) => (
+ <ResourceCard
+ key={file.id}
+ resourceType="file"
+ icon={
+ <div className="flex size-full items-center justify-center bg-neutral-50">
+ <FileContent className="size-4 text-neutral-800" />
+ </div>
+ }
+ title={file.name || "File"}
+ description={`${getFileExtension(file.url) || "Unknown"}・${formatFileSize(file.size, 0)}`}
+ downloadUrl={file.url}
+ />
+ ))}
+ </ResourceSection>
+ )}
+ </div>
+ ) : (
+ <AnimatedEmptyState
+ title="Resources"
+ description="When this program adds resources, they'll appear here"
+ cardContent={(idx) => {
+ const Icon = emptyStateIcons[idx % emptyStateIcons.length];
+ return (
+ <>
+ <Icon className="size-4 text-neutral-700" />
+ <div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />
+ </>
+ );
+ }}
+ />
+ )}
+ </PageWidthWrapper>
</PageContent>
);
}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/[customerId]/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/[customerId]/page.tsx
index afd6de4d98..6a11985812 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/[customerId]/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/[customerId]/page.tsx
@@ -7,6 +7,10 @@ export default async function ProgramCustomerPage({
params: Promise<{ slug: string; customerId: string }>;
}) {
const { slug, customerId } = await params;
+ if (customerId === "referrals") {
+ redirect(`/${slug}/program/customers/leads`);
+ }
+
redirect(`/${slug}/program/customers/${customerId}/sales`);
return null;
diff --git a/apps/web/scripts/migrations/backfill-submitted-leads.ts b/apps/web/scripts/migrations/backfill-submitted-leads.ts
deleted file mode 100644
index 4d64f95d5e..0000000000
--- a/apps/web/scripts/migrations/backfill-submitted-leads.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-import { prisma } from "@dub/prisma";
-import { Prisma, SubmittedLeadStatus } from "@dub/prisma/client";
-import "dotenv-flow/config";
-
-const BATCH_SIZE = 100;
-
-async function main() {
- let cursor: string | undefined;
- let totalProcessed = 0;
- let totalInserted = 0;
-
- while (true) {
- const referrals = await prisma.partnerReferral.findMany({
- take: BATCH_SIZE,
- ...(cursor
- ? {
- skip: 1,
- cursor: {
- id: cursor,
- },
- }
- : {}),
- orderBy: {
- id: "asc",
- },
- });
-
- if (referrals.length === 0) {
- break;
- }
-
- const data: Prisma.SubmittedLeadCreateManyInput[] = referrals.map((r) => ({
- // Preserve IDs (but change prefix) so historical references (e.g. ActivityLog.resourceId) remain valid.
- id: r.id.replace("ref_", "sbl_"),
- programId: r.programId,
- partnerId: r.partnerId,
- customerId: r.customerId,
- name: r.name,
- email: r.email,
- company: r.company,
- formData: (r.formData ?? Prisma.JsonNull) as Prisma.InputJsonValue,
- status: r.status as unknown as SubmittedLeadStatus,
- createdAt: r.createdAt,
- updatedAt: r.updatedAt,
- }));
-
- const { count } = await prisma.submittedLead.createMany({
- data,
- skipDuplicates: true,
- });
-
- totalProcessed += referrals.length;
- totalInserted += count;
-
- console.log(
- `Backfilled ${count} submitted leads (batch=${referrals.length}, processed=${totalProcessed}, inserted=${totalInserted})`,
- );
-
- cursor = referrals[referrals.length - 1].id;
- }
-
- console.log(
- `Done backfilling submitted leads (processed=${totalProcessed}, inserted=${totalInserted})`,
- );
-}
-
-main();
diff --git a/apps/web/scripts/migrations/migrate-referrals-activity-log.ts b/apps/web/scripts/migrations/migrate-referrals-activity-log.ts
deleted file mode 100644
index e49d4e4d33..0000000000
--- a/apps/web/scripts/migrations/migrate-referrals-activity-log.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { prisma } from "@dub/prisma";
-import "dotenv-flow/config";
-
-const BATCH_SIZE = 20;
-
-async function main() {
- while (true) {
- const logs = await prisma.activityLog.findMany({
- where: {
- resourceType: "referral",
- },
- take: BATCH_SIZE,
- });
-
- if (logs.length === 0) {
- break;
- }
-
- for (const log of logs) {
- await prisma.activityLog.update({
- where: { id: log.id },
- data: {
- resourceType: "submittedLead",
- resourceId: log.resourceId.replace("ref_", "sbl_"),
- action: log.action.replace("referral.", "submittedLead."),
- },
- });
- console.log(`Migrated ${log.id}`);
- }
- }
-}
-
-main();
diff --git a/packages/prisma/schema/referral.prisma b/packages/prisma/schema/referral.prisma
deleted file mode 100644
index afe1b02269..0000000000
--- a/packages/prisma/schema/referral.prisma
+++ /dev/null
@@ -1,28 +0,0 @@
-enum ReferralStatus {
- pending
- qualified
- meeting
- negotiation
- unqualified
- closedWon
- closedLost
-}
-
-model PartnerReferral {
- id String @id @default(cuid())
- programId String
- partnerId String
- customerId String?
- name String
- email String
- company String
- formData Json? @db.Json
- status ReferralStatus @default(pending)
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
-
- @@index([programId, partnerId])
- @@index(partnerId)
- @@index(customerId)
- @@fulltext([email, name])
-}
\ No newline at end of file