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.

restructure admin, add Partners tab

Steven Teyaf34c27539b1
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx
deleted file mode 100644
index 55dbedba17..0000000000
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx
+++ /dev/null
@@ -1,397 +0,0 @@
-"use client";
-
-import { formatDateTooltip } from "@/lib/analytics/format-date-tooltip";
-import { AnalyticsLoadingSpinner } from "@/ui/analytics/analytics-loading-spinner";
-import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
-import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
-import {
- CrownSmall,
- Filter,
- Table,
- usePagination,
- useRouterStuff,
- useTable,
-} from "@dub/ui";
-import { Areas, TimeSeriesChart, XAxis, YAxis } from "@dub/ui/charts";
-import { GridIcon } from "@dub/ui/icons";
-import {
- cn,
- currencyFormatter,
- DUB_FOUNDING_DATE,
- fetcher,
- OG_AVATAR_URL,
-} from "@dub/utils";
-import NumberFlow from "@number-flow/react";
-import { Fragment, useCallback, useMemo, useState } from "react";
-import useSWR from "swr";
-
-export default function CommissionsPageClient() {
- const { queryParams, getQueryString, searchParamsObj } = useRouterStuff();
- const { interval, start, end, programId } = searchParamsObj;
-
- const { data: { programs, timeseries } = {}, isLoading } = useSWR<{
- programs: {
- id: string;
- name: string;
- logo: string;
- commissions: number;
- fees: number;
- }[];
- timeseries: {
- start: Date;
- commissions: number;
- }[];
- }>(
- `/api/admin/commissions${getQueryString({
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
- })}`,
- fetcher,
- {
- keepPreviousData: true,
- },
- );
-
- // Filter configuration
- const filters = useMemo(
- () => [
- {
- key: "programId",
- icon: GridIcon,
- label: "Program",
- options:
- programs?.map((program) => ({
- value: program.id,
- label: program.name,
- icon: (
- <img
- src={program.logo || `${OG_AVATAR_URL}${program.name}`}
- alt={`${program.name} image`}
- className="size-4 rounded-full"
- />
- ),
- })) ?? null,
- },
- ],
- [programs],
- );
-
- const activeFilters = useMemo(() => {
- return [...(programId ? [{ key: "programId", value: programId }] : [])];
- }, [programId]);
-
- const onSelect = useCallback(
- (key: string, value: any) =>
- queryParams({
- set: {
- [key]: value,
- },
- del: "page",
- }),
- [queryParams],
- );
-
- const onRemove = useCallback(
- (key: string) =>
- queryParams({
- del: [key, "page"],
- }),
- [queryParams],
- );
-
- const onRemoveAll = useCallback(
- () =>
- queryParams({
- del: ["programId"],
- }),
- [queryParams],
- );
-
- const [selectedFilter, setSelectedFilter] = useState<string | null>(null);
- const [search, setSearch] = useState("");
-
- const tabs: {
- id: string;
- label: string;
- colorClassName: string;
- disabled?: boolean;
- }[] = [
- {
- id: "commissions",
- label: "Commissions",
- colorClassName: "text-teal-500 bg-teal-500/50 border-teal-500",
- },
- {
- id: "fees",
- label: "Fees",
- colorClassName: "text-red-500 bg-red-500/50 border-red-500",
- disabled: true,
- },
- ];
-
- const tab = tabs[0];
- const selectedTab = tab.id;
-
- const chartData =
- timeseries?.map(({ start, commissions }) => ({
- date: start ? new Date(start) : new Date(),
- values: {
- commissions: commissions || 0,
- },
- })) ?? null;
-
- const totals = useMemo(() => {
- return {
- commissions:
- timeseries?.reduce(
- (acc, { commissions }) => acc + (commissions || 0),
- 0,
- ) ?? 0,
- fees: programs?.reduce((acc, { fees }) => acc + (fees || 0), 0) ?? 0,
- };
- }, [timeseries, programs]);
-
- const { pagination, setPagination } = usePagination();
-
- const { table, ...tableProps } = useTable({
- data: programs ?? [],
- columns: [
- {
- id: "position",
- header: "Position",
- size: 12,
- minSize: 12,
- maxSize: 12,
- cell: ({ row }) => {
- return (
- <div className="flex w-28 items-center justify-start gap-2 tabular-nums">
- {row.index + 1}
- {row.index <= 2 && (
- <CrownSmall
- className={cn("size-4", {
- "text-amber-400": row.index === 0,
- "text-neutral-400": row.index === 1,
- "text-yellow-900": row.index === 2,
- })}
- />
- )}
- </div>
- );
- },
- },
- {
- id: "program",
- header: "Program",
- cell: ({ row }) => (
- <div className="flex items-center gap-1.5">
- <img
- src={row.original.logo}
- alt={row.original.name}
- width={20}
- height={20}
- className="size-4 rounded-full"
- />
- <span className="text-sm font-medium">{row.original.name}</span>
- </div>
- ),
- meta: {
- filterParams: ({ row }) => ({
- programId: row.original.id,
- }),
- },
- },
- {
- id: "commissions",
- header: "Commissions",
- accessorKey: "commissions",
- cell: ({ row }) => currencyFormatter(row.original.commissions),
- },
- {
- id: "fees",
- header: "Fees",
- accessorKey: "fees",
- cell: ({ row }) => currencyFormatter(row.original.fees),
- },
- ],
- pagination,
- onPaginationChange: setPagination,
- resourceName: (plural) => `program${plural ? "s" : ""}`,
- rowCount: programs?.length ?? 0,
- loading: isLoading,
- cellRight: (cell) => {
- const meta = cell.column.columnDef.meta as
- | {
- filterParams?: any;
- }
- | undefined;
-
- return (
- meta?.filterParams && (
- <FilterButtonTableRow set={meta.filterParams(cell)} />
- )
- );
- },
- });
-
- return (
- <div className="mx-auto flex w-full max-w-screen-xl flex-col gap-3 p-6">
- <div className="flex flex-col gap-3 md:flex-row md:items-center">
- <Filter.Select
- className="w-full md:w-fit"
- filters={filters}
- activeFilters={activeFilters}
- onSelect={onSelect}
- onRemove={onRemove}
- onSearchChange={setSearch}
- onSelectedFilterChange={setSelectedFilter}
- />
- <SimpleDateRangePicker
- defaultInterval="mtd"
- className="w-full sm:min-w-[200px] md:w-fit"
- />
- </div>
- {activeFilters.length > 0 && (
- <div>
- <Filter.List
- filters={filters}
- activeFilters={activeFilters}
- onSelect={onSelect}
- onRemove={onRemove}
- onRemoveAll={onRemoveAll}
- />
- </div>
- )}
- <div className="flex flex-col divide-y divide-neutral-200 rounded-lg border border-neutral-200 bg-white">
- <div className="scrollbar-hide grid w-full grid-cols-2 divide-x overflow-y-hidden sm:grid-cols-3">
- {tabs.map(({ id, label, colorClassName, disabled }) => {
- return (
- <button
- key={id}
- disabled={disabled}
- onClick={() => {
- queryParams({
- set: { tab: id },
- });
- }}
- className={cn(
- "border-box relative block h-full w-full flex-none px-4 py-3 sm:px-8 sm:py-6",
- "ring-inset ring-neutral-500 focus-visible:ring-1 sm:first:rounded-tl-xl",
- disabled
- ? "cursor-not-allowed"
- : "transition-colors hover:bg-neutral-50 focus:outline-none active:bg-neutral-100",
- )}
- >
- {/* Active tab indicator */}
- <div
- className={cn(
- "absolute bottom-0 left-0 h-0.5 w-full bg-black transition-transform duration-100",
- selectedTab !== id && "translate-y-[3px]",
- )}
- />
- <div className="flex items-center gap-2.5 text-sm text-neutral-600">
- <div
- className={cn(
- "h-2 w-2 rounded-sm bg-current shadow-[inset_0_0_0_1px_#00000019]",
- colorClassName,
- )}
- />
- <span>{label}</span>
- </div>
- <div className="mt-1 flex h-12 items-center">
- {(totals[id] || totals[id] === 0) && !isLoading ? (
- <NumberFlow
- value={(totals[id] ?? 0) / 100}
- className="text-xl font-medium sm:text-3xl"
- format={{
- style: "currency",
- currency: "USD",
- // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
- trailingZeroDisplay: "stripIfInteger",
- }}
- />
- ) : (
- <div className="h-10 w-24 animate-pulse rounded-md bg-neutral-200" />
- )}
- </div>
- </button>
- );
- })}
- </div>
- <div className="p-5 sm:p-10">
- <div className="flex h-96 w-full items-center justify-center">
- {chartData ? (
- chartData.length > 0 ? (
- <TimeSeriesChart
- data={chartData}
- series={[
- {
- id: "commissions",
- valueAccessor: (d) => d.values.commissions,
- isActive: selectedTab === "commissions",
- colorClassName: tab.colorClassName,
- },
- ]}
- tooltipClassName="p-0"
- tooltipContent={(d) => (
- <>
- <p className="border-b border-neutral-200 px-4 py-3 text-sm text-neutral-900">
- {formatDateTooltip(d.date, {
- interval,
- start,
- end,
- })}
- </p>
- <div className="grid grid-cols-2 gap-x-6 gap-y-2 px-4 py-3 text-sm">
- <Fragment>
- <div className="flex items-center gap-2">
- <div
- className={cn(
- "h-2 w-2 rounded-sm shadow-[inset_0_0_0_1px_#0003]",
- tab.colorClassName,
- )}
- />
- <p className="capitalize text-neutral-600">
- {tab.label}
- </p>
- </div>
- <p className="text-right font-medium text-neutral-900">
- {currencyFormatter(d.values[tab.id])}
- </p>
- </Fragment>
- </div>
- </>
- )}
- >
- <Areas />
- <XAxis
- maxTicks={5}
- tickFormat={(d) =>
- formatDateTooltip(d, {
- interval,
- start,
- end,
- dataAvailableFrom: DUB_FOUNDING_DATE,
- })
- }
- />
- <YAxis
- showGridLines
- tickFormat={(value) => currencyFormatter(value)}
- />
- </TimeSeriesChart>
- ) : (
- <div className="text-center text-sm text-neutral-600">
- No data available.
- </div>
- )
- ) : (
- <AnalyticsLoadingSpinner />
- )}
- </div>
- </div>
- </div>
- <div className="w-full">
- <Table {...tableProps} table={table} />
- </div>
- </div>
- );
-}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/page.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/page.tsx
index 70e3d5efad..2589ce6b03 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/page.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/page.tsx
@@ -1,10 +1,392 @@
-import { Suspense } from "react";
-import CommissionsPageClient from "./client";
+"use client";
+
+import { formatDateTooltip } from "@/lib/analytics/format-date-tooltip";
+import { AnalyticsLoadingSpinner } from "@/ui/analytics/analytics-loading-spinner";
+import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
+import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
+import {
+ CrownSmall,
+ Filter,
+ Table,
+ usePagination,
+ useRouterStuff,
+ useTable,
+} from "@dub/ui";
+import { Areas, TimeSeriesChart, XAxis, YAxis } from "@dub/ui/charts";
+import { GridIcon } from "@dub/ui/icons";
+import {
+ cn,
+ currencyFormatter,
+ DUB_FOUNDING_DATE,
+ fetcher,
+ OG_AVATAR_URL,
+} from "@dub/utils";
+import NumberFlow from "@number-flow/react";
+import { Fragment, useCallback, useMemo } from "react";
+import useSWR from "swr";
+
+export default function CommissionsPage() {
+ const { queryParams, getQueryString, searchParamsObj } = useRouterStuff();
+ const { interval, start, end, programId } = searchParamsObj;
+
+ const { data: { programs, timeseries } = {}, isLoading } = useSWR<{
+ programs: {
+ id: string;
+ name: string;
+ logo: string;
+ commissions: number;
+ fees: number;
+ }[];
+ timeseries: {
+ start: Date;
+ commissions: number;
+ }[];
+ }>(
+ `/api/admin/commissions${getQueryString({
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
+ })}`,
+ fetcher,
+ {
+ keepPreviousData: true,
+ },
+ );
+
+ // Filter configuration
+ const filters = useMemo(
+ () => [
+ {
+ key: "programId",
+ icon: GridIcon,
+ label: "Program",
+ options:
+ programs?.map((program) => ({
+ value: program.id,
+ label: program.name,
+ icon: (
+ <img
+ src={program.logo || `${OG_AVATAR_URL}${program.name}`}
+ alt={`${program.name} image`}
+ className="size-4 rounded-full"
+ />
+ ),
+ })) ?? null,
+ },
+ ],
+ [programs],
+ );
+
+ const activeFilters = useMemo(() => {
+ return [...(programId ? [{ key: "programId", value: programId }] : [])];
+ }, [programId]);
+
+ const onSelect = useCallback(
+ (key: string, value: any) =>
+ queryParams({
+ set: {
+ [key]: value,
+ },
+ del: "page",
+ }),
+ [queryParams],
+ );
+
+ const onRemove = useCallback(
+ (key: string) =>
+ queryParams({
+ del: [key, "page"],
+ }),
+ [queryParams],
+ );
+
+ const onRemoveAll = useCallback(
+ () =>
+ queryParams({
+ del: ["programId"],
+ }),
+ [queryParams],
+ );
+
+ const tabs: {
+ id: string;
+ label: string;
+ colorClassName: string;
+ disabled?: boolean;
+ }[] = [
+ {
+ id: "commissions",
+ label: "Commissions",
+ colorClassName: "text-teal-500 bg-teal-500/50 border-teal-500",
+ },
+ {
+ id: "fees",
+ label: "Fees",
+ colorClassName: "text-red-500 bg-red-500/50 border-red-500",
+ disabled: true,
+ },
+ ];
+
+ const tab = tabs[0];
+ const selectedTab = tab.id;
+
+ const chartData =
+ timeseries?.map(({ start, commissions }) => ({
+ date: start ? new Date(start) : new Date(),
+ values: {
+ commissions: commissions || 0,
+ },
+ })) ?? null;
+
+ const totals = useMemo(() => {
+ return {
+ commissions:
+ timeseries?.reduce(
+ (acc, { commissions }) => acc + (commissions || 0),
+ 0,
+ ) ?? 0,
+ fees: programs?.reduce((acc, { fees }) => acc + (fees || 0), 0) ?? 0,
+ };
+ }, [timeseries, programs]);
+
+ const { pagination, setPagination } = usePagination();
+
+ const { table, ...tableProps } = useTable({
+ data: programs ?? [],
+ columns: [
+ {
+ id: "position",
+ header: "Position",
+ size: 12,
+ minSize: 12,
+ maxSize: 12,
+ cell: ({ row }) => {
+ return (
+ <div className="flex w-28 items-center justify-start gap-2 tabular-nums">
+ {row.index + 1}
+ {row.index <= 2 && (
+ <CrownSmall
+ className={cn("size-4", {
+ "text-amber-400": row.index === 0,
+ "text-neutral-400": row.index === 1,
+ "text-yellow-900": row.index === 2,
+ })}
+ />
+ )}
+ </div>
+ );
+ },
+ },
+ {
+ id: "program",
+ header: "Program",
+ cell: ({ row }) => (
+ <div className="flex items-center gap-1.5">
+ <img
+ src={row.original.logo}
+ alt={row.original.name}
+ width={20}
+ height={20}
+ className="size-4 rounded-full"
+ />
+ <span className="text-sm font-medium">{row.original.name}</span>
+ </div>
+ ),
+ meta: {
+ filterParams: ({ row }) => ({
+ programId: row.original.id,
+ }),
+ },
+ },
+ {
+ id: "commissions",
+ header: "Commissions",
+ accessorKey: "commissions",
+ cell: ({ row }) => currencyFormatter(row.original.commissions),
+ },
+ {
+ id: "fees",
+ header: "Fees",
+ accessorKey: "fees",
+ cell: ({ row }) => currencyFormatter(row.original.fees),
+ },
+ ],
+ pagination,
+ onPaginationChange: setPagination,
+ resourceName: (plural) => `program${plural ? "s" : ""}`,
+ rowCount: programs?.length ?? 0,
+ loading: isLoading,
+ cellRight: (cell) => {
+ const meta = cell.column.columnDef.meta as
+ | {
+ filterParams?: any;
+ }
+ | undefined;
+
+ return (
+ meta?.filterParams && (
+ <FilterButtonTableRow set={meta.filterParams(cell)} />
+ )
+ );
+ },
+ });
-export default async function CommissionsPage() {
return (
- <Suspense>
- <CommissionsPageClient />
- </Suspense>
+ <div className="mx-auto flex w-full max-w-screen-xl flex-col gap-3 p-6">
+ <div className="flex flex-col gap-3 md:flex-row md:items-center">
+ <Filter.Select
+ className="w-full md:w-fit"
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ />
+ <SimpleDateRangePicker
+ defaultInterval="mtd"
+ className="w-full sm:min-w-[200px] md:w-fit"
+ />
+ </div>
+ {activeFilters.length > 0 && (
+ <div>
+ <Filter.List
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ onRemoveAll={onRemoveAll}
+ />
+ </div>
+ )}
+ <div className="flex flex-col divide-y divide-neutral-200 rounded-lg border border-neutral-200 bg-white">
+ <div className="scrollbar-hide grid w-full grid-cols-2 divide-x overflow-y-hidden sm:grid-cols-3">
+ {tabs.map(({ id, label, colorClassName, disabled }) => {
+ return (
+ <button
+ key={id}
+ disabled={disabled}
+ onClick={() => {
+ queryParams({
+ set: { tab: id },
+ });
+ }}
+ className={cn(
+ "border-box relative block h-full w-full flex-none px-4 py-3 sm:px-8 sm:py-6",
+ "ring-inset ring-neutral-500 focus-visible:ring-1 sm:first:rounded-tl-xl",
+ disabled
+ ? "cursor-not-allowed"
+ : "transition-colors hover:bg-neutral-50 focus:outline-none active:bg-neutral-100",
+ )}
+ >
+ {/* Active tab indicator */}
+ <div
+ className={cn(
+ "absolute bottom-0 left-0 h-0.5 w-full bg-black transition-transform duration-100",
+ selectedTab !== id && "translate-y-[3px]",
+ )}
+ />
+ <div className="flex items-center gap-2.5 text-sm text-neutral-600">
+ <div
+ className={cn(
+ "h-2 w-2 rounded-sm bg-current shadow-[inset_0_0_0_1px_#00000019]",
+ colorClassName,
+ )}
+ />
+ <span>{label}</span>
+ </div>
+ <div className="mt-1 flex h-12 items-center">
+ {(totals[id] || totals[id] === 0) && !isLoading ? (
+ <NumberFlow
+ value={(totals[id] ?? 0) / 100}
+ className="text-xl font-medium sm:text-3xl"
+ format={{
+ style: "currency",
+ currency: "USD",
+ // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
+ trailingZeroDisplay: "stripIfInteger",
+ }}
+ />
+ ) : (
+ <div className="h-10 w-24 animate-pulse rounded-md bg-neutral-200" />
+ )}
+ </div>
+ </button>
+ );
+ })}
+ </div>
+ <div className="p-5 sm:p-10">
+ <div className="flex h-96 w-full items-center justify-center">
+ {chartData ? (
+ chartData.length > 0 ? (
+ <TimeSeriesChart
+ data={chartData}
+ series={[
+ {
+ id: "commissions",
+ valueAccessor: (d) => d.values.commissions,
+ isActive: selectedTab === "commissions",
+ colorClassName: tab.colorClassName,
+ },
+ ]}
+ tooltipClassName="p-0"
+ tooltipContent={(d) => (
+ <>
+ <p className="border-b border-neutral-200 px-4 py-3 text-sm text-neutral-900">
+ {formatDateTooltip(d.date, {
+ interval,
+ start,
+ end,
+ })}
+ </p>
+ <div className="grid grid-cols-2 gap-x-6 gap-y-2 px-4 py-3 text-sm">
+ <Fragment>
+ <div className="flex items-center gap-2">
+ <div
+ className={cn(
+ "h-2 w-2 rounded-sm shadow-[inset_0_0_0_1px_#0003]",
+ tab.colorClassName,
+ )}
+ />
+ <p className="capitalize text-neutral-600">
+ {tab.label}
+ </p>
+ </div>
+ <p className="text-right font-medium text-neutral-900">
+ {currencyFormatter(d.values[tab.id])}
+ </p>
+ </Fragment>
+ </div>
+ </>
+ )}
+ >
+ <Areas />
+ <XAxis
+ maxTicks={5}
+ tickFormat={(d) =>
+ formatDateTooltip(d, {
+ interval,
+ start,
+ end,
+ dataAvailableFrom: DUB_FOUNDING_DATE,
+ })
+ }
+ />
+ <YAxis
+ showGridLines
+ tickFormat={(value) => currencyFormatter(value)}
+ />
+ </TimeSeriesChart>
+ ) : (
+ <div className="text-center text-sm text-neutral-600">
+ No data available.
+ </div>
+ )
+ ) : (
+ <AnalyticsLoadingSpinner />
+ )}
+ </div>
+ </div>
+ </div>
+ <div className="w-full">
+ <Table {...tableProps} table={table} />
+ </div>
+ </div>
);
}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/layout-nav-client.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/layout-nav-client.tsx
index b1b6801581..476b11e7f6 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/layout-nav-client.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/layout-nav-client.tsx
@@ -28,6 +28,10 @@ const tabs = [
href: "/payouts",
label: "Payouts",
},
+ {
+ href: "/partners",
+ label: "Partners",
+ },
{
href: "/revenue",
label: "Revenue",
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/layout.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/layout.tsx
index a76a50dfdb..b88708f449 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/layout.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/layout.tsx
@@ -2,7 +2,10 @@ import { constructMetadata } from "@dub/utils";
import { ReactNode } from "react";
import { AdminNav } from "./layout-nav-client";
-export const metadata = constructMetadata({ noIndex: true });
+export const metadata = constructMetadata({
+ title: "Dub Admin",
+ noIndex: true,
+});
export default function AdminLayout({ children }: { children: ReactNode }) {
return (
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/page.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/page.tsx
index be2f038f8d..d47606c643 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/page.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/page.tsx
@@ -1,4 +1,3 @@
-import { constructMetadata } from "@dub/utils";
import { BanLink } from "./components/ban-link";
import { DeletePartnerAccount } from "./components/delete-partner-account";
import { ImpersonateUser } from "./components/impersonate-user";
@@ -6,11 +5,6 @@ import { ImpersonateWorkspace } from "./components/impersonate-workspace";
import { RefreshDomain } from "./components/refresh-domain";
import { ResetLoginAttempts } from "./components/reset-login-attempts";
-export const metadata = constructMetadata({
- title: "Dub Admin",
- noIndex: true,
-});
-
export default function AdminPage() {
return (
<div className="mx-auto flex w-full max-w-screen-sm flex-col divide-y divide-neutral-200 overflow-auto bg-white">
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/page.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/page.tsx
new file mode 100644
index 0000000000..9f997cdff0
--- /dev/null
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/page.tsx
@@ -0,0 +1,250 @@
+"use client";
+
+import { useConfirmModal } from "@/ui/modals/confirm-modal";
+import { PartnerAvatar } from "@/ui/partners/partner-avatar";
+import { Button, CopyText, TimestampTooltip } from "@dub/ui";
+import { Xmark } from "@dub/ui/icons";
+import { cn, fetcher, formatDateSmart } from "@dub/utils";
+import { FormEvent, useCallback, useMemo, useState } from "react";
+import { toast } from "sonner";
+import useSWR from "swr";
+
+type TrustedPartner = {
+ id: string;
+ name: string;
+ email: string | null;
+ image: string | null;
+ trustedAt: Date;
+};
+
+function TrustedAtLabel({
+ trustedAt,
+ className,
+}: {
+ trustedAt: Date | string;
+ className?: string;
+}) {
+ return (
+ <TimestampTooltip
+ timestamp={trustedAt}
+ rows={["local", "utc", "unix"]}
+ side="left"
+ >
+ <div
+ className={cn(
+ "cursor-default whitespace-nowrap text-xs tabular-nums text-neutral-400 underline decoration-neutral-300 decoration-dotted underline-offset-2",
+ className,
+ )}
+ >
+ Trusted {formatDateSmart(trustedAt)}
+ </div>
+ </TimestampTooltip>
+ );
+}
+
+export default function TrustedPartnersPage() {
+ const [partnerIdOrEmail, setPartnerIdOrEmail] = useState("");
+ const [isSubmitting, setIsSubmitting] = useState(false);
+ const [partnerToRemove, setPartnerToRemove] = useState<TrustedPartner | null>(
+ null,
+ );
+
+ const { data, isLoading, mutate } = useSWR<{ partners: TrustedPartner[] }>(
+ "/api/admin/partners",
+ fetcher,
+ { keepPreviousData: true },
+ );
+
+ const trustedPartners = data?.partners ?? [];
+
+ const { setShowConfirmModal, confirmModal } = useConfirmModal({
+ title: "Remove trusted partner",
+ description: partnerToRemove ? (
+ <>
+ Remove{" "}
+ <span className="font-medium text-neutral-900">
+ {partnerToRemove.name}
+ </span>{" "}
+ from the trusted partners list? They will no longer show the trusted
+ badge in the partner network.
+ </>
+ ) : null,
+ confirmText: "Remove",
+ confirmVariant: "danger",
+ cancelText: "Cancel",
+ onCancel: () => setPartnerToRemove(null),
+ onConfirm: async () => {
+ if (!partnerToRemove) return;
+
+ const res = await fetch("/api/admin/partners", {
+ method: "DELETE",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ partnerId: partnerToRemove.id }),
+ });
+
+ if (!res.ok) {
+ const message = await res.text();
+ toast.error(message || "Failed to remove trusted partner.");
+ throw new Error(message);
+ }
+
+ await mutate();
+ toast.success("Partner removed from trusted partners.");
+ setPartnerToRemove(null);
+ },
+ });
+
+ const openRemoveModal = useCallback(
+ (partner: TrustedPartner) => {
+ setPartnerToRemove(partner);
+ setShowConfirmModal(true);
+ },
+ [setShowConfirmModal],
+ );
+
+ const submitDisabled = useMemo(
+ () => isSubmitting || partnerIdOrEmail.trim().length === 0,
+ [isSubmitting, partnerIdOrEmail],
+ );
+
+ const onSubmit = async (e: FormEvent<HTMLFormElement>) => {
+ e.preventDefault();
+ const trimmedValue = partnerIdOrEmail.trim();
+ if (!trimmedValue) return;
+
+ setIsSubmitting(true);
+ await fetch("/api/admin/partners", {
+ method: "POST",
+ body: JSON.stringify({
+ partnerIdOrEmail: trimmedValue,
+ }),
+ })
+ .then(async (res) => {
+ if (!res.ok) {
+ throw new Error(await res.text());
+ }
+ await mutate();
+ setPartnerIdOrEmail("");
+ toast.success("Successfully marked partner as trusted.");
+ })
+ .catch((error) => {
+ toast.error(error.message || "Failed to mark partner as trusted.");
+ })
+ .finally(() => {
+ setIsSubmitting(false);
+ });
+ };
+
+ return (
+ <div className="mx-auto flex w-full max-w-screen-xl flex-col gap-6 p-6">
+ {confirmModal}
+ <div className="rounded-xl border border-neutral-200 bg-white p-5 sm:p-6">
+ <div className="mb-4">
+ <h1 className="text-base font-semibold text-neutral-900">
+ Trusted partners
+ </h1>
+ <p className="mt-1 text-sm text-neutral-600">
+ Add a partner by ID (e.g. pn_xxx) or email to mark them as trusted.
+ </p>
+ </div>
+
+ <form
+ onSubmit={onSubmit}
+ className="flex flex-col gap-2 sm:flex-row sm:items-center"
+ >
+ <input
+ type="text"
+ value={partnerIdOrEmail}
+ onChange={(e) => setPartnerIdOrEmail(e.target.value)}
+ placeholder="pn_123... or [email protected]"
+ className="w-full rounded-md border border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"
+ />
+ <Button
+ type="submit"
+ text="Add partner"
+ className="w-fit"
+ loading={isSubmitting}
+ disabled={submitDisabled}
+ />
+ </form>
+ </div>
+
+ <div className="overflow-hidden rounded-xl border border-neutral-200 bg-white">
+ {isLoading ? (
+ <div className="space-y-0 divide-y divide-neutral-100 px-4 py-2 sm:px-5">
+ {[0, 1, 2].map((i) => (
+ <div key={i} className="flex items-center gap-3 py-3.5">
+ <div className="size-10 shrink-0 animate-pulse rounded-full bg-neutral-100" />
+ <div className="min-w-0 flex-1 space-y-2">
+ <div className="h-4 w-40 max-w-full animate-pulse rounded bg-neutral-100" />
+ <div className="h-3 w-56 max-w-full animate-pulse rounded bg-neutral-50" />
+ </div>
+ </div>
+ ))}
+ </div>
+ ) : trustedPartners.length === 0 ? (
+ <p className="px-4 py-12 text-center text-sm text-neutral-500 sm:px-5">
+ No trusted partners yet.
+ </p>
+ ) : (
+ <ul className="divide-y divide-neutral-100">
+ {trustedPartners.map((partner) => (
+ <li key={partner.id}>
+ <div className="flex items-start gap-3 px-4 py-3.5 sm:px-5 md:items-center">
+ <PartnerAvatar
+ partner={partner}
+ className="size-10 shrink-0 border border-neutral-100 shadow-sm"
+ />
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-1">
+ <p className="truncate text-sm font-medium text-neutral-900">
+ {partner.name}
+ </p>
+ ·
+ <CopyText
+ value={partner.id}
+ className="truncate font-mono text-xs text-neutral-500"
+ >
+ {partner.id}
+ </CopyText>
+ </div>
+ {partner.email ? (
+ <CopyText
+ value={partner.email}
+ className="truncate text-sm text-neutral-500"
+ >
+ {partner.email}
+ </CopyText>
+ ) : null}
+ <TrustedAtLabel
+ trustedAt={partner.trustedAt}
+ className="mt-0.5 md:hidden"
+ />
+ </div>
+ <div className="flex shrink-0 items-center gap-4">
+ <TrustedAtLabel
+ trustedAt={partner.trustedAt}
+ className="hidden md:block"
+ />
+ <button
+ type="button"
+ aria-label={`Remove ${partner.name} from trusted partners`}
+ className={cn(
+ "shrink-0 rounded-md p-2 text-neutral-400 transition-colors",
+ "hover:bg-neutral-100 hover:text-neutral-700",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 focus-visible:ring-offset-2",
+ )}
+ onClick={() => openRemoveModal(partner)}
+ >
+ <Xmark className="size-4" />
+ </button>
+ </div>
+ </div>
+ </li>
+ ))}
+ </ul>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx
deleted file mode 100644
index e975d0258a..0000000000
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx
+++ /dev/null
@@ -1,470 +0,0 @@
-"use client";
-
-import { formatDateTooltip } from "@/lib/analytics/format-date-tooltip";
-import { AnalyticsLoadingSpinner } from "@/ui/analytics/analytics-loading-spinner";
-import { PayoutStatusBadges } from "@/ui/partners/payout-status-badges";
-import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
-import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
-import { InvoiceStatus } from "@dub/prisma/client";
-import {
- Button,
- Filter,
- StatusBadge,
- Table,
- usePagination,
- useRouterStuff,
- useTable,
-} from "@dub/ui";
-import { Areas, TimeSeriesChart, XAxis, YAxis } from "@dub/ui/charts";
-import { CircleDotted, GridIcon, Paypal } from "@dub/ui/icons";
-import {
- cn,
- currencyFormatter,
- fetcher,
- formatDateTime,
- OG_AVATAR_URL,
-} from "@dub/utils";
-import NumberFlow from "@number-flow/react";
-import Link from "next/link";
-import { Fragment, useCallback, useMemo, useState } from "react";
-import useSWR from "swr";
-
-interface TimeseriesData {
- date: Date;
- payouts: number;
- fees: number;
- total: number;
-}
-
-interface InvoiceData {
- date: Date;
- programId: string;
- programName: string;
- programLogo: string;
- status: InvoiceStatus;
- amount: number;
- fee: number;
- total: number;
-}
-
-type Tab = {
- id: "payouts" | "fees" | "total";
- label: string;
- colorClassName: string;
-};
-
-export default function PayoutsPageClient() {
- const { queryParams, getQueryString, searchParamsObj } = useRouterStuff();
- const { interval, start, end, status, programId } = searchParamsObj;
-
- const { data: { invoices, timeseriesData } = {}, isLoading } = useSWR<{
- invoices: InvoiceData[];
- timeseriesData: TimeseriesData[];
- }>(`/api/admin/payouts${getQueryString()}`, fetcher, {
- keepPreviousData: true,
- });
-
- // Extract unique programs from invoices
- const programs = useMemo(() => {
- if (!invoices) return [];
- const programMap = new Map<
- string,
- { id: string; name: string; logo: string }
- >();
- invoices.forEach((invoice) => {
- if (!programMap.has(invoice.programId)) {
- programMap.set(invoice.programId, {
- id: invoice.programId,
- name: invoice.programName,
- logo: invoice.programLogo,
- });
- }
- });
- return Array.from(programMap.values()).sort((a, b) =>
- a.name.localeCompare(b.name),
- );
- }, [invoices]);
-
- // Filter configuration
- const filters = useMemo(
- () => [
- {
- key: "programId",
- icon: GridIcon,
- label: "Program",
- options:
- programs.map((program) => ({
- value: program.id,
- label: program.name,
- icon: (
- <img
- src={program.logo || `${OG_AVATAR_URL}${program.name}`}
- alt={`${program.name} image`}
- className="size-4 rounded-full"
- />
- ),
- })) ?? null,
- },
- {
- key: "status",
- icon: CircleDotted,
- label: "Status",
- options: Object.entries(PayoutStatusBadges)
- .filter(([key]) =>
- ["processing", "completed", "failed"].includes(key),
- )
- .map(([value, { label }]) => {
- const Icon =
- PayoutStatusBadges[value as keyof typeof PayoutStatusBadges].icon;
- return {
- value,
- label,
- icon: (
- <Icon
- className={cn(
- PayoutStatusBadges[value as keyof typeof PayoutStatusBadges]
- .className,
- "size-4 bg-transparent",
- )}
- />
- ),
- };
- }),
- },
- ],
- [programs],
- );
-
- const activeFilters = useMemo(() => {
- return [
- ...(programId ? [{ key: "programId", value: programId }] : []),
- ...(status ? [{ key: "status", value: status }] : []),
- ];
- }, [programId, status]);
-
- const onSelect = useCallback(
- (key: string, value: any) =>
- queryParams({
- set: {
- [key]: value,
- },
- del: "page",
- }),
- [queryParams],
- );
-
- const onRemove = useCallback(
- (key: string) =>
- queryParams({
- del: [key, "page"],
- }),
- [queryParams],
- );
-
- const onRemoveAll = useCallback(
- () =>
- queryParams({
- del: ["status", "programId"],
- }),
- [queryParams],
- );
-
- const tabs: Tab[] = [
- {
- id: "payouts",
- label: "Payouts",
- colorClassName: "text-blue-500/50 bg-blue-500/50 border-blue-500",
- },
- {
- id: "fees",
- label: "Fees",
- colorClassName: "text-red-500/50 bg-red-500/50 border-red-500",
- },
- {
- id: "total",
- label: "Total",
- colorClassName: "text-green-500/50 bg-green-500/50 border-green-500",
- },
- ];
-
- const [selectedTab, setSelectedTab] = useState<"payouts" | "fees" | "total">(
- "payouts",
- );
- const tab = tabs.find(({ id }) => id === selectedTab) ?? tabs[0];
-
- // take the last 12 months
- const chartData =
- timeseriesData?.map(({ date, ...rest }) => ({
- date: new Date(date),
- values: {
- value: rest[selectedTab],
- },
- })) ?? null;
-
- const dateFormatter = (date: Date) =>
- date.toLocaleDateString("en-US", {
- month: "short",
- year: "numeric",
- timeZone: "UTC",
- });
-
- const totals = useMemo(() => {
- return {
- payouts:
- timeseriesData?.reduce((acc, { payouts }) => acc + payouts, 0) ?? 0,
- fees: timeseriesData?.reduce((acc, { fees }) => acc + fees, 0) ?? 0,
- total: timeseriesData?.reduce((acc, { total }) => acc + total, 0) ?? 0,
- };
- }, [timeseriesData]);
-
- const { pagination, setPagination } = usePagination();
-
- const { table, ...tableProps } = useTable({
- data: invoices ?? [],
- columns: [
- {
- id: "date",
- header: "Payment Date (UTC)",
- accessorKey: "date",
- cell: ({ row }) =>
- formatDateTime(row.original.date, {
- timeZone: "UTC",
- }),
- },
- {
- id: "program",
- header: "Program",
- cell: ({ row }) => (
- <div className="flex items-center gap-1.5">
- <img
- src={row.original.programLogo}
- alt={row.original.programName}
- width={20}
- height={20}
- className="size-4 rounded-full"
- />
- <span className="text-sm font-medium">
- {row.original.programName}
- </span>
- </div>
- ),
- meta: {
- filterParams: ({ row }) => ({
- programId: row.original.programId,
- }),
- },
- },
- {
- id: "status",
- header: "Status",
- cell: ({ row }) => {
- const badge = PayoutStatusBadges[row.original.status];
-
- return badge ? (
- <StatusBadge icon={badge.icon} variant={badge.variant}>
- {badge.label}
- </StatusBadge>
- ) : (
- "-"
- );
- },
- meta: {
- filterParams: ({ row }) => ({
- status: row.original.status,
- }),
- },
- },
- {
- id: "amount",
- header: "Amount",
- accessorKey: "amount",
- cell: ({ row }) => currencyFormatter(row.original.amount),
- },
- {
- id: "fee",
- header: "Fee",
- accessorKey: "fee",
- cell: ({ row }) => currencyFormatter(row.original.fee),
- },
- {
- id: "total",
- header: "Total",
- accessorKey: "total",
- cell: ({ row }) => currencyFormatter(row.original.total),
- },
- ],
- pagination,
- onPaginationChange: setPagination,
- resourceName: (plural) => `invoice${plural ? "s" : ""}`,
- rowCount: invoices?.length ?? 0,
- loading: isLoading,
- cellRight: (cell) => {
- const meta = cell.column.columnDef.meta as
- | {
- filterParams?: any;
- }
- | undefined;
-
- return (
- meta?.filterParams && (
- <FilterButtonTableRow set={meta.filterParams(cell)} />
- )
- );
- },
- });
-
- return (
- <div className="mx-auto flex w-full max-w-screen-xl flex-col gap-3 p-6">
- <div className="flex flex-col gap-3 md:flex-row md:items-center">
- <Filter.Select
- className="w-full md:w-fit"
- filters={filters}
- activeFilters={activeFilters}
- onSelect={onSelect}
- onRemove={onRemove}
- />
- <SimpleDateRangePicker
- defaultInterval="mtd"
- className="w-full sm:min-w-[200px] md:w-fit"
- />
- <Link href="/payouts/paypal">
- <Button
- variant="secondary"
- text="Paypal payouts"
- icon={<Paypal className="size-4" />}
- />
- </Link>
- </div>
- {activeFilters.length > 0 && (
- <div>
- <Filter.List
- filters={filters}
- activeFilters={activeFilters}
- onSelect={onSelect}
- onRemove={onRemove}
- onRemoveAll={onRemoveAll}
- />
- </div>
- )}
- <div className="flex flex-col divide-y divide-neutral-200 rounded-lg border border-neutral-200 bg-white">
- <div className="scrollbar-hide grid w-full grid-cols-1 divide-y overflow-y-hidden sm:grid-cols-3 sm:divide-x sm:divide-y-0">
- {tabs.map(({ id, label, colorClassName }) => {
- return (
- <button
- key={id}
- onClick={() => {
- setSelectedTab(id);
- queryParams({
- set: { tab: id },
- });
- }}
- className={cn(
- "border-box relative block h-full w-full flex-none px-4 py-3 sm:px-8 sm:py-6",
- "transition-colors hover:bg-neutral-50 focus:outline-none active:bg-neutral-100",
- "ring-inset ring-neutral-500 focus-visible:ring-1 sm:first:rounded-tl-xl",
- )}
- >
- {/* Active tab indicator */}
- {selectedTab === id && (
- <div className="absolute bottom-0 left-0 h-0.5 w-full bg-black" />
- )}
- <div className="flex items-center gap-2.5 text-sm text-neutral-600">
- <div
- className={cn(
- "h-2 w-2 rounded-sm bg-current shadow-[inset_0_0_0_1px_#00000019]",
- colorClassName,
- )}
- />
- <span>{label}</span>
- </div>
- <div className="mt-1 flex h-12 items-center">
- {(totals[id] || totals[id] === 0) && !isLoading ? (
- <NumberFlow
- value={(totals[id] ?? 0) / 100}
- className="text-xl font-medium sm:text-3xl"
- format={{
- style: "currency",
- currency: "USD",
- // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
- trailingZeroDisplay: "stripIfInteger",
- }}
- />
- ) : (
- <div className="h-10 w-24 animate-pulse rounded-md bg-neutral-200" />
- )}
- </div>
- </button>
- );
- })}
- </div>
- <div className="p-5 sm:p-10">
- <div className="flex h-96 w-full items-center justify-center">
- {chartData ? (
- chartData.length > 0 ? (
- <TimeSeriesChart
- data={chartData}
- series={[
- {
- id: "value",
- valueAccessor: (d) => d.values.value,
- isActive: true,
- colorClassName: tab.colorClassName,
- },
- ]}
- tooltipClassName="p-0"
- tooltipContent={(d) => (
- <>
- <p className="border-b border-neutral-200 px-4 py-3 text-sm text-neutral-900">
- {formatDateTooltip(d.date, {
- interval,
- start,
- end,
- timezone: "UTC",
- })}
- </p>
- <div className="grid grid-cols-2 gap-x-6 gap-y-2 px-4 py-3 text-sm">
- <Fragment>
- <div className="flex items-center gap-2">
- <div
- className={cn(
- "h-2 w-2 rounded-sm shadow-[inset_0_0_0_1px_#0003]",
- tab.colorClassName,
- )}
- />
- <p className="capitalize text-neutral-600">
- {tab.label}
- </p>
- </div>
- <p className="text-right font-medium text-neutral-900">
- {currencyFormatter(d.values.value)}
- </p>
- </Fragment>
- </div>
- </>
- )}
- >
- <Areas />
- <XAxis maxTicks={5} tickFormat={dateFormatter} />
- <YAxis
- showGridLines
- tickFormat={(value) => currencyFormatter(value)}
- />
- </TimeSeriesChart>
- ) : (
- <div className="text-center text-sm text-neutral-600">
- No data available.
- </div>
- )
- ) : (
- <AnalyticsLoadingSpinner />
- )}
- </div>
- </div>
- </div>
-
- <div className="w-full">
- <Table {...tableProps} table={table} />
- </div>
- </div>
- );
-}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/page.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/page.tsx
index b6d5bcf7f3..903c069595 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/page.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/page.tsx
@@ -1,10 +1,470 @@
-import { Suspense } from "react";
-import PayoutsPageClient from "./client";
+"use client";
+
+import { formatDateTooltip } from "@/lib/analytics/format-date-tooltip";
+import { AnalyticsLoadingSpinner } from "@/ui/analytics/analytics-loading-spinner";
+import { PayoutStatusBadges } from "@/ui/partners/payout-status-badges";
+import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
+import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
+import { InvoiceStatus } from "@dub/prisma/client";
+import {
+ Button,
+ Filter,
+ StatusBadge,
+ Table,
+ usePagination,
+ useRouterStuff,
+ useTable,
+} from "@dub/ui";
+import { Areas, TimeSeriesChart, XAxis, YAxis } from "@dub/ui/charts";
+import { CircleDotted, GridIcon, Paypal } from "@dub/ui/icons";
+import {
+ cn,
+ currencyFormatter,
+ fetcher,
+ formatDateTime,
+ OG_AVATAR_URL,
+} from "@dub/utils";
+import NumberFlow from "@number-flow/react";
+import Link from "next/link";
+import { Fragment, useCallback, useMemo, useState } from "react";
+import useSWR from "swr";
+
+interface TimeseriesData {
+ date: Date;
+ payouts: number;
+ fees: number;
+ total: number;
+}
+
+interface InvoiceData {
+ date: Date;
+ programId: string;
+ programName: string;
+ programLogo: string;
+ status: InvoiceStatus;
+ amount: number;
+ fee: number;
+ total: number;
+}
+
+type Tab = {
+ id: "payouts" | "fees" | "total";
+ label: string;
+ colorClassName: string;
+};
+
+export default function PayoutsPage() {
+ const { queryParams, getQueryString, searchParamsObj } = useRouterStuff();
+ const { interval, start, end, status, programId } = searchParamsObj;
+
+ const { data: { invoices, timeseriesData } = {}, isLoading } = useSWR<{
+ invoices: InvoiceData[];
+ timeseriesData: TimeseriesData[];
+ }>(`/api/admin/payouts${getQueryString()}`, fetcher, {
+ keepPreviousData: true,
+ });
+
+ // Extract unique programs from invoices
+ const programs = useMemo(() => {
+ if (!invoices) return [];
+ const programMap = new Map<
+ string,
+ { id: string; name: string; logo: string }
+ >();
+ invoices.forEach((invoice) => {
+ if (!programMap.has(invoice.programId)) {
+ programMap.set(invoice.programId, {
+ id: invoice.programId,
+ name: invoice.programName,
+ logo: invoice.programLogo,
+ });
+ }
+ });
+ return Array.from(programMap.values()).sort((a, b) =>
+ a.name.localeCompare(b.name),
+ );
+ }, [invoices]);
+
+ // Filter configuration
+ const filters = useMemo(
+ () => [
+ {
+ key: "programId",
+ icon: GridIcon,
+ label: "Program",
+ options:
+ programs.map((program) => ({
+ value: program.id,
+ label: program.name,
+ icon: (
+ <img
+ src={program.logo || `${OG_AVATAR_URL}${program.name}`}
+ alt={`${program.name} image`}
+ className="size-4 rounded-full"
+ />
+ ),
+ })) ?? null,
+ },
+ {
+ key: "status",
+ icon: CircleDotted,
+ label: "Status",
+ options: Object.entries(PayoutStatusBadges)
+ .filter(([key]) =>
+ ["processing", "completed", "failed"].includes(key),
+ )
+ .map(([value, { label }]) => {
+ const Icon =
+ PayoutStatusBadges[value as keyof typeof PayoutStatusBadges].icon;
+ return {
+ value,
+ label,
+ icon: (
+ <Icon
+ className={cn(
+ PayoutStatusBadges[value as keyof typeof PayoutStatusBadges]
+ .className,
+ "size-4 bg-transparent",
+ )}
+ />
+ ),
+ };
+ }),
+ },
+ ],
+ [programs],
+ );
+
+ const activeFilters = useMemo(() => {
+ return [
+ ...(programId ? [{ key: "programId", value: programId }] : []),
+ ...(status ? [{ key: "status", value: status }] : []),
+ ];
+ }, [programId, status]);
+
+ const onSelect = useCallback(
+ (key: string, value: any) =>
+ queryParams({
+ set: {
+ [key]: value,
+ },
+ del: "page",
+ }),
+ [queryParams],
+ );
+
+ const onRemove = useCallback(
+ (key: string) =>
+ queryParams({
+ del: [key, "page"],
+ }),
+ [queryParams],
+ );
+
+ const onRemoveAll = useCallback(
+ () =>
+ queryParams({
+ del: ["status", "programId"],
+ }),
+ [queryParams],
+ );
+
+ const tabs: Tab[] = [
+ {
+ id: "payouts",
+ label: "Payouts",
+ colorClassName: "text-blue-500/50 bg-blue-500/50 border-blue-500",
+ },
+ {
+ id: "fees",
+ label: "Fees",
+ colorClassName: "text-red-500/50 bg-red-500/50 border-red-500",
+ },
+ {
+ id: "total",
+ label: "Total",
+ colorClassName: "text-green-500/50 bg-green-500/50 border-green-500",
+ },
+ ];
+
+ const [selectedTab, setSelectedTab] = useState<"payouts" | "fees" | "total">(
+ "payouts",
+ );
+ const tab = tabs.find(({ id }) => id === selectedTab) ?? tabs[0];
+
+ // take the last 12 months
+ const chartData =
+ timeseriesData?.map(({ date, ...rest }) => ({
+ date: new Date(date),
+ values: {
+ value: rest[selectedTab],
+ },
+ })) ?? null;
+
+ const dateFormatter = (date: Date) =>
+ date.toLocaleDateString("en-US", {
+ month: "short",
+ year: "numeric",
+ timeZone: "UTC",
+ });
+
+ const totals = useMemo(() => {
+ return {
+ payouts:
+ timeseriesData?.reduce((acc, { payouts }) => acc + payouts, 0) ?? 0,
+ fees: timeseriesData?.reduce((acc, { fees }) => acc + fees, 0) ?? 0,
+ total: timeseriesData?.reduce((acc, { total }) => acc + total, 0) ?? 0,
+ };
+ }, [timeseriesData]);
+
+ const { pagination, setPagination } = usePagination();
+
+ const { table, ...tableProps } = useTable({
+ data: invoices ?? [],
+ columns: [
+ {
+ id: "date",
+ header: "Payment Date (UTC)",
+ accessorKey: "date",
+ cell: ({ row }) =>
+ formatDateTime(row.original.date, {
+ timeZone: "UTC",
+ }),
+ },
+ {
+ id: "program",
+ header: "Program",
+ cell: ({ row }) => (
+ <div className="flex items-center gap-1.5">
+ <img
+ src={row.original.programLogo}
+ alt={row.original.programName}
+ width={20}
+ height={20}
+ className="size-4 rounded-full"
+ />
+ <span className="text-sm font-medium">
+ {row.original.programName}
+ </span>
+ </div>
+ ),
+ meta: {
+ filterParams: ({ row }) => ({
+ programId: row.original.programId,
+ }),
+ },
+ },
+ {
+ id: "status",
+ header: "Status",
+ cell: ({ row }) => {
+ const badge = PayoutStatusBadges[row.original.status];
+
+ return badge ? (
+ <StatusBadge icon={badge.icon} variant={badge.variant}>
+ {badge.label}
+ </StatusBadge>
+ ) : (
+ "-"
+ );
+ },
+ meta: {
+ filterParams: ({ row }) => ({
+ status: row.original.status,
+ }),
+ },
+ },
+ {
+ id: "amount",
+ header: "Amount",
+ accessorKey: "amount",
+ cell: ({ row }) => currencyFormatter(row.original.amount),
+ },
+ {
+ id: "fee",
+ header: "Fee",
+ accessorKey: "fee",
+ cell: ({ row }) => currencyFormatter(row.original.fee),
+ },
+ {
+ id: "total",
+ header: "Total",
+ accessorKey: "total",
+ cell: ({ row }) => currencyFormatter(row.original.total),
+ },
+ ],
+ pagination,
+ onPaginationChange: setPagination,
+ resourceName: (plural) => `invoice${plural ? "s" : ""}`,
+ rowCount: invoices?.length ?? 0,
+ loading: isLoading,
+ cellRight: (cell) => {
+ const meta = cell.column.columnDef.meta as
+ | {
+ filterParams?: any;
+ }
+ | undefined;
+
+ return (
+ meta?.filterParams && (
+ <FilterButtonTableRow set={meta.filterParams(cell)} />
+ )
+ );
+ },
+ });
-export default async function PayoutsPage() {
return (
- <Suspense>
- <PayoutsPageClient />
- </Suspense>
+ <div className="mx-auto flex w-full max-w-screen-xl flex-col gap-3 p-6">
+ <div className="flex flex-col gap-3 md:flex-row md:items-center">
+ <Filter.Select
+ className="w-full md:w-fit"
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ />
+ <SimpleDateRangePicker
+ defaultInterval="mtd"
+ className="w-full sm:min-w-[200px] md:w-fit"
+ />
+ <Link href="/payouts/paypal">
+ <Button
+ variant="secondary"
+ text="Paypal payouts"
+ icon={<Paypal className="size-4" />}
+ />
+ </Link>
+ </div>
+ {activeFilters.length > 0 && (
+ <div>
+ <Filter.List
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ onRemoveAll={onRemoveAll}
+ />
+ </div>
+ )}
+ <div className="flex flex-col divide-y divide-neutral-200 rounded-lg border border-neutral-200 bg-white">
+ <div className="scrollbar-hide grid w-full grid-cols-1 divide-y overflow-y-hidden sm:grid-cols-3 sm:divide-x sm:divide-y-0">
+ {tabs.map(({ id, label, colorClassName }) => {
+ return (
+ <button
+ key={id}
+ onClick={() => {
+ setSelectedTab(id);
+ queryParams({
+ set: { tab: id },
+ });
+ }}
+ className={cn(
+ "border-box relative block h-full w-full flex-none px-4 py-3 sm:px-8 sm:py-6",
+ "transition-colors hover:bg-neutral-50 focus:outline-none active:bg-neutral-100",
+ "ring-inset ring-neutral-500 focus-visible:ring-1 sm:first:rounded-tl-xl",
+ )}
+ >
+ {/* Active tab indicator */}
+ {selectedTab === id && (
+ <div className="absolute bottom-0 left-0 h-0.5 w-full bg-black" />
+ )}
+ <div className="flex items-center gap-2.5 text-sm text-neutral-600">
+ <div
+ className={cn(
+ "h-2 w-2 rounded-sm bg-current shadow-[inset_0_0_0_1px_#00000019]",
+ colorClassName,
+ )}
+ />
+ <span>{label}</span>
+ </div>
+ <div className="mt-1 flex h-12 items-center">
+ {(totals[id] || totals[id] === 0) && !isLoading ? (
+ <NumberFlow
+ value={(totals[id] ?? 0) / 100}
+ className="text-xl font-medium sm:text-3xl"
+ format={{
+ style: "currency",
+ currency: "USD",
+ // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
+ trailingZeroDisplay: "stripIfInteger",
+ }}
+ />
+ ) : (
+ <div className="h-10 w-24 animate-pulse rounded-md bg-neutral-200" />
+ )}
+ </div>
+ </button>
+ );
+ })}
+ </div>
+ <div className="p-5 sm:p-10">
+ <div className="flex h-96 w-full items-center justify-center">
+ {chartData ? (
+ chartData.length > 0 ? (
+ <TimeSeriesChart
+ data={chartData}
+ series={[
+ {
+ id: "value",
+ valueAccessor: (d) => d.values.value,
+ isActive: true,
+ colorClassName: tab.colorClassName,
+ },
+ ]}
+ tooltipClassName="p-0"
+ tooltipContent={(d) => (
+ <>
+ <p className="border-b border-neutral-200 px-4 py-3 text-sm text-neutral-900">
+ {formatDateTooltip(d.date, {
+ interval,
+ start,
+ end,
+ timezone: "UTC",
+ })}
+ </p>
+ <div className="grid grid-cols-2 gap-x-6 gap-y-2 px-4 py-3 text-sm">
+ <Fragment>
+ <div className="flex items-center gap-2">
+ <div
+ className={cn(
+ "h-2 w-2 rounded-sm shadow-[inset_0_0_0_1px_#0003]",
+ tab.colorClassName,
+ )}
+ />
+ <p className="capitalize text-neutral-600">
+ {tab.label}
+ </p>
+ </div>
+ <p className="text-right font-medium text-neutral-900">
+ {currencyFormatter(d.values.value)}
+ </p>
+ </Fragment>
+ </div>
+ </>
+ )}
+ >
+ <Areas />
+ <XAxis maxTicks={5} tickFormat={dateFormatter} />
+ <YAxis
+ showGridLines
+ tickFormat={(value) => currencyFormatter(value)}
+ />
+ </TimeSeriesChart>
+ ) : (
+ <div className="text-center text-sm text-neutral-600">
+ No data available.
+ </div>
+ )
+ ) : (
+ <AnalyticsLoadingSpinner />
+ )}
+ </div>
+ </div>
+ </div>
+
+ <div className="w-full">
+ <Table {...tableProps} table={table} />
+ </div>
+ </div>
);
}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/revenue/client.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/revenue/client.tsx
deleted file mode 100644
index 401d62e2f8..0000000000
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/revenue/client.tsx
+++ /dev/null
@@ -1,180 +0,0 @@
-"use client";
-
-import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
-import {
- CrownSmall,
- Table,
- usePagination,
- useRouterStuff,
- useTable,
-} from "@dub/ui";
-import { cn, currencyFormatter, fetcher, nFormatter } from "@dub/utils";
-import NumberFlow from "@number-flow/react";
-import { useMemo } from "react";
-import useSWR from "swr";
-
-export default function RevenuePageClient() {
- const { getQueryString } = useRouterStuff();
-
- const { data: { programs } = {}, isLoading } = useSWR<{
- programs: {
- id: string;
- name: string;
- logo: string;
- partners: number;
- sales: number;
- saleAmount: number;
- }[];
- }>(`/api/admin/revenue${getQueryString()}`, fetcher, {
- keepPreviousData: true,
- });
-
- const { pagination, setPagination } = usePagination();
-
- const { table, ...tableProps } = useTable({
- data: programs ?? [],
- columns: [
- {
- id: "position",
- header: "Position",
- size: 12,
- minSize: 12,
- maxSize: 12,
- cell: ({ row }) => {
- return (
- <div className="flex w-28 items-center justify-start gap-2 tabular-nums">
- {row.index + 1}
- {row.index <= 2 && (
- <CrownSmall
- className={cn("size-4", {
- "text-amber-400": row.index === 0,
- "text-neutral-400": row.index === 1,
- "text-yellow-900": row.index === 2,
- })}
- />
- )}
- </div>
- );
- },
- },
- {
- id: "program",
- header: "Program",
- cell: ({ row }) => (
- <div className="flex items-center gap-1.5">
- <img
- src={row.original.logo}
- alt={row.original.name}
- width={20}
- height={20}
- className="size-4 rounded-full"
- />
- <span className="text-sm font-medium">{row.original.name}</span>
- </div>
- ),
- },
- {
- id: "partners",
- header: "Active Partners",
- accessorKey: "partners",
- cell: ({ row }) => nFormatter(row.original.partners, { full: true }),
- },
- {
- id: "sales",
- header: "Total Sales",
- accessorKey: "sales",
- cell: ({ row }) => nFormatter(row.original.sales, { full: true }),
- },
- {
- id: "revenue",
- header: "Affiliate Revenue",
- accessorKey: "revenue",
- cell: ({ row }) => currencyFormatter(row.original.saleAmount),
- },
- ],
- pagination,
- onPaginationChange: setPagination,
- resourceName: (plural) => `program${plural ? "s" : ""}`,
- rowCount: programs?.length ?? 0,
- loading: isLoading,
- });
-
- const stats = useMemo(
- () => [
- {
- id: "partners",
- label: "Active Partners",
- value: programs?.reduce(
- (acc, { partners }) => acc + (partners || 0),
- 0,
- ),
- colorClassName: "bg-blue-500",
- },
- {
- id: "sales",
- label: "Total Sales",
- value: programs?.reduce((acc, { sales }) => acc + (sales || 0), 0),
- colorClassName: "bg-green-500",
- },
- {
- id: "revenue",
- label: "Affiliate Revenue",
- value: programs?.reduce(
- (acc, { saleAmount }) => acc + (saleAmount || 0),
- 0,
- ),
- colorClassName: "bg-purple-500",
- },
- ],
- [programs],
- );
-
- return (
- <div className="mx-auto flex w-full max-w-screen-xl flex-col space-y-6 p-6">
- <SimpleDateRangePicker defaultInterval="mtd" className="w-fit" />
- <div className="flex flex-col divide-y divide-neutral-200 rounded-lg border border-neutral-200 bg-white">
- <div className="grid w-full grid-cols-1 divide-x sm:grid-cols-3">
- {stats.map(({ id, label, value, colorClassName }) => (
- <div key={id} className="flex-none px-4 py-3 sm:px-8 sm:py-6">
- <div className="flex items-center gap-2.5 text-sm text-neutral-600">
- <div
- className={cn(
- "h-2 w-2 rounded-sm shadow-[inset_0_0_0_1px_#00000019]",
- colorClassName,
- )}
- />
- <span>{label}</span>
- </div>
- <div className="mt-1 flex h-12 items-center">
- {value !== undefined ? (
- id === "revenue" ? (
- <NumberFlow
- value={value / 100}
- className="text-xl font-medium sm:text-3xl"
- format={{
- style: "currency",
- currency: "USD",
- // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
- trailingZeroDisplay: "stripIfInteger",
- }}
- />
- ) : (
- <NumberFlow
- value={value}
- className="text-xl font-medium sm:text-3xl"
- />
- )
- ) : (
- <div className="h-10 w-24 animate-pulse rounded-md bg-neutral-200" />
- )}
- </div>
- </div>
- ))}
- </div>
- </div>
- <div className="w-full">
- <Table {...tableProps} table={table} />
- </div>
- </div>
- );
-}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/revenue/page.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/revenue/page.tsx
index 0d1dffc677..f43dba7b04 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/revenue/page.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/revenue/page.tsx
@@ -1,10 +1,180 @@
-import { Suspense } from "react";
-import RevenuePageClient from "./client";
+"use client";
+
+import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
+import {
+ CrownSmall,
+ Table,
+ usePagination,
+ useRouterStuff,
+ useTable,
+} from "@dub/ui";
+import { cn, currencyFormatter, fetcher, nFormatter } from "@dub/utils";
+import NumberFlow from "@number-flow/react";
+import { useMemo } from "react";
+import useSWR from "swr";
+
+export default function RevenuePage() {
+ const { getQueryString } = useRouterStuff();
+
+ const { data: { programs } = {}, isLoading } = useSWR<{
+ programs: {
+ id: string;
+ name: string;
+ logo: string;
+ partners: number;
+ sales: number;
+ saleAmount: number;
+ }[];
+ }>(`/api/admin/revenue${getQueryString()}`, fetcher, {
+ keepPreviousData: true,
+ });
+
+ const { pagination, setPagination } = usePagination();
+
+ const { table, ...tableProps } = useTable({
+ data: programs ?? [],
+ columns: [
+ {
+ id: "position",
+ header: "Position",
+ size: 12,
+ minSize: 12,
+ maxSize: 12,
+ cell: ({ row }) => {
+ return (
+ <div className="flex w-28 items-center justify-start gap-2 tabular-nums">
+ {row.index + 1}
+ {row.index <= 2 && (
+ <CrownSmall
+ className={cn("size-4", {
+ "text-amber-400": row.index === 0,
+ "text-neutral-400": row.index === 1,
+ "text-yellow-900": row.index === 2,
+ })}
+ />
+ )}
+ </div>
+ );
+ },
+ },
+ {
+ id: "program",
+ header: "Program",
+ cell: ({ row }) => (
+ <div className="flex items-center gap-1.5">
+ <img
+ src={row.original.logo}
+ alt={row.original.name}
+ width={20}
+ height={20}
+ className="size-4 rounded-full"
+ />
+ <span className="text-sm font-medium">{row.original.name}</span>
+ </div>
+ ),
+ },
+ {
+ id: "partners",
+ header: "Active Partners",
+ accessorKey: "partners",
+ cell: ({ row }) => nFormatter(row.original.partners, { full: true }),
+ },
+ {
+ id: "sales",
+ header: "Total Sales",
+ accessorKey: "sales",
+ cell: ({ row }) => nFormatter(row.original.sales, { full: true }),
+ },
+ {
+ id: "revenue",
+ header: "Affiliate Revenue",
+ accessorKey: "revenue",
+ cell: ({ row }) => currencyFormatter(row.original.saleAmount),
+ },
+ ],
+ pagination,
+ onPaginationChange: setPagination,
+ resourceName: (plural) => `program${plural ? "s" : ""}`,
+ rowCount: programs?.length ?? 0,
+ loading: isLoading,
+ });
+
+ const stats = useMemo(
+ () => [
+ {
+ id: "partners",
+ label: "Active Partners",
+ value: programs?.reduce(
+ (acc, { partners }) => acc + (partners || 0),
+ 0,
+ ),
+ colorClassName: "bg-blue-500",
+ },
+ {
+ id: "sales",
+ label: "Total Sales",
+ value: programs?.reduce((acc, { sales }) => acc + (sales || 0), 0),
+ colorClassName: "bg-green-500",
+ },
+ {
+ id: "revenue",
+ label: "Affiliate Revenue",
+ value: programs?.reduce(
+ (acc, { saleAmount }) => acc + (saleAmount || 0),
+ 0,
+ ),
+ colorClassName: "bg-purple-500",
+ },
+ ],
+ [programs],
+ );
-export default async function RevenuePage() {
return (
- <Suspense>
- <RevenuePageClient />
- </Suspense>
+ <div className="mx-auto flex w-full max-w-screen-xl flex-col space-y-6 p-6">
+ <SimpleDateRangePicker defaultInterval="mtd" className="w-fit" />
+ <div className="flex flex-col divide-y divide-neutral-200 rounded-lg border border-neutral-200 bg-white">
+ <div className="grid w-full grid-cols-1 divide-x sm:grid-cols-3">
+ {stats.map(({ id, label, value, colorClassName }) => (
+ <div key={id} className="flex-none px-4 py-3 sm:px-8 sm:py-6">
+ <div className="flex items-center gap-2.5 text-sm text-neutral-600">
+ <div
+ className={cn(
+ "h-2 w-2 rounded-sm shadow-[inset_0_0_0_1px_#00000019]",
+ colorClassName,
+ )}
+ />
+ <span>{label}</span>
+ </div>
+ <div className="mt-1 flex h-12 items-center">
+ {value !== undefined ? (
+ id === "revenue" ? (
+ <NumberFlow
+ value={value / 100}
+ className="text-xl font-medium sm:text-3xl"
+ format={{
+ style: "currency",
+ currency: "USD",
+ // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
+ trailingZeroDisplay: "stripIfInteger",
+ }}
+ />
+ ) : (
+ <NumberFlow
+ value={value}
+ className="text-xl font-medium sm:text-3xl"
+ />
+ )
+ ) : (
+ <div className="h-10 w-24 animate-pulse rounded-md bg-neutral-200" />
+ )}
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ <div className="w-full">
+ <Table {...tableProps} table={table} />
+ </div>
+ </div>
);
}
diff --git a/apps/web/app/(ee)/api/admin/partners/route.ts b/apps/web/app/(ee)/api/admin/partners/route.ts
new file mode 100644
index 0000000000..00af983934
--- /dev/null
+++ b/apps/web/app/(ee)/api/admin/partners/route.ts
@@ -0,0 +1,103 @@
+import { withAdmin } from "@/lib/auth";
+import { prisma } from "@dub/prisma";
+import { NextResponse } from "next/server";
+import * as z from "zod/v4";
+
+// GET /api/admin/partners
+export const GET = withAdmin(async () => {
+ const partners = await prisma.partner.findMany({
+ where: {
+ trustedAt: {
+ not: null,
+ },
+ },
+ orderBy: {
+ trustedAt: "desc",
+ },
+ select: {
+ id: true,
+ name: true,
+ email: true,
+ image: true,
+ trustedAt: true,
+ },
+ });
+
+ return NextResponse.json({ partners });
+});
+
+// POST /api/admin/partners
+export const POST = withAdmin(async ({ req }) => {
+ const { partnerIdOrEmail } = z
+ .object({
+ partnerIdOrEmail: z.string().trim().min(1),
+ })
+ .parse(await req.json());
+
+ if (!partnerIdOrEmail.startsWith("pn_") && !partnerIdOrEmail.includes("@")) {
+ return new Response("Invalid partner ID or email.", { status: 400 });
+ }
+
+ const partner = await prisma.partner.findFirst({
+ where: partnerIdOrEmail.startsWith("pn_")
+ ? { id: partnerIdOrEmail }
+ : { email: partnerIdOrEmail },
+ select: {
+ id: true,
+ trustedAt: true,
+ },
+ });
+
+ if (!partner) {
+ return new Response("Partner not found.", { status: 404 });
+ }
+
+ if (partner.trustedAt) {
+ return new Response("Partner is already marked as trusted.", {
+ status: 400,
+ });
+ }
+
+ const updatedPartner = await prisma.partner.update({
+ where: {
+ id: partner.id,
+ },
+ data: {
+ trustedAt: new Date(),
+ },
+ select: {
+ id: true,
+ name: true,
+ email: true,
+ image: true,
+ trustedAt: true,
+ },
+ });
+
+ return NextResponse.json(updatedPartner);
+});
+
+// DELETE /api/admin/partners — clears trusted status (removes from trusted list)
+export const DELETE = withAdmin(async ({ req }) => {
+ const { partnerId } = z
+ .object({
+ partnerId: z.string().trim().min(1),
+ })
+ .parse(await req.json());
+
+ const partner = await prisma.partner.findUnique({
+ where: { id: partnerId },
+ select: { id: true, trustedAt: true },
+ });
+
+ if (!partner) {
+ return new Response("Partner not found.", { status: 404 });
+ }
+
+ await prisma.partner.update({
+ where: { id: partner.id },
+ data: { trustedAt: null },
+ });
+
+ return NextResponse.json({ success: true });
+});
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx
index ed42556068..1b24cf5f32 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/add-edit-bounty-sheet.tsx
@@ -418,7 +418,7 @@ function BountySheetContent({ setIsOpen, bounty }: BountySheetProps) {
<div className="flex items-center gap-2.5">
<RewardIconSquare icon={CalendarIcon} />
<span className="text-content-default text-sm leading-relaxed">
- Partners can submit{" "}
+ Partners can only submit{" "}
<SubmissionWindowBadge
value={submissionWindow}
onChange={handleSubmissionWindowChange}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-criteria-manual-submission.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-criteria-manual-submission.tsx
index 328cbd2bf7..47f3273cf6 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-criteria-manual-submission.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty/bounty-criteria-manual-submission.tsx
@@ -322,8 +322,8 @@ export function BountyCriteriaManualSubmission() {
)}
<p className="text-xs text-neutral-500">
- Restrict URLs to specific domains. Partners can submit URLs
- from these domains or their subdomains.
+ Restrict URLs to specific domains. Partners can only submit
+ URLs from these domains or their subdomains.
</p>
</div>
</div>