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 `PartnerNetworkStatus` enum (#3876)

Steven Tey20911d631fb0
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 972c185fe1..aeff9f81de 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
@@ -29,17 +29,13 @@ const tabs = [
label: "Payouts",
},
{
- href: "/partners",
+ href: "/partners/network",
label: "Partners",
},
{
href: "/revenue",
label: "Revenue",
},
- {
- href: "/fraud-alerts",
- label: "Fraud Alerts",
- },
];
export function AdminNav() {
@@ -54,8 +50,12 @@ export function AdminNav() {
pathname === tab.href || pathname?.startsWith(`${tab.href}/`);
return (
<Link
- href={tab.href}
key={tab.href}
+ href={
+ tab.href === "/partners/network"
+ ? "/partners/network?networkStatus=submitted"
+ : tab.href
+ }
className={`block w-full rounded-md px-4 py-2 text-left text-sm text-neutral-700 transition-colors hover:bg-neutral-100 active:bg-neutral-200 ${
isActive ? "bg-neutral-100" : ""
}`}
@@ -110,8 +110,12 @@ export function AdminNav() {
pathname?.startsWith(`${tab.href}/`);
return (
<Link
- href={tab.href}
key={tab.href}
+ href={
+ tab.href === "/partners/network"
+ ? "/partners/network?networkStatus=submitted"
+ : tab.href
+ }
className={`rounded-md px-3 py-1.5 text-sm transition-colors ${
isActive
? "bg-neutral-100 text-neutral-900"
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/fraud-alerts/page.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/fraud/page.tsx
similarity index 93%
rename from apps/web/app/(ee)/admin.dub.co/(dashboard)/fraud-alerts/page.tsx
rename to apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/fraud/page.tsx
index 3fd307d515..bef5c19b1e 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/fraud-alerts/page.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/fraud/page.tsx
@@ -1,6 +1,6 @@
"use client";
-import { fraudAlertSchema } from "@/lib/zod/schemas/fraud";
+import { adminFraudAlertSchema } from "@/lib/zod/schemas/admin";
import { PartnerAvatar } from "@/ui/partners/partner-avatar";
import { FraudAlertStatus } from "@dub/prisma/client";
import {
@@ -19,7 +19,7 @@ import useSWR from "swr";
import * as z from "zod/v4";
import { ReviewFraudAlertSheet } from "./review-fraud-alert-sheet";
-type FraudAlert = z.infer<typeof fraudAlertSchema>;
+type AdminFraudAlert = z.infer<typeof adminFraudAlertSchema>;
const FRAUD_ALERT_STATUS_BADGES: Record<
FraudAlertStatus,
@@ -42,23 +42,25 @@ function FraudAlertsPageClient() {
const { queryParams, getQueryString, searchParamsObj } = useRouterStuff();
const { status, programId } = searchParamsObj;
- const [selectedAlert, setSelectedAlert] = useState<FraudAlert | null>(null);
+ const [selectedAlert, setSelectedAlert] = useState<AdminFraudAlert | null>(
+ null,
+ );
const {
data: { fraudAlerts, total } = {},
isLoading,
mutate,
} = useSWR<{
- fraudAlerts: FraudAlert[];
+ fraudAlerts: AdminFraudAlert[];
total: number;
- }>(`/api/admin/fraud-alerts${getQueryString()}`, fetcher, {
+ }>(`/api/admin/partners/fraud${getQueryString()}`, fetcher, {
keepPreviousData: true,
});
// Extract unique programs from fraud alerts for filter options
const programs = useMemo(() => {
if (!fraudAlerts) return [];
- const programMap = new Map<string, FraudAlert["program"]>();
+ const programMap = new Map<string, AdminFraudAlert["program"]>();
fraudAlerts.forEach((alert) => {
if (!programMap.has(alert.program.id)) {
@@ -242,9 +244,7 @@ function FraudAlertsPageClient() {
});
return (
- <div className="mx-auto flex w-full max-w-screen-xl flex-col gap-6 p-6">
- <h1 className="text-2xl font-semibold text-neutral-900">Fraud Alerts</h1>
-
+ <>
<div>
<Filter.Select
className="w-full md:w-fit"
@@ -285,6 +285,6 @@ function FraudAlertsPageClient() {
await mutate();
}}
/>
- </div>
+ </>
);
}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/fraud-alerts/review-fraud-alert-sheet.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/fraud/review-fraud-alert-sheet.tsx
similarity index 98%
rename from apps/web/app/(ee)/admin.dub.co/(dashboard)/fraud-alerts/review-fraud-alert-sheet.tsx
rename to apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/fraud/review-fraud-alert-sheet.tsx
index 3e7853c575..217ad7305f 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/fraud-alerts/review-fraud-alert-sheet.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/fraud/review-fraud-alert-sheet.tsx
@@ -2,7 +2,7 @@
import { PARTNER_PLATFORM_FIELDS } from "@/lib/partners/partner-platforms";
import { PartnerPlatformProps } from "@/lib/types";
-import { fraudAlertSchema } from "@/lib/zod/schemas/fraud";
+import { adminFraudAlertSchema } from "@/lib/zod/schemas/admin";
import {
MAX_FRAUD_REASON_LENGTH,
PartnerSchema,
@@ -39,7 +39,7 @@ import { toast } from "sonner";
import useSWR from "swr";
import * as z from "zod/v4";
-type FraudAlert = z.infer<typeof fraudAlertSchema>;
+type AdminFraudAlert = z.infer<typeof adminFraudAlertSchema>;
type ProgramInfo = Pick<z.infer<typeof ProgramSchema>, "id" | "name" | "logo">;
@@ -51,7 +51,7 @@ type PartnerDetail = z.infer<typeof PartnerSchema> & {
> & {
program: ProgramInfo;
})[];
- fraudAlerts: FraudAlert[];
+ fraudAlerts: AdminFraudAlert[];
payouts: (z.infer<typeof PayoutSchema> & {
program: ProgramInfo;
})[];
@@ -81,7 +81,7 @@ export function ReviewFraudAlertSheet({
setIsOpen,
onReviewed,
}: {
- alert: FraudAlert | null;
+ alert: AdminFraudAlert | null;
isOpen: boolean;
setIsOpen: (open: boolean) => void;
onReviewed: () => Promise<void>;
@@ -110,7 +110,7 @@ function SheetContent({
setIsOpen,
onReviewed,
}: {
- fraudAlert: FraudAlert;
+ fraudAlert: AdminFraudAlert;
setIsOpen: (open: boolean) => void;
onReviewed: () => Promise<void>;
}) {
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/layout.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/layout.tsx
new file mode 100644
index 0000000000..28ccc7c425
--- /dev/null
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/layout.tsx
@@ -0,0 +1,22 @@
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
+import { Suspense } from "react";
+import { PartnersNavTabs } from "./partners-nav-tabs";
+
+export default function AdminPartnersLayout({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ return (
+ <PageWidthWrapper className="pb-12 pt-4">
+ <div className="border-border-subtle overflow-hidden rounded-xl border bg-neutral-100">
+ <Suspense>
+ <PartnersNavTabs />
+ <div className="border-border-subtle -mx-px -mb-px space-y-4 rounded-xl border bg-white p-4">
+ {children}
+ </div>
+ </Suspense>
+ </div>
+ </PageWidthWrapper>
+ );
+}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/network-partner-application-sheet.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/network-partner-application-sheet.tsx
new file mode 100644
index 0000000000..b5cd5c1c3c
--- /dev/null
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/network-partner-application-sheet.tsx
@@ -0,0 +1,548 @@
+"use client";
+
+import { AdminNetworkPartner } from "@/lib/types";
+import { useConfirmModal } from "@/ui/modals/confirm-modal";
+import { PartnerAbout } from "@/ui/partners/partner-about";
+import { PartnerAvatar } from "@/ui/partners/partner-avatar";
+import { PartnerInfoCards } from "@/ui/partners/partner-info-cards";
+import { PartnerStatusBadges } from "@/ui/partners/partner-status-badges";
+import { CountryFlag } from "@/ui/shared/country-flag";
+import { X } from "@/ui/shared/icons";
+import { ProgramEnrollmentStatus } from "@dub/prisma/client";
+import {
+ Button,
+ ChevronLeft,
+ ChevronRight,
+ ScrollContainer,
+ Sheet,
+ StatusBadge,
+ Trophy,
+ useKeyboardShortcut,
+ User,
+ Users,
+} from "@dub/ui";
+import { cn, COUNTRIES, currencyFormatter, OG_AVATAR_URL } from "@dub/utils";
+import { LayoutGroup, motion } from "motion/react";
+import Link from "next/link";
+import { useId, useState } from "react";
+import { NetworkPartnerChangeHistory } from "./network-partner-change-history";
+
+type NetworkPartnerSheetTabId = "about" | "programs" | "duplicates";
+
+export function NetworkPartnerApplicationSheet({
+ isOpen,
+ setIsOpen,
+ partner,
+ onPrevious,
+ onNext,
+ onReview,
+}: {
+ isOpen: boolean;
+ setIsOpen: (open: boolean) => void;
+ partner: AdminNetworkPartner;
+ onPrevious?: () => void;
+ onNext?: () => void;
+ onReview: (
+ partner: AdminNetworkPartner,
+ status: "approved" | "rejected",
+ ) => Promise<void>;
+}) {
+ const [currentTabId, setCurrentTabId] =
+ useState<NetworkPartnerSheetTabId>("about");
+
+ const PartnerDetails = (
+ <div className="rounded-lg border border-neutral-200 bg-neutral-100 p-3">
+ <div className="flex items-center gap-4">
+ <PartnerAvatar partner={partner} className="size-10 bg-white" />
+ <div className="flex min-w-0 flex-col">
+ <h4 className="truncate text-sm font-medium text-neutral-900">
+ {partner.name}
+ </h4>
+ <p className="truncate text-xs text-neutral-500">{partner.email}</p>
+ </div>
+ </div>
+ </div>
+ );
+
+ const {
+ setShowConfirmModal: setShowApproveConfirm,
+ confirmModal: approveModal,
+ } = useConfirmModal({
+ title: "Approve network application",
+ description: PartnerDetails,
+ confirmText: "Approve",
+ onConfirm: async () => {
+ await onReview(partner, "approved");
+ },
+ confirmShortcut: "a",
+ confirmShortcutOptions: { sheet: true, modal: true },
+ });
+
+ const {
+ setShowConfirmModal: setShowRejectConfirm,
+ confirmModal: rejectModal,
+ } = useConfirmModal({
+ title: "Reject network application",
+ description: PartnerDetails,
+ confirmText: "Reject",
+ confirmVariant: "danger",
+ onConfirm: async () => {
+ await onReview(partner, "rejected");
+ },
+ confirmShortcut: "r",
+ confirmShortcutOptions: { sheet: true, modal: true },
+ });
+
+ useKeyboardShortcut(
+ "ArrowRight",
+ () => {
+ if (onNext) {
+ onNext();
+ }
+ },
+ { sheet: true },
+ );
+
+ useKeyboardShortcut(
+ "ArrowLeft",
+ () => {
+ if (onPrevious) {
+ onPrevious();
+ }
+ },
+ { sheet: true },
+ );
+
+ useKeyboardShortcut("a", () => setShowApproveConfirm(true), {
+ sheet: true,
+ enabled: !["rejected", "trusted"].includes(partner.networkStatus),
+ });
+
+ useKeyboardShortcut("r", () => setShowRejectConfirm(true), {
+ sheet: true,
+ enabled: !["approved", "trusted"].includes(partner.networkStatus),
+ });
+
+ return (
+ <Sheet
+ open={isOpen}
+ onOpenChange={setIsOpen}
+ contentProps={{
+ className: "md:w-[max(min(calc(100vw-334px),1170px),540px)]",
+ }}
+ >
+ {approveModal}
+ {rejectModal}
+
+ <div className="flex size-full flex-col">
+ <div className="flex h-16 shrink-0 items-center justify-between border-b border-neutral-200 px-6 py-4">
+ <Sheet.Title className="text-lg font-semibold">
+ Network application
+ </Sheet.Title>
+ <div className="flex items-center gap-4">
+ <div className="flex items-center">
+ <Button
+ type="button"
+ disabled={!onPrevious}
+ onClick={onPrevious}
+ variant="secondary"
+ className="size-9 rounded-l-lg rounded-r-none p-0"
+ icon={<ChevronLeft className="size-3.5" />}
+ />
+ <Button
+ type="button"
+ disabled={!onNext}
+ onClick={onNext}
+ variant="secondary"
+ className="-ml-px size-9 rounded-l-none rounded-r-lg p-0"
+ icon={<ChevronRight className="size-3.5" />}
+ />
+ </div>
+ <Sheet.Close asChild>
+ <Button
+ variant="outline"
+ icon={<X className="size-5" />}
+ className="h-auto w-fit p-1"
+ />
+ </Sheet.Close>
+ </div>
+ </div>
+
+ <div className="@3xl/sheet:grid-cols-[minmax(440px,1fr)_minmax(0,360px)] scrollbar-hide grid min-h-0 grow grid-cols-1 gap-x-6 gap-y-4 overflow-y-auto p-4 sm:p-6">
+ <div className="@3xl/sheet:order-2 @3xl/sheet:sticky @3xl/sheet:top-0 @3xl/sheet:self-start space-y-4">
+ <PartnerInfoCards
+ type="admin"
+ partner={partner}
+ showApplicationRiskAnalysis
+ />
+ <ScrollContainer className="@3xl/sheet:max-h-[50dvh] @3xl/sheet:pr-1">
+ <NetworkPartnerChangeHistory
+ changeHistoryLog={partner.changeHistoryLog}
+ />
+ </ScrollContainer>
+ </div>
+ <div className="@3xl/sheet:order-1">
+ <div className="border-border-subtle overflow-hidden rounded-xl border bg-neutral-100">
+ <NetworkPartnerSheetTabs
+ currentTabId={currentTabId}
+ setCurrentTabId={setCurrentTabId}
+ programsCount={partner.programs.length}
+ duplicatesCount={partner.duplicatePartnerAccounts.length}
+ />
+ <div className="border-border-subtle -mx-px -mb-px rounded-xl border bg-white p-4">
+ {currentTabId === "about" && (
+ <div className="grid grid-cols-1 gap-5 text-sm text-neutral-600">
+ <PartnerAbout partner={partner} />
+ </div>
+ )}
+ {currentTabId === "programs" && (
+ <ScrollContainer className="@3xl/sheet:max-h-[72dvh]">
+ <NetworkPartnerProgramPerformance partner={partner} />
+ </ScrollContainer>
+ )}
+ {currentTabId === "duplicates" &&
+ partner.duplicatePartnerAccounts.length > 0 && (
+ <ScrollContainer className="@3xl/sheet:max-h-[72dvh]">
+ <NetworkPartnerDuplicateAccounts
+ duplicatePartnerAccounts={
+ partner.duplicatePartnerAccounts
+ }
+ />
+ </ScrollContainer>
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div className="shrink-0 border-t border-neutral-200 p-5">
+ <div className="flex justify-end gap-2">
+ <Button
+ type="button"
+ variant="secondary"
+ text="Reject"
+ className="w-fit shrink-0"
+ shortcut="R"
+ onClick={() => setShowRejectConfirm(true)}
+ disabledTooltip={
+ ["rejected", "trusted"].includes(partner.networkStatus)
+ ? `Cannot reject a ${partner.networkStatus} partner.`
+ : undefined
+ }
+ />
+ <Button
+ type="button"
+ variant="primary"
+ text="Approve"
+ className="w-fit shrink-0"
+ shortcut="A"
+ onClick={() => setShowApproveConfirm(true)}
+ disabledTooltip={
+ ["approved", "trusted"].includes(partner.networkStatus)
+ ? `Cannot approve a ${partner.networkStatus} partner.`
+ : undefined
+ }
+ />
+ </div>
+ </div>
+ </div>
+ </Sheet>
+ );
+}
+
+function NetworkPartnerSheetTabs({
+ currentTabId,
+ setCurrentTabId,
+ programsCount,
+ duplicatesCount,
+}: {
+ currentTabId: NetworkPartnerSheetTabId;
+ setCurrentTabId: (tabId: NetworkPartnerSheetTabId) => void;
+ programsCount: number;
+ duplicatesCount: number;
+}) {
+ const layoutGroupId = useId();
+
+ const tabs: {
+ id: NetworkPartnerSheetTabId;
+ label: string;
+ icon: typeof User;
+ badge?: string | number;
+ badgeClassName?: string;
+ }[] = [
+ {
+ id: "about",
+ label: "About",
+ icon: User,
+ },
+ {
+ id: "programs",
+ label: "Programs",
+ icon: Trophy,
+ badge: programsCount > 99 ? "99+" : programsCount,
+ },
+ ...(duplicatesCount > 0
+ ? [
+ {
+ id: "duplicates" as const,
+ label: "Duplicates",
+ icon: Users,
+ badge: duplicatesCount > 99 ? "99+" : duplicatesCount,
+ badgeClassName: "bg-red-600 text-white",
+ },
+ ]
+ : []),
+ ];
+
+ return (
+ <div className="scrollbar-hide relative z-0 flex items-center gap-1 overflow-x-auto p-2">
+ <LayoutGroup id={layoutGroupId}>
+ <div className="relative z-0 inline-flex items-center gap-1">
+ {tabs.map(({ id, label, icon: Icon, badge, badgeClassName }) => {
+ const isSelected = id === currentTabId;
+ return (
+ <button
+ key={id}
+ type="button"
+ onClick={() => setCurrentTabId(id)}
+ data-selected={isSelected}
+ className={cn(
+ "text-content-emphasis relative z-10 flex items-center gap-2 px-2.5 py-1 text-sm font-medium",
+ !isSelected &&
+ "hover:text-content-subtle z-[11] transition-colors",
+ )}
+ >
+ <Icon className="size-4" />
+ <span>{label}</span>
+ {badge && (
+ <span
+ className={cn(
+ "rounded-md bg-blue-600 px-2 py-0.5 text-xs font-semibold text-white",
+ badgeClassName,
+ )}
+ >
+ {badge}
+ </span>
+ )}
+ {isSelected && (
+ <motion.div
+ layoutId={layoutGroupId}
+ className="border-border-subtle bg-bg-default absolute left-0 top-0 -z-[1] size-full rounded-lg border shadow-sm"
+ transition={{ duration: 0.25 }}
+ />
+ )}
+ </button>
+ );
+ })}
+ </div>
+ </LayoutGroup>
+ </div>
+ );
+}
+
+function NetworkPartnerDuplicateAccounts({
+ duplicatePartnerAccounts,
+}: {
+ duplicatePartnerAccounts: AdminNetworkPartner["duplicatePartnerAccounts"];
+}) {
+ return (
+ <div>
+ <h3 className="text-content-emphasis text-sm font-semibold">
+ Duplicate partner accounts
+ </h3>
+ <p className="mt-1 text-sm text-neutral-500">
+ These accounts likely match this applicant by email or profile details.
+ </p>
+
+ <div className="mt-4 space-y-3">
+ {duplicatePartnerAccounts.map((account) => (
+ <Link
+ key={account.id}
+ href={`/partners/network?partnerId=${account.id}&search=${encodeURIComponent(account.email ?? "")}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="group block rounded-lg border border-red-100 bg-red-50/40 p-3 transition-colors hover:border-red-200 hover:bg-red-50"
+ >
+ <div className="grid grid-cols-1 gap-3 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center">
+ <div className="flex min-w-0 items-center gap-3">
+ <PartnerAvatar partner={account} className="size-9 bg-white" />
+ <div className="min-w-0">
+ <p className="truncate text-sm font-medium text-neutral-900 group-hover:underline">
+ {account.name}
+ </p>
+ <p className="truncate text-xs text-neutral-600">
+ {account.email || "No email"}
+ </p>
+ </div>
+ </div>
+ <div className="flex w-fit items-center gap-1.5 rounded-md border border-red-200 bg-white px-2.5 py-1">
+ {account.country && (
+ <CountryFlag
+ countryCode={account.country}
+ className="size-3.5"
+ />
+ )}
+ <p className="truncate text-sm font-medium text-neutral-900 group-hover:underline">
+ {account.country ? COUNTRIES[account.country] : "Unknown"}
+ </p>
+ </div>
+ </div>
+ </Link>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+function NetworkPartnerProgramPerformance({
+ partner,
+}: {
+ partner: AdminNetworkPartner;
+}) {
+ const [selectedStatus, setSelectedStatus] = useState<
+ ProgramEnrollmentStatus | "all"
+ >("all");
+
+ const statusOrder = [
+ "approved",
+ "invited",
+ "pending",
+ "rejected",
+ "deactivated",
+ "banned",
+ ] as const;
+
+ const statusCounts = partner.programs.reduce(
+ (counts, program) => {
+ counts[program.status] = (counts[program.status] ?? 0) + 1;
+ return counts;
+ },
+ {} as Partial<Record<ProgramEnrollmentStatus, number>>,
+ );
+
+ const statusSummary = statusOrder
+ .map((status) => ({
+ status,
+ count: statusCounts[status] ?? 0,
+ }))
+ .filter(({ count }) => count > 0);
+
+ const filteredPrograms =
+ selectedStatus === "all"
+ ? partner.programs
+ : partner.programs.filter((program) => program.status === selectedStatus);
+
+ return (
+ <div>
+ <div
+ className={cn(
+ "flex justify-between",
+ statusSummary.length > 3
+ ? "flex-col items-start"
+ : "flex-row items-center",
+ )}
+ >
+ <h3 className="text-content-emphasis text-sm font-semibold">
+ Program performance
+ </h3>
+ {statusSummary.length > 0 && (
+ <div className="mt-3 flex flex-wrap gap-2">
+ <button
+ type="button"
+ className={cn(
+ "rounded-md transition-opacity",
+ selectedStatus === "all"
+ ? "opacity-100"
+ : "opacity-60 hover:opacity-100",
+ )}
+ onClick={() => setSelectedStatus("all")}
+ >
+ <StatusBadge variant="neutral">
+ All ({partner.programs.length})
+ </StatusBadge>
+ </button>
+ {statusSummary.map(({ status, count }) => (
+ <button
+ key={status}
+ type="button"
+ className={cn(
+ "rounded-md transition-opacity",
+ selectedStatus === status
+ ? "opacity-100"
+ : "opacity-60 hover:opacity-100",
+ )}
+ onClick={() =>
+ setSelectedStatus((current) =>
+ current === status ? "all" : status,
+ )
+ }
+ >
+ <StatusBadge {...PartnerStatusBadges[status]}>
+ {PartnerStatusBadges[status].label} ({count})
+ </StatusBadge>
+ </button>
+ ))}
+ </div>
+ )}
+ </div>
+ {partner.programs.length === 0 ? (
+ <p className="mt-3 text-sm text-neutral-500">
+ This partner is not enrolled in any programs yet.
+ </p>
+ ) : (
+ <div
+ className={cn(
+ "space-y-3",
+ statusSummary.length > 0 ? "mt-4" : "mt-3",
+ )}
+ >
+ {filteredPrograms.map((program) => (
+ <div
+ key={`${partner.id}-${program.id}`}
+ className="rounded-lg border border-neutral-200 p-3"
+ >
+ <div className="flex items-center justify-between gap-3">
+ <Link
+ href={program.url || "#"}
+ target="_blank"
+ className="group flex min-w-0 items-center gap-2"
+ >
+ <img
+ src={program.logo || `${OG_AVATAR_URL}${program.name}`}
+ alt={program.name}
+ className="size-5 rounded-full"
+ />
+ <span className="truncate text-sm font-medium text-neutral-900 group-hover:underline">
+ {program.name}
+ </span>
+ </Link>
+ <StatusBadge {...PartnerStatusBadges[program.status]}>
+ {PartnerStatusBadges[program.status].label}
+ </StatusBadge>
+ </div>
+ <div className="mt-3 grid grid-cols-2 gap-2 text-xs text-neutral-500">
+ <div>
+ <p className="text-neutral-400">Total revenue</p>
+ <p className="mt-0.5 text-sm font-medium text-neutral-900">
+ {currencyFormatter(program.totalSaleAmount)}
+ </p>
+ </div>
+ <div>
+ <p className="text-neutral-400">Total commissions</p>
+ <p className="mt-0.5 text-sm font-medium text-neutral-900">
+ {currencyFormatter(program.totalCommissions)}
+ </p>
+ </div>
+ </div>
+ </div>
+ ))}
+ {filteredPrograms.length === 0 && (
+ <p className="text-sm text-neutral-500">
+ No programs match this status.
+ </p>
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/network-partner-change-history-item.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/network-partner-change-history-item.tsx
new file mode 100644
index 0000000000..4c744ee039
--- /dev/null
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/network-partner-change-history-item.tsx
@@ -0,0 +1,86 @@
+"use client";
+
+import { AdminNetworkPartner } from "@/lib/types";
+import { NetworkStatusBadges } from "@/ui/partners/partner-network/network-status-badges";
+import { CountryFlag } from "@/ui/shared/country-flag";
+import { StatusBadge, TimestampTooltip } from "@dub/ui";
+import { capitalize, COUNTRIES, formatDate } from "@dub/utils";
+
+type PartnerChangeLogEntry = NonNullable<AdminNetworkPartner["changeHistoryLog"]>[number];
+
+const FIELD_LABELS: Record<PartnerChangeLogEntry["field"], string> = {
+ country: "Country",
+ profileType: "Profile type",
+ networkStatus: "Network status",
+};
+
+export function NetworkPartnerChangeHistoryItem({
+ entry,
+}: {
+ entry: PartnerChangeLogEntry;
+}) {
+ return (
+ <li className="rounded-lg border border-neutral-200 bg-white p-3">
+ <div className="flex items-center justify-between gap-2">
+ <p className="text-xs font-medium uppercase tracking-wide text-neutral-500">
+ {FIELD_LABELS[entry.field]}
+ </p>
+ <TimestampTooltip
+ timestamp={entry.changedAt}
+ side="left"
+ rows={["local", "utc", "unix"]}
+ >
+ <time className="text-xs text-neutral-500">
+ {formatDate(entry.changedAt, {
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ hour: "numeric",
+ minute: "2-digit",
+ })}
+ </time>
+ </TimestampTooltip>
+ </div>
+
+ <div className="mt-2 flex flex-wrap items-center gap-2 text-sm">
+ {renderChangeValue(entry.field, entry.from)}
+ <span className="text-neutral-400">→</span>
+ {renderChangeValue(entry.field, entry.to)}
+ </div>
+ </li>
+ );
+}
+
+function renderChangeValue(
+ field: PartnerChangeLogEntry["field"],
+ value: PartnerChangeLogEntry["from"] | PartnerChangeLogEntry["to"],
+) {
+ if (field === "networkStatus" && value) {
+ const { label, icon, variant } = NetworkStatusBadges[value];
+ return (
+ <StatusBadge variant={variant} icon={icon}>
+ {label}
+ </StatusBadge>
+ );
+ }
+
+ if (field === "country" && value) {
+ return (
+ <span className="inline-flex items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-xs font-medium text-neutral-700">
+ <CountryFlag countryCode={value} className="size-3.5" />
+ {COUNTRIES[value] || value}
+ </span>
+ );
+ }
+
+ const label =
+ value === null
+ ? "Not set"
+ : capitalize(value);
+
+ return (
+ <span className="inline-flex items-center rounded-md border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-xs font-medium text-neutral-700">
+ {label}
+ </span>
+ );
+}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/network-partner-change-history.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/network-partner-change-history.tsx
new file mode 100644
index 0000000000..158a49121e
--- /dev/null
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/network-partner-change-history.tsx
@@ -0,0 +1,40 @@
+"use client";
+
+import { AdminNetworkPartner } from "@/lib/types";
+import { History } from "@dub/ui/icons";
+import { NetworkPartnerChangeHistoryItem } from "./network-partner-change-history-item";
+
+export function NetworkPartnerChangeHistory({
+ changeHistoryLog,
+}: {
+ changeHistoryLog: AdminNetworkPartner["changeHistoryLog"];
+}) {
+ const entries = (changeHistoryLog ?? []).toSorted(
+ (a, b) =>
+ new Date(b.changedAt).getTime() - new Date(a.changedAt).getTime(),
+ );
+
+ return (
+ <section className="rounded-xl border border-neutral-200 bg-neutral-100 p-4">
+ <div className="flex items-center gap-2">
+ <History className="size-4 text-neutral-500" />
+ <h3 className="text-sm font-semibold text-neutral-900">Change history</h3>
+ </div>
+
+ {entries.length === 0 ? (
+ <p className="mt-3 text-sm text-neutral-500">
+ No changes have been recorded yet.
+ </p>
+ ) : (
+ <ul className="mt-3 space-y-2">
+ {entries.map((entry, index) => (
+ <NetworkPartnerChangeHistoryItem
+ key={`${entry.field}-${new Date(entry.changedAt).toISOString()}-${index}`}
+ entry={entry}
+ />
+ ))}
+ </ul>
+ )}
+ </section>
+ );
+}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/page.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/page.tsx
new file mode 100644
index 0000000000..6931815b38
--- /dev/null
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/network/page.tsx
@@ -0,0 +1,457 @@
+"use client";
+
+import { buildSocialPlatformLookup } from "@/lib/social-utils";
+import { AdminNetworkPartner } from "@/lib/types";
+import { NetworkStatusBadges } from "@/ui/partners/partner-network/network-status-badges";
+import { PartnerRowItem } from "@/ui/partners/partner-row-item";
+import { PartnerSocialColumn } from "@/ui/partners/partner-social-column";
+import { CountryFlag } from "@/ui/shared/country-flag";
+import { SearchBoxPersisted } from "@/ui/shared/search-box";
+import { PartnerNetworkStatus, PlatformType } from "@dub/prisma/client";
+import {
+ Filter,
+ StatusBadge,
+ Table,
+ TimestampTooltip,
+ usePagination,
+ useRouterStuff,
+ useTable,
+} from "@dub/ui";
+import { CircleDotted, FlagWavy } from "@dub/ui/icons";
+import { cn, COUNTRIES, fetcher, formatDate } from "@dub/utils";
+import { Row } from "@tanstack/react-table";
+import { NetworkPartnerApplicationSheet } from "app/(ee)/admin.dub.co/(dashboard)/partners/network/network-partner-application-sheet";
+import { useEffect, useMemo, useState } from "react";
+import { toast } from "sonner";
+import useSWR from "swr";
+
+const SOCIAL_FIELDS = [
+ { id: "website", label: "Website" },
+ { id: "youtube", label: "YouTube" },
+ { id: "twitter", label: "X / Twitter" },
+ { id: "linkedin", label: "LinkedIn" },
+ { id: "instagram", label: "Instagram" },
+ { id: "tiktok", label: "TikTok" },
+] as const;
+
+export default function NetworkApplicationsPage() {
+ const { queryParams, searchParams, searchParamsObj, getQueryString } =
+ useRouterStuff();
+
+ const [detailsSheetState, setDetailsSheetState] = useState<
+ { open: false; partnerId: null } | { open: true; partnerId: string }
+ >({ open: false, partnerId: null });
+
+ const {
+ data: partners = [],
+ isLoading,
+ mutate,
+ } = useSWR<AdminNetworkPartner[]>(
+ `/api/admin/partners/network${getQueryString(undefined, {
+ exclude: ["partnerId"],
+ })}`,
+ fetcher,
+ {
+ keepPreviousData: true,
+ },
+ );
+
+ const { data: partnersCount } = useSWR<{
+ count: number;
+ }>(
+ `/api/admin/partners/network/count${getQueryString(undefined, {
+ exclude: ["partnerId"],
+ })}`,
+ fetcher,
+ {
+ keepPreviousData: true,
+ },
+ );
+
+ const statusFilterOptions = useMemo(
+ () =>
+ Object.values(PartnerNetworkStatus).map((status) => {
+ {
+ const { label, icon: Icon, className } = NetworkStatusBadges[status];
+ return {
+ value: status,
+ label,
+ icon: <Icon className={cn(className, "size-4 bg-transparent")} />,
+ };
+ }
+ }),
+ [partners],
+ );
+ const filters = useMemo(
+ () => [
+ {
+ key: "networkStatus",
+ icon: CircleDotted,
+ label: "Status",
+ singleSelect: true,
+ options: statusFilterOptions,
+ },
+ {
+ key: "country",
+ icon: FlagWavy,
+ label: "Country",
+ singleSelect: true,
+ getOptionIcon: (value: string) => <CountryFlag countryCode={value} />,
+ options: Object.entries(COUNTRIES).map(([key, value]) => ({
+ value: key,
+ label: value,
+ })),
+ },
+ ],
+ [statusFilterOptions],
+ );
+ const activeFilters = useMemo(() => {
+ const active = [] as { key: string; value: string }[];
+
+ if (searchParamsObj.networkStatus) {
+ active.push({
+ key: "networkStatus",
+ value: searchParamsObj.networkStatus,
+ });
+ }
+
+ if (searchParamsObj.country) {
+ active.push({
+ key: "country",
+ value: searchParamsObj.country,
+ });
+ }
+
+ return active;
+ }, [searchParamsObj.country, searchParamsObj.networkStatus]);
+
+ const platformsMapByPartnerId = useMemo(() => {
+ const map = new Map<
+ string,
+ Record<
+ PlatformType,
+ NonNullable<AdminNetworkPartner["platforms"]>[number] | null
+ >
+ >();
+
+ partners.forEach((partner) => {
+ map.set(partner.id, buildSocialPlatformLookup(partner.platforms ?? []));
+ });
+
+ return map;
+ }, [partners]);
+
+ useEffect(() => {
+ const partnerId = searchParams.get("partnerId");
+ if (partnerId) {
+ setDetailsSheetState({ open: true, partnerId });
+ return;
+ }
+
+ setDetailsSheetState({ open: false, partnerId: null });
+ }, [searchParams]);
+
+ const currentPartner = useMemo(() => {
+ if (!detailsSheetState.partnerId) {
+ return null;
+ }
+
+ return (
+ partners.find(({ id }) => id === detailsSheetState.partnerId) ?? null
+ );
+ }, [detailsSheetState.partnerId, partners]);
+
+ const [previousPartnerId, nextPartnerId] = useMemo(() => {
+ if (!detailsSheetState.partnerId) {
+ return [null, null] as const;
+ }
+
+ const currentIndex = partners.findIndex(
+ ({ id }) => id === detailsSheetState.partnerId,
+ );
+
+ if (currentIndex === -1) {
+ return [null, null] as const;
+ }
+
+ return [
+ currentIndex > 0 ? partners[currentIndex - 1]?.id ?? null : null,
+ currentIndex < partners.length - 1
+ ? partners[currentIndex + 1]?.id ?? null
+ : null,
+ ] as const;
+ }, [detailsSheetState.partnerId, partners]);
+
+ const onSelectFilter = (key: string, value: unknown) => {
+ queryParams({
+ set: {
+ [key]: String(value),
+ },
+ del: "page",
+ });
+ };
+
+ const onRemoveFilter = (key: string) => {
+ queryParams({
+ del: [key, "page"],
+ });
+ };
+
+ const onRemoveAllFilters = () => {
+ queryParams({
+ del: ["networkStatus", "country", "page"],
+ });
+ };
+
+ const handleReviewPartner = async (
+ partner: AdminNetworkPartner,
+ status: "approved" | "rejected",
+ ) => {
+ const currentIndex = partners.findIndex(({ id }) => id === partner.id);
+ const fallbackPartnerId =
+ (currentIndex !== -1 && partners[currentIndex + 1]?.id) ||
+ (currentIndex !== -1 && partners[currentIndex - 1]?.id) ||
+ null;
+
+ try {
+ const response = await fetch(
+ `/api/admin/partners/${partner.id}/network-status`,
+ {
+ method: "PATCH",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ status }),
+ },
+ );
+
+ if (!response.ok) {
+ throw new Error((await response.text()) || "Failed to review partner.");
+ }
+
+ toast.success(
+ status === "approved"
+ ? "Partner approved for the network."
+ : "Partner rejected from the network.",
+ );
+
+ await mutate();
+
+ if (fallbackPartnerId) {
+ queryParams({
+ set: {
+ partnerId: fallbackPartnerId,
+ },
+ scroll: false,
+ });
+ } else {
+ setDetailsSheetState({ open: false, partnerId: null });
+ queryParams({ del: "partnerId", scroll: false });
+ }
+ } catch (error) {
+ toast.error(
+ error instanceof Error ? error.message : "Failed to review partner.",
+ );
+ }
+ };
+
+ const columns = useMemo(
+ () => [
+ {
+ id: "partner",
+ header: "Partner",
+ minSize: 250,
+ cell: ({ row }: { row: Row<AdminNetworkPartner> }) => (
+ <PartnerRowItem
+ partner={toEnrolledPartnerPreview(row.original)}
+ showPermalink={false}
+ showFraudIndicator={true}
+ />
+ ),
+ },
+ {
+ id: "createdAt",
+ header: "Joined",
+ cell: ({ row }: { row: Row<AdminNetworkPartner> }) => (
+ <TimestampTooltip
+ timestamp={row.original.createdAt}
+ rows={["local", "utc", "unix"]}
+ side="right"
+ delayDuration={150}
+ >
+ <span>
+ {formatDate(row.original.createdAt, { month: "short" })}
+ </span>
+ </TimestampTooltip>
+ ),
+ },
+ {
+ id: "networkStatus",
+ header: "Status",
+ minSize: 140,
+ cell: ({ row }: { row: Row<AdminNetworkPartner> }) => {
+ const networkStatusBadge =
+ NetworkStatusBadges[row.original.networkStatus];
+ const { label, icon } = networkStatusBadge;
+ return (
+ <StatusBadge variant={networkStatusBadge.variant} icon={icon}>
+ {label}
+ </StatusBadge>
+ );
+ },
+ },
+ {
+ id: "location",
+ header: "Location",
+ minSize: 150,
+ cell: ({ row }: { row: Row<AdminNetworkPartner> }) => {
+ 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>
+ );
+ },
+ },
+ ...SOCIAL_FIELDS.map(({ id, label }) => ({
+ id,
+ header: label,
+ minSize: 150,
+ cell: ({ row }: { row: Row<AdminNetworkPartner> }) => {
+ const platformsMap = platformsMapByPartnerId.get(row.original.id);
+ return (
+ <PartnerSocialColumn
+ platform={platformsMap?.[id] ?? null}
+ platformName={id}
+ />
+ );
+ },
+ })),
+ ],
+ [platformsMapByPartnerId],
+ );
+
+ const sortBy = searchParams.get("sortBy") || "createdAt";
+ const sortOrder = searchParams.get("sortOrder") === "asc" ? "asc" : "desc";
+ const { pagination, setPagination } = usePagination();
+
+ const { table, ...tableProps } = useTable<AdminNetworkPartner>({
+ data: partners,
+ columns,
+ onRowClick: (row) =>
+ queryParams({
+ set: {
+ partnerId: row.original.id,
+ },
+ scroll: false,
+ }),
+ loading: isLoading,
+ sortableColumns: ["createdAt"],
+ sortBy,
+ sortOrder,
+ onSortChange: ({ sortBy, sortOrder }) =>
+ queryParams({
+ set: {
+ ...(sortBy && { sortBy }),
+ ...(sortOrder && { sortOrder }),
+ },
+ del: "page",
+ scroll: false,
+ }),
+
+ pagination,
+ onPaginationChange: setPagination,
+ thClassName: "border-l-0",
+ tdClassName: "border-l-0",
+ resourceName: (plural) => `partner${plural ? "s" : ""}`,
+ rowCount: partnersCount?.count ?? 0,
+ });
+
+ return (
+ <>
+ {currentPartner && (
+ <NetworkPartnerApplicationSheet
+ isOpen={detailsSheetState.open}
+ partner={currentPartner}
+ onPrevious={
+ previousPartnerId
+ ? () =>
+ queryParams({
+ set: {
+ partnerId: previousPartnerId,
+ },
+ scroll: false,
+ })
+ : undefined
+ }
+ onNext={
+ nextPartnerId
+ ? () =>
+ queryParams({
+ set: {
+ partnerId: nextPartnerId,
+ },
+ scroll: false,
+ })
+ : undefined
+ }
+ setIsOpen={(open) => {
+ if (!open) {
+ setDetailsSheetState({ open: false, partnerId: null });
+ queryParams({ del: "partnerId", scroll: false });
+ } else if (detailsSheetState.partnerId) {
+ setDetailsSheetState({
+ open: true,
+ partnerId: detailsSheetState.partnerId,
+ });
+ }
+ }}
+ onReview={handleReviewPartner}
+ />
+ )}
+ <div className="mb-4 flex flex-col gap-3">
+ <div className="flex w-full flex-col gap-2 min-[550px]:flex-row min-[550px]:items-center min-[550px]:justify-between">
+ <Filter.Select
+ className="w-full md:w-fit"
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelectFilter}
+ onRemove={onRemoveFilter}
+ />
+ <SearchBoxPersisted
+ placeholder="Search by partner email"
+ inputClassName="w-full md:w-80"
+ />
+ </div>
+ {activeFilters.length > 0 && (
+ <Filter.List
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelectFilter}
+ onRemove={onRemoveFilter}
+ onRemoveAll={onRemoveAllFilters}
+ />
+ )}
+ </div>
+ <Table
+ {...tableProps}
+ table={table}
+ containerClassName="max-h-[calc(70dvh)] overflow-auto"
+ />
+ </>
+ );
+}
+
+function toEnrolledPartnerPreview(partner: AdminNetworkPartner) {
+ return {
+ id: partner.id,
+ name: partner.name,
+ email: partner.email,
+ image: partner.image,
+ country: partner.country,
+ status: "pending",
+ } as const;
+}
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
index 3efee6f616..b1a242f8c6 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/page.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/page.tsx
@@ -1,611 +1,5 @@
-"use client";
+import { redirect } from "next/navigation";
-import { PARTNER_PLATFORM_FIELDS } from "@/lib/partners/partner-platforms";
-import { useConfirmModal } from "@/ui/modals/confirm-modal";
-import { PartnerAvatar } from "@/ui/partners/partner-avatar";
-import { PlatformType } from "@dub/prisma/client";
-import { Button, CopyText, Sheet, TimestampTooltip, Tooltip } from "@dub/ui";
-import {
- BadgeCheck2Fill,
- Instagram,
- LinkedIn,
- TikTok,
- Twitter,
- Xmark,
- YouTube,
-} from "@dub/ui/icons";
-import { cn, fetcher, formatDateSmart } from "@dub/utils";
-import Link from "next/link";
-import { FormEvent, useCallback, useEffect, 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;
- description?: string | null;
- platforms: Array<{
- type: PlatformType;
- identifier: string;
- verifiedAt: Date | string | null;
- subscribers: number;
- posts: number;
- views: number;
- }>;
-};
-
-const PLATFORM_ORDER: PlatformType[] = [
- "youtube",
- "twitter",
- "linkedin",
- "instagram",
- "tiktok",
- "website",
-];
-
-const PLATFORM_LABELS: Record<PlatformType, string> = {
- website: "Website",
- youtube: "YouTube",
- twitter: "X / Twitter",
- linkedin: "LinkedIn",
- instagram: "Instagram",
- tiktok: "TikTok",
-};
-
-const PLATFORM_PLACEHOLDERS: Record<PlatformType, string> = {
- website: "https://example.com",
- youtube: "@creator or channel URL",
- twitter: "@handle or profile URL",
- linkedin: "profile slug or URL",
- instagram: "@handle or profile URL",
- tiktok: "@handle or profile URL",
-};
-
-const formatInt = (value: number) =>
- new Intl.NumberFormat("en-US").format(value);
-
-function PlatformIcon({ platform }: { platform: PlatformType }) {
- const className = "size-4";
- if (platform === "youtube") return <YouTube className={className} />;
- if (platform === "twitter") return <Twitter className={className} />;
- if (platform === "linkedin") return <LinkedIn className={className} />;
- if (platform === "instagram") return <Instagram className={className} />;
- if (platform === "tiktok") return <TikTok className={className} />;
- return <span className="text-xs text-neutral-500">WEB</span>;
-}
-
-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 PartnersPage() {
- const [partnerIdOrEmail, setPartnerIdOrEmail] = useState("");
- const [isSubmitting, setIsSubmitting] = useState(false);
- const [partnerToRemove, setPartnerToRemove] = useState<TrustedPartner | null>(
- null,
- );
- const [activePartner, setActivePartner] = useState<TrustedPartner | null>(
- null,
- );
- const [sheetOpen, setSheetOpen] = useState(false);
- const [draftHandles, setDraftHandles] = useState<
- Partial<Record<PlatformType, string>>
- >({});
- const [linkedInPostUrls, setLinkedInPostUrls] = useState<
- Partial<Record<PlatformType, string>>
- >({});
- const [verifyingPlatforms, setVerifyingPlatforms] = useState<
- Partial<Record<PlatformType, boolean>>
- >({});
-
- const { data, isLoading, mutate } = useSWR<{ partners: TrustedPartner[] }>(
- "/api/admin/partners",
- fetcher,
- { keepPreviousData: true },
- );
-
- const trustedPartners = data?.partners ?? [];
- const platformByType = useMemo(
- () =>
- Object.fromEntries(
- (activePartner?.platforms ?? []).map((platform) => [
- platform.type,
- platform,
- ]),
- ) as Partial<Record<PlatformType, TrustedPartner["platforms"][number]>>,
- [activePartner?.platforms],
- );
-
- useEffect(() => {
- if (!activePartner) return;
- const nextDraftHandles: Partial<Record<PlatformType, string>> = {};
- for (const platform of PLATFORM_ORDER) {
- nextDraftHandles[platform] = platformByType[platform]?.identifier ?? "";
- }
- setDraftHandles(nextDraftHandles);
- setLinkedInPostUrls({});
- }, [activePartner, platformByType]);
-
- 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);
- });
- };
-
- const verifyPlatform = async (platform: PlatformType) => {
- if (!activePartner) return;
- const identifier = draftHandles[platform]?.trim();
- if (!identifier) {
- toast.error(`Please enter a ${PLATFORM_LABELS[platform]} identifier.`);
- return;
- }
-
- setVerifyingPlatforms((prev) => ({ ...prev, [platform]: true }));
-
- const payload: {
- partnerId: string;
- platform: PlatformType;
- identifier: string;
- postUrl?: string;
- } = {
- partnerId: activePartner.id,
- platform,
- identifier,
- };
-
- const linkedInPostUrl = linkedInPostUrls.linkedin?.trim();
- if (platform === "linkedin" && linkedInPostUrl) {
- payload.postUrl = linkedInPostUrl;
- }
-
- await fetch("/api/admin/partners/platforms", {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify(payload),
- })
- .then(async (res) => {
- if (!res.ok) {
- throw new Error(await res.text());
- }
- const refreshed = await mutate();
- const updatedActivePartner = refreshed?.partners?.find(
- (p) => p.id === activePartner.id,
- );
- if (updatedActivePartner) {
- setActivePartner(updatedActivePartner);
- }
- toast.success(`${PLATFORM_LABELS[platform]} verified manually.`);
- })
- .catch((error) => {
- toast.error(error.message || "Failed to verify platform.");
- })
- .finally(() => {
- setVerifyingPlatforms((prev) => ({ ...prev, [platform]: 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
- role="button"
- tabIndex={0}
- className="flex cursor-pointer items-start gap-3 px-4 py-3.5 transition-colors hover:bg-neutral-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300 sm:px-5 md:items-center"
- onClick={() => {
- setActivePartner(partner);
- setSheetOpen(true);
- }}
- onKeyDown={(e) => {
- if (e.key === "Enter" || e.key === " ") {
- e.preventDefault();
- setActivePartner(partner);
- setSheetOpen(true);
- }
- }}
- >
- <PartnerAvatar
- partner={{
- id: partner.id,
- name: partner.name,
- image: partner.image,
- }}
- 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>
- <div className="mt-1 flex flex-col gap-1 lg:flex-row lg:items-center lg:gap-3">
- {partner.email ? (
- <CopyText
- value={partner.email}
- className="w-fit truncate text-sm text-neutral-500"
- >
- {partner.email}
- </CopyText>
- ) : (
- <span />
- )}
- <div className="flex flex-wrap items-center gap-1.5 lg:justify-end">
- {(() => {
- const platforms = partner.platforms.map((p) => ({
- ...p,
- platformId: null,
- avatarUrl: null,
- subscribers: BigInt(p.subscribers),
- posts: BigInt(p.posts),
- views: BigInt(p.views),
- verifiedAt: p.verifiedAt
- ? new Date(p.verifiedAt)
- : null,
- }));
- return PARTNER_PLATFORM_FIELDS.map(
- ({ label, icon: Icon, data: getPlatformData }) => {
- const { value, href, verified } =
- getPlatformData(platforms);
- if (!value) return null;
- return (
- <Tooltip
- key={label}
- content={
- <Link
- href={href ?? "#"}
- target="_blank"
- rel="noopener noreferrer"
- className="flex items-center gap-1 px-2 py-1 text-xs font-medium text-neutral-700 hover:text-neutral-900"
- onClick={(e) => e.stopPropagation()}
- >
- <Icon className="size-3 shrink-0" />
- <span>{value}</span>
- {verified && (
- <BadgeCheck2Fill className="size-3 text-green-600" />
- )}
- </Link>
- }
- >
- <Link
- href={href ?? "#"}
- target="_blank"
- rel="noopener noreferrer"
- className="border-border-subtle hover:bg-bg-muted relative flex size-6 shrink-0 items-center justify-center rounded-full border"
- onClick={(e) => e.stopPropagation()}
- >
- <Icon className="size-3" />
- <span className="sr-only">{label}</span>
- {verified && (
- <BadgeCheck2Fill className="absolute -right-1 -top-1 size-3 text-green-600" />
- )}
- </Link>
- </Tooltip>
- );
- },
- );
- })()}
- </div>
- </div>
- <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={(e) => {
- e.stopPropagation();
- openRemoveModal(partner);
- }}
- >
- <Xmark className="size-4" />
- </button>
- </div>
- </div>
- </li>
- ))}
- </ul>
- )}
- </div>
- <Sheet
- open={sheetOpen}
- onOpenChange={(open) => {
- setSheetOpen(open);
- if (!open) setActivePartner(null);
- }}
- >
- <div className="flex h-full flex-col">
- <div className="flex h-16 items-center justify-between border-b border-neutral-200 px-6 py-4">
- <Sheet.Title className="text-lg font-semibold">
- Partner profile and platforms
- </Sheet.Title>
- <Sheet.Close asChild>
- <Button
- type="button"
- variant="outline"
- icon={<Xmark className="size-5" />}
- className="h-auto w-fit p-1"
- />
- </Sheet.Close>
- </div>
-
- <div className="grid min-h-0 flex-1 gap-4 overflow-y-auto p-6">
- {!activePartner ? null : (
- <>
- <div className="rounded-xl border border-neutral-200 bg-white p-4">
- <div className="flex items-start gap-3">
- <img
- src={activePartner.image || ""}
- alt={activePartner.name}
- className="size-12 shrink-0 rounded-full border border-neutral-100 bg-neutral-100 object-cover"
- />
- <div className="min-w-0">
- <p className="truncate text-sm font-semibold text-neutral-900">
- {activePartner.name}
- </p>
- <p className="truncate text-sm text-neutral-600">
- {activePartner.email ?? "No email"}
- </p>
- {activePartner.description ? (
- <p className="mt-1 line-clamp-3 text-sm text-neutral-500">
- {activePartner.description}
- </p>
- ) : null}
- </div>
- </div>
- </div>
-
- <div className="space-y-3">
- {PLATFORM_ORDER.map((platform) => {
- const existing = platformByType[platform];
- const isVerifying = Boolean(verifyingPlatforms[platform]);
- return (
- <div
- key={platform}
- className="rounded-xl border border-neutral-200 bg-white p-4"
- >
- <div className="mb-3 flex items-center justify-between gap-3">
- <div className="flex items-center gap-2">
- <PlatformIcon platform={platform} />
- <p className="text-sm font-medium text-neutral-900">
- {PLATFORM_LABELS[platform]}
- </p>
- </div>
- <div
- className={cn(
- "rounded-full px-2 py-0.5 text-xs font-medium",
- existing?.verifiedAt
- ? "bg-emerald-100 text-emerald-700"
- : "bg-neutral-100 text-neutral-600",
- )}
- >
- {existing?.verifiedAt ? "Verified" : "Not verified"}
- </div>
- </div>
-
- <div className="grid gap-2 sm:grid-cols-[1fr_auto]">
- <input
- type="text"
- value={draftHandles[platform] ?? ""}
- onChange={(e) =>
- setDraftHandles((prev) => ({
- ...prev,
- [platform]: e.target.value,
- }))
- }
- placeholder={PLATFORM_PLACEHOLDERS[platform]}
- className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"
- />
- <Button
- type="button"
- text="Verify"
- className="w-fit"
- loading={isVerifying}
- onClick={() => verifyPlatform(platform)}
- />
- </div>
-
- {platform === "linkedin" ? (
- <input
- type="text"
- value={linkedInPostUrls.linkedin ?? ""}
- onChange={(e) =>
- setLinkedInPostUrls((prev) => ({
- ...prev,
- linkedin: e.target.value,
- }))
- }
- placeholder="Optional: LinkedIn post URL (for follower metadata)"
- className="mt-2 w-full rounded-md border border-neutral-300 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"
- />
- ) : null}
-
- <div className="mt-3 flex flex-wrap gap-3 text-xs text-neutral-500">
- <span>
- Subscribers: {formatInt(existing?.subscribers ?? 0)}
- </span>
- <span>Posts: {formatInt(existing?.posts ?? 0)}</span>
- <span>Views: {formatInt(existing?.views ?? 0)}</span>
- {existing?.verifiedAt ? (
- <span>
- Verified {formatDateSmart(existing.verifiedAt)}
- </span>
- ) : null}
- </div>
- </div>
- );
- })}
- </div>
- </>
- )}
- </div>
- </div>
- </Sheet>
- </div>
- );
+export default function AdminPartnersPage() {
+ redirect("/partners/network?networkStatus=submitted");
}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/partners-nav-tabs.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/partners-nav-tabs.tsx
new file mode 100644
index 0000000000..2a067fcb62
--- /dev/null
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/partners-nav-tabs.tsx
@@ -0,0 +1,31 @@
+"use client";
+
+import { PageNavTabs } from "@/ui/layout/page-nav-tabs";
+import { AlertCircleFill } from "@/ui/shared/icons";
+import { GridIcon, UserCheck } from "@dub/ui";
+import { useMemo } from "react";
+
+export function PartnersNavTabs() {
+ const tabs = useMemo(
+ () => [
+ {
+ id: "network",
+ label: "Network Partners",
+ icon: GridIcon,
+ },
+ {
+ id: "trusted",
+ label: "Trusted Partners",
+ icon: UserCheck,
+ },
+ {
+ id: "fraud",
+ label: "Fraud Alerts",
+ icon: AlertCircleFill,
+ },
+ ],
+ [],
+ );
+
+ return <PageNavTabs basePath="/partners" tabs={tabs} />;
+}
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/trusted/page.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/trusted/page.tsx
new file mode 100644
index 0000000000..cbf6c8fcf5
--- /dev/null
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/partners/trusted/page.tsx
@@ -0,0 +1,611 @@
+"use client";
+
+import { PARTNER_PLATFORM_FIELDS } from "@/lib/partners/partner-platforms";
+import { useConfirmModal } from "@/ui/modals/confirm-modal";
+import { PartnerAvatar } from "@/ui/partners/partner-avatar";
+import { PlatformType } from "@dub/prisma/client";
+import { Button, CopyText, Sheet, TimestampTooltip, Tooltip } from "@dub/ui";
+import {
+ BadgeCheck2Fill,
+ Instagram,
+ LinkedIn,
+ TikTok,
+ Twitter,
+ Xmark,
+ YouTube,
+} from "@dub/ui/icons";
+import { cn, fetcher, formatDateSmart } from "@dub/utils";
+import Link from "next/link";
+import { FormEvent, useCallback, useEffect, 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;
+ description?: string | null;
+ platforms: Array<{
+ type: PlatformType;
+ identifier: string;
+ verifiedAt: Date | string | null;
+ subscribers: number;
+ posts: number;
+ views: number;
+ }>;
+};
+
+const PLATFORM_ORDER: PlatformType[] = [
+ "youtube",
+ "twitter",
+ "linkedin",
+ "instagram",
+ "tiktok",
+ "website",
+];
+
+const PLATFORM_LABELS: Record<PlatformType, string> = {
+ website: "Website",
+ youtube: "YouTube",
+ twitter: "X / Twitter",
+ linkedin: "LinkedIn",
+ instagram: "Instagram",
+ tiktok: "TikTok",
+};
+
+const PLATFORM_PLACEHOLDERS: Record<PlatformType, string> = {
+ website: "https://example.com",
+ youtube: "@creator or channel URL",
+ twitter: "@handle or profile URL",
+ linkedin: "profile slug or URL",
+ instagram: "@handle or profile URL",
+ tiktok: "@handle or profile URL",
+};
+
+const formatInt = (value: number) =>
+ new Intl.NumberFormat("en-US").format(value);
+
+function PlatformIcon({ platform }: { platform: PlatformType }) {
+ const className = "size-4";
+ if (platform === "youtube") return <YouTube className={className} />;
+ if (platform === "twitter") return <Twitter className={className} />;
+ if (platform === "linkedin") return <LinkedIn className={className} />;
+ if (platform === "instagram") return <Instagram className={className} />;
+ if (platform === "tiktok") return <TikTok className={className} />;
+ return <span className="text-xs text-neutral-500">WEB</span>;
+}
+
+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 PartnersPage() {
+ const [partnerIdOrEmail, setPartnerIdOrEmail] = useState("");
+ const [isSubmitting, setIsSubmitting] = useState(false);
+ const [partnerToRemove, setPartnerToRemove] = useState<TrustedPartner | null>(
+ null,
+ );
+ const [activePartner, setActivePartner] = useState<TrustedPartner | null>(
+ null,
+ );
+ const [sheetOpen, setSheetOpen] = useState(false);
+ const [draftHandles, setDraftHandles] = useState<
+ Partial<Record<PlatformType, string>>
+ >({});
+ const [linkedInPostUrls, setLinkedInPostUrls] = useState<
+ Partial<Record<PlatformType, string>>
+ >({});
+ const [verifyingPlatforms, setVerifyingPlatforms] = useState<
+ Partial<Record<PlatformType, boolean>>
+ >({});
+
+ const { data, isLoading, mutate } = useSWR<{ partners: TrustedPartner[] }>(
+ "/api/admin/partners/trusted",
+ fetcher,
+ { keepPreviousData: true },
+ );
+
+ const trustedPartners = data?.partners ?? [];
+ const platformByType = useMemo(
+ () =>
+ Object.fromEntries(
+ (activePartner?.platforms ?? []).map((platform) => [
+ platform.type,
+ platform,
+ ]),
+ ) as Partial<Record<PlatformType, TrustedPartner["platforms"][number]>>,
+ [activePartner?.platforms],
+ );
+
+ useEffect(() => {
+ if (!activePartner) return;
+ const nextDraftHandles: Partial<Record<PlatformType, string>> = {};
+ for (const platform of PLATFORM_ORDER) {
+ nextDraftHandles[platform] = platformByType[platform]?.identifier ?? "";
+ }
+ setDraftHandles(nextDraftHandles);
+ setLinkedInPostUrls({});
+ }, [activePartner, platformByType]);
+
+ 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/trusted", {
+ 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/trusted", {
+ 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);
+ });
+ };
+
+ const verifyPlatform = async (platform: PlatformType) => {
+ if (!activePartner) return;
+ const identifier = draftHandles[platform]?.trim();
+ if (!identifier) {
+ toast.error(`Please enter a ${PLATFORM_LABELS[platform]} identifier.`);
+ return;
+ }
+
+ setVerifyingPlatforms((prev) => ({ ...prev, [platform]: true }));
+
+ const payload: {
+ partnerId: string;
+ platform: PlatformType;
+ identifier: string;
+ postUrl?: string;
+ } = {
+ partnerId: activePartner.id,
+ platform,
+ identifier,
+ };
+
+ const linkedInPostUrl = linkedInPostUrls.linkedin?.trim();
+ if (platform === "linkedin" && linkedInPostUrl) {
+ payload.postUrl = linkedInPostUrl;
+ }
+
+ await fetch(`/api/admin/partners/${activePartner.id}/platforms`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(payload),
+ })
+ .then(async (res) => {
+ if (!res.ok) {
+ throw new Error(await res.text());
+ }
+ const refreshed = await mutate();
+ const updatedActivePartner = refreshed?.partners?.find(
+ (p) => p.id === activePartner.id,
+ );
+ if (updatedActivePartner) {
+ setActivePartner(updatedActivePartner);
+ }
+ toast.success(`${PLATFORM_LABELS[platform]} verified manually.`);
+ })
+ .catch((error) => {
+ toast.error(error.message || "Failed to verify platform.");
+ })
+ .finally(() => {
+ setVerifyingPlatforms((prev) => ({ ...prev, [platform]: false }));
+ });
+ };
+
+ return (
+ <>
+ {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
+ role="button"
+ tabIndex={0}
+ className="flex cursor-pointer items-start gap-3 px-4 py-3.5 transition-colors hover:bg-neutral-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300 sm:px-5 md:items-center"
+ onClick={() => {
+ setActivePartner(partner);
+ setSheetOpen(true);
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" || e.key === " ") {
+ e.preventDefault();
+ setActivePartner(partner);
+ setSheetOpen(true);
+ }
+ }}
+ >
+ <PartnerAvatar
+ partner={{
+ id: partner.id,
+ name: partner.name,
+ image: partner.image,
+ }}
+ 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>
+ <div className="mt-1 flex flex-col gap-1 lg:flex-row lg:items-center lg:gap-3">
+ {partner.email ? (
+ <CopyText
+ value={partner.email}
+ className="w-fit truncate text-sm text-neutral-500"
+ >
+ {partner.email}
+ </CopyText>
+ ) : (
+ <span />
+ )}
+ <div className="flex flex-wrap items-center gap-1.5 lg:justify-end">
+ {(() => {
+ const platforms = partner.platforms.map((p) => ({
+ ...p,
+ platformId: null,
+ avatarUrl: null,
+ subscribers: BigInt(p.subscribers),
+ posts: BigInt(p.posts),
+ views: BigInt(p.views),
+ verifiedAt: p.verifiedAt
+ ? new Date(p.verifiedAt)
+ : null,
+ }));
+ return PARTNER_PLATFORM_FIELDS.map(
+ ({ label, icon: Icon, data: getPlatformData }) => {
+ const { value, href, verified } =
+ getPlatformData(platforms);
+ if (!value) return null;
+ return (
+ <Tooltip
+ key={label}
+ content={
+ <Link
+ href={href ?? "#"}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="flex items-center gap-1 px-2 py-1 text-xs font-medium text-neutral-700 hover:text-neutral-900"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <Icon className="size-3 shrink-0" />
+ <span>{value}</span>
+ {verified && (
+ <BadgeCheck2Fill className="size-3 text-green-600" />
+ )}
+ </Link>
+ }
+ >
+ <Link
+ href={href ?? "#"}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="border-border-subtle hover:bg-bg-muted relative flex size-6 shrink-0 items-center justify-center rounded-full border"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <Icon className="size-3" />
+ <span className="sr-only">{label}</span>
+ {verified && (
+ <BadgeCheck2Fill className="absolute -right-1 -top-1 size-3 text-green-600" />
+ )}
+ </Link>
+ </Tooltip>
+ );
+ },
+ );
+ })()}
+ </div>
+ </div>
+ <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={(e) => {
+ e.stopPropagation();
+ openRemoveModal(partner);
+ }}
+ >
+ <Xmark className="size-4" />
+ </button>
+ </div>
+ </div>
+ </li>
+ ))}
+ </ul>
+ )}
+ </div>
+ <Sheet
+ open={sheetOpen}
+ onOpenChange={(open) => {
+ setSheetOpen(open);
+ if (!open) setActivePartner(null);
+ }}
+ >
+ <div className="flex h-full flex-col">
+ <div className="flex h-16 items-center justify-between border-b border-neutral-200 px-6 py-4">
+ <Sheet.Title className="text-lg font-semibold">
+ Partner profile and platforms
+ </Sheet.Title>
+ <Sheet.Close asChild>
+ <Button
+ type="button"
+ variant="outline"
+ icon={<Xmark className="size-5" />}
+ className="h-auto w-fit p-1"
+ />
+ </Sheet.Close>
+ </div>
+
+ <div className="grid min-h-0 flex-1 gap-4 overflow-y-auto p-6">
+ {!activePartner ? null : (
+ <>
+ <div className="rounded-xl border border-neutral-200 bg-white p-4">
+ <div className="flex items-start gap-3">
+ <img
+ src={activePartner.image || ""}
+ alt={activePartner.name}
+ className="size-12 shrink-0 rounded-full border border-neutral-100 bg-neutral-100 object-cover"
+ />
+ <div className="min-w-0">
+ <p className="truncate text-sm font-semibold text-neutral-900">
+ {activePartner.name}
+ </p>
+ <p className="truncate text-sm text-neutral-600">
+ {activePartner.email ?? "No email"}
+ </p>
+ {activePartner.description ? (
+ <p className="mt-1 line-clamp-3 text-sm text-neutral-500">
+ {activePartner.description}
+ </p>
+ ) : null}
+ </div>
+ </div>
+ </div>
+
+ <div className="space-y-3">
+ {PLATFORM_ORDER.map((platform) => {
+ const existing = platformByType[platform];
+ const isVerifying = Boolean(verifyingPlatforms[platform]);
+ return (
+ <div
+ key={platform}
+ className="rounded-xl border border-neutral-200 bg-white p-4"
+ >
+ <div className="mb-3 flex items-center justify-between gap-3">
+ <div className="flex items-center gap-2">
+ <PlatformIcon platform={platform} />
+ <p className="text-sm font-medium text-neutral-900">
+ {PLATFORM_LABELS[platform]}
+ </p>
+ </div>
+ <div
+ className={cn(
+ "rounded-full px-2 py-0.5 text-xs font-medium",
+ existing?.verifiedAt
+ ? "bg-emerald-100 text-emerald-700"
+ : "bg-neutral-100 text-neutral-600",
+ )}
+ >
+ {existing?.verifiedAt ? "Verified" : "Not verified"}
+ </div>
+ </div>
+
+ <div className="grid gap-2 sm:grid-cols-[1fr_auto]">
+ <input
+ type="text"
+ value={draftHandles[platform] ?? ""}
+ onChange={(e) =>
+ setDraftHandles((prev) => ({
+ ...prev,
+ [platform]: e.target.value,
+ }))
+ }
+ placeholder={PLATFORM_PLACEHOLDERS[platform]}
+ className="w-full rounded-md border border-neutral-300 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"
+ />
+ <Button
+ type="button"
+ text="Verify"
+ className="w-fit"
+ loading={isVerifying}
+ onClick={() => verifyPlatform(platform)}
+ />
+ </div>
+
+ {platform === "linkedin" ? (
+ <input
+ type="text"
+ value={linkedInPostUrls.linkedin ?? ""}
+ onChange={(e) =>
+ setLinkedInPostUrls((prev) => ({
+ ...prev,
+ linkedin: e.target.value,
+ }))
+ }
+ placeholder="Optional: LinkedIn post URL (for follower metadata)"
+ className="mt-2 w-full rounded-md border border-neutral-300 px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500"
+ />
+ ) : null}
+
+ <div className="mt-3 flex flex-wrap gap-3 text-xs text-neutral-500">
+ <span>
+ Subscribers: {formatInt(existing?.subscribers ?? 0)}
+ </span>
+ <span>Posts: {formatInt(existing?.posts ?? 0)}</span>
+ <span>Views: {formatInt(existing?.views ?? 0)}</span>
+ {existing?.verifiedAt ? (
+ <span>
+ Verified {formatDateSmart(existing.verifiedAt)}
+ </span>
+ ) : null}
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ </>
+ )}
+ </div>
+ </div>
+ </Sheet>
+ </>
+ );
+}
diff --git a/apps/web/app/(ee)/api/admin/fraud-alerts/route.ts b/apps/web/app/(ee)/api/admin/fraud-alerts/route.ts
index d17391b0e0..dd4aa2ab26 100644
--- a/apps/web/app/(ee)/api/admin/fraud-alerts/route.ts
+++ b/apps/web/app/(ee)/api/admin/fraud-alerts/route.ts
@@ -1,78 +1 @@
-import { withAdmin } from "@/lib/auth";
-import { fraudAlertSchema } from "@/lib/zod/schemas/fraud";
-import { prisma } from "@dub/prisma";
-import { FraudAlertStatus } from "@dub/prisma/client";
-import { NextResponse } from "next/server";
-import * as z from "zod/v4";
-
-const PAGE_SIZE = 50;
-
-const querySchema = z.object({
- status: z.enum(FraudAlertStatus).optional(),
- programId: z.string().optional(),
- page: z.coerce.number().int().positive().optional().default(1),
-});
-
-// GET /api/admin/fraud-alerts
-export const GET = withAdmin(async ({ searchParams }) => {
- const { status, programId, page } = querySchema.parse(searchParams);
-
- const where = {
- ...(status && { status }),
- ...(programId && { programId }),
- };
-
- const skip = (page - 1) * PAGE_SIZE;
-
- const [fraudAlerts, total] = await Promise.all([
- prisma.fraudAlert.findMany({
- where,
- orderBy: [
- {
- status: "asc",
- },
- {
- createdAt: "desc",
- },
- ],
- skip,
- take: PAGE_SIZE,
- select: {
- id: true,
- partnerId: true,
- reason: true,
- status: true,
- reviewedAt: true,
- reviewNote: true,
- createdAt: true,
- partner: {
- select: {
- id: true,
- name: true,
- email: true,
- image: true,
- },
- },
- program: {
- select: {
- id: true,
- name: true,
- logo: true,
- },
- },
- reviewedBy: {
- select: {
- id: true,
- name: true,
- },
- },
- },
- }),
- prisma.fraudAlert.count({ where }),
- ]);
-
- return NextResponse.json({
- fraudAlerts: fraudAlertSchema.array().parse(fraudAlerts),
- total,
- });
-});
+export { GET } from "../partners/fraud/route";
diff --git a/apps/web/app/(ee)/api/admin/partners/[partnerId]/network-status/route.ts b/apps/web/app/(ee)/api/admin/partners/[partnerId]/network-status/route.ts
new file mode 100644
index 0000000000..900ce0a50c
--- /dev/null
+++ b/apps/web/app/(ee)/api/admin/partners/[partnerId]/network-status/route.ts
@@ -0,0 +1,109 @@
+import { withAdmin } from "@/lib/auth";
+import { partnerProfileChangeHistoryLogSchema } from "@/lib/zod/schemas/partner-profile";
+import { sendEmail } from "@dub/email";
+import NetworkPartnerApplicationApproved from "@dub/email/templates/network-partner-application-approved";
+import NetworkPartnerApplicationRejected from "@dub/email/templates/network-partner-application-rejected";
+import { prisma } from "@dub/prisma";
+import { waitUntil } from "@vercel/functions";
+import { NextResponse } from "next/server";
+import * as z from "zod/v4";
+
+const updateAdminNetworkStatusSchema = z.object({
+ status: z.enum(["approved", "rejected"]),
+});
+
+// PATCH /api/admin/partners/[partnerId]/network-status
+export const PATCH = withAdmin(
+ async ({ params, req }) => {
+ const { partnerId } = params;
+ const { status } = updateAdminNetworkStatusSchema.parse(await req.json());
+
+ const existingPartner = await prisma.partner.findUnique({
+ where: {
+ id: partnerId,
+ },
+ select: {
+ id: true,
+ name: true,
+ email: true,
+ networkStatus: true,
+ changeHistoryLog: true,
+ },
+ });
+
+ if (!existingPartner) {
+ return new Response("Partner not found.", { status: 404 });
+ }
+
+ if (existingPartner.networkStatus === status) {
+ return new Response("Partner is already in this status.", {
+ status: 400,
+ });
+ }
+
+ if (existingPartner.networkStatus === "trusted" && status === "approved") {
+ return new Response("Trusted partners cannot be approved.", {
+ status: 400,
+ });
+ }
+
+ const partnerChangeHistoryLog = existingPartner.changeHistoryLog
+ ? partnerProfileChangeHistoryLogSchema.parse(
+ existingPartner.changeHistoryLog,
+ )
+ : [];
+
+ partnerChangeHistoryLog.push({
+ field: "networkStatus",
+ from: existingPartner.networkStatus,
+ to: status,
+ changedAt: new Date(),
+ });
+
+ const updatedPartner = await prisma.partner.update({
+ where: {
+ id: partnerId,
+ },
+ data: {
+ networkStatus: status,
+ changeHistoryLog: partnerChangeHistoryLog,
+ reviewedAt: new Date(),
+ },
+ select: {
+ id: true,
+ networkStatus: true,
+ },
+ });
+
+ if (
+ existingPartner.email &&
+ (status === "approved" || status === "rejected")
+ ) {
+ waitUntil(
+ sendEmail({
+ to: existingPartner.email,
+ subject:
+ status === "approved"
+ ? "Your Dub Partner Network application was approved"
+ : "Dub Partner Network application update",
+ variant: "notifications",
+ react:
+ status === "approved"
+ ? NetworkPartnerApplicationApproved({
+ name: existingPartner.name,
+ email: existingPartner.email,
+ })
+ : NetworkPartnerApplicationRejected({
+ name: existingPartner.name,
+ email: existingPartner.email,
+ }),
+ }),
+ );
+ }
+
+ return NextResponse.json(updatedPartner);
+ },
+ {
+ requiredRoles: ["owner"],
+ },
+);
diff --git a/apps/web/app/(ee)/api/admin/partners/platforms/route.ts b/apps/web/app/(ee)/api/admin/partners/[partnerId]/platforms/route.ts
similarity index 93%
rename from apps/web/app/(ee)/api/admin/partners/platforms/route.ts
rename to apps/web/app/(ee)/api/admin/partners/[partnerId]/platforms/route.ts
index c3901376b3..64297854b1 100644
--- a/apps/web/app/(ee)/api/admin/partners/platforms/route.ts
+++ b/apps/web/app/(ee)/api/admin/partners/[partnerId]/platforms/route.ts
@@ -4,22 +4,21 @@ import { withAdmin } from "@/lib/auth";
import { sanitizeSocialHandle, sanitizeWebsite } from "@/lib/social-utils";
import { prisma } from "@dub/prisma";
import { PlatformType } from "@dub/prisma/client";
-import { revalidatePath } from "next/cache";
import { NextResponse } from "next/server";
import * as z from "zod/v4";
const postSchema = z.object({
- partnerId: z.string().trim().min(1),
platform: z.enum(PlatformType),
identifier: z.string().trim().min(1),
postUrl: z.string().trim().url().optional(),
});
-// POST /api/admin/partners/platforms
+// POST /api/admin/partners/[partnerId]/platforms
export const POST = withAdmin(
- async ({ req }) => {
+ async ({ req, params }) => {
+ const { partnerId } = params;
+
const {
- partnerId,
platform,
identifier: rawIdentifier,
postUrl,
@@ -128,9 +127,6 @@ export const POST = withAdmin(
},
});
- revalidatePath("/api/admin/partners");
- revalidatePath("/api/admin/partners/platforms");
-
return NextResponse.json({
platform: {
...updated,
diff --git a/apps/web/app/(ee)/api/admin/partners/[id]/route.ts b/apps/web/app/(ee)/api/admin/partners/[partnerId]/route.ts
similarity index 92%
rename from apps/web/app/(ee)/api/admin/partners/[id]/route.ts
rename to apps/web/app/(ee)/api/admin/partners/[partnerId]/route.ts
index 388347b3e6..a684386456 100644
--- a/apps/web/app/(ee)/api/admin/partners/[id]/route.ts
+++ b/apps/web/app/(ee)/api/admin/partners/[partnerId]/route.ts
@@ -2,13 +2,13 @@ import { withAdmin } from "@/lib/auth";
import { prisma } from "@dub/prisma";
import { NextResponse } from "next/server";
-// GET /api/admin/partners/[id]
+// GET /api/admin/partners/[partnerId]
export const GET = withAdmin(async ({ params }) => {
- const { id } = params;
+ const { partnerId } = params;
const partner = await prisma.partner.findUnique({
where: {
- id,
+ id: partnerId,
},
select: {
id: true,
@@ -29,7 +29,7 @@ export const GET = withAdmin(async ({ params }) => {
const [programEnrollments, fraudAlerts, payouts] = await Promise.all([
prisma.programEnrollment.findMany({
where: {
- partnerId: id,
+ partnerId,
status: "banned",
},
include: {
@@ -48,7 +48,7 @@ export const GET = withAdmin(async ({ params }) => {
prisma.fraudAlert.findMany({
where: {
- partnerId: id,
+ partnerId,
},
include: {
program: {
@@ -66,7 +66,7 @@ export const GET = withAdmin(async ({ params }) => {
prisma.payout.findMany({
where: {
- partnerId: id,
+ partnerId,
},
include: {
program: {
diff --git a/apps/web/app/(ee)/api/admin/partners/fraud/route.ts b/apps/web/app/(ee)/api/admin/partners/fraud/route.ts
new file mode 100644
index 0000000000..b8a5c17e5b
--- /dev/null
+++ b/apps/web/app/(ee)/api/admin/partners/fraud/route.ts
@@ -0,0 +1,78 @@
+import { withAdmin } from "@/lib/auth";
+import { adminFraudAlertSchema } from "@/lib/zod/schemas/admin";
+import { prisma } from "@dub/prisma";
+import { FraudAlertStatus } from "@dub/prisma/client";
+import { NextResponse } from "next/server";
+import * as z from "zod/v4";
+
+const PAGE_SIZE = 50;
+
+const querySchema = z.object({
+ status: z.enum(FraudAlertStatus).optional(),
+ programId: z.string().optional(),
+ page: z.coerce.number().int().positive().optional().default(1),
+});
+
+// GET /api/admin/partners/fraud
+export const GET = withAdmin(async ({ searchParams }) => {
+ const { status, programId, page } = querySchema.parse(searchParams);
+
+ const where = {
+ ...(status && { status }),
+ ...(programId && { programId }),
+ };
+
+ const skip = (page - 1) * PAGE_SIZE;
+
+ const [fraudAlerts, total] = await Promise.all([
+ prisma.fraudAlert.findMany({
+ where,
+ orderBy: [
+ {
+ status: "asc",
+ },
+ {
+ createdAt: "desc",
+ },
+ ],
+ skip,
+ take: PAGE_SIZE,
+ select: {
+ id: true,
+ partnerId: true,
+ reason: true,
+ status: true,
+ reviewedAt: true,
+ reviewNote: true,
+ createdAt: true,
+ partner: {
+ select: {
+ id: true,
+ name: true,
+ email: true,
+ image: true,
+ },
+ },
+ program: {
+ select: {
+ id: true,
+ name: true,
+ logo: true,
+ },
+ },
+ reviewedBy: {
+ select: {
+ id: true,
+ name: true,
+ },
+ },
+ },
+ }),
+ prisma.fraudAlert.count({ where }),
+ ]);
+
+ return NextResponse.json({
+ fraudAlerts: adminFraudAlertSchema.array().parse(fraudAlerts),
+ total,
+ });
+});
diff --git a/apps/web/app/(ee)/api/admin/partners/network/count/route.ts b/apps/web/app/(ee)/api/admin/partners/network/count/route.ts
new file mode 100644
index 0000000000..a5499e5095
--- /dev/null
+++ b/apps/web/app/(ee)/api/admin/partners/network/count/route.ts
@@ -0,0 +1,25 @@
+import { withAdmin } from "@/lib/auth";
+import { adminNetworkPartnerQuerySchema } from "@/lib/zod/schemas/admin";
+import { prisma } from "@dub/prisma";
+import { NextResponse } from "next/server";
+
+// GET /api/admin/partners/network
+export const GET = withAdmin(async ({ searchParams }) => {
+ const { networkStatus, country, search } = adminNetworkPartnerQuerySchema
+ .pick({ networkStatus: true, country: true, search: true })
+ .parse(searchParams);
+
+ const partnersCount = await prisma.partner.count({
+ where: {
+ ...(networkStatus && { networkStatus }),
+ ...(country && { country }),
+ ...(search && {
+ email: search,
+ }),
+ },
+ });
+
+ return NextResponse.json({
+ count: partnersCount,
+ });
+});
diff --git a/apps/web/app/(ee)/api/admin/partners/network/route.ts b/apps/web/app/(ee)/api/admin/partners/network/route.ts
new file mode 100644
index 0000000000..8fb68b08e4
--- /dev/null
+++ b/apps/web/app/(ee)/api/admin/partners/network/route.ts
@@ -0,0 +1,99 @@
+import { withAdmin } from "@/lib/auth";
+import {
+ adminNetworkPartnerQuerySchema,
+ adminNetworkPartnerSchema,
+} from "@/lib/zod/schemas/admin";
+import { prisma } from "@dub/prisma";
+import { NextResponse } from "next/server";
+
+// GET /api/admin/partners/network
+export const GET = withAdmin(async ({ searchParams }) => {
+ const { networkStatus, country, search, sortOrder, page, pageSize } =
+ adminNetworkPartnerQuerySchema.parse(searchParams);
+
+ const partners = await prisma.partner.findMany({
+ where: {
+ ...(networkStatus && { networkStatus }),
+ ...(country && { country }),
+ ...(search && {
+ email: search,
+ }),
+ },
+ include: {
+ platforms: true,
+ industryInterests: true,
+ preferredEarningStructures: true,
+ salesChannels: true,
+ programs: {
+ orderBy: {
+ totalCommissions: "desc",
+ },
+ include: {
+ program: true,
+ },
+ },
+ },
+ orderBy: { createdAt: sortOrder },
+ take: pageSize,
+ skip: ((page ?? 1) - 1) * pageSize,
+ });
+
+ const duplicatePartnerAccounts = await prisma.partner.findMany({
+ where: {
+ OR: [
+ {
+ payoutMethodHash: {
+ in: partners
+ .filter((partner) => partner.payoutMethodHash !== null)
+ .map((partner) => partner.payoutMethodHash!),
+ },
+ },
+ {
+ cryptoWalletAddress: {
+ in: partners
+ .filter((partner) => partner.cryptoWalletAddress !== null)
+ .map((partner) => partner.cryptoWalletAddress!),
+ },
+ },
+ ],
+ },
+ select: {
+ id: true,
+ name: true,
+ email: true,
+ image: true,
+ country: true,
+ payoutMethodHash: true,
+ cryptoWalletAddress: true,
+ },
+ });
+
+ return NextResponse.json(
+ adminNetworkPartnerSchema.array().parse(
+ partners.map((partner) => ({
+ ...partner,
+ industryInterests: partner.industryInterests.map(
+ (interest) => interest.industryInterest,
+ ),
+ preferredEarningStructures: partner.preferredEarningStructures.map(
+ (structure) => structure.preferredEarningStructure,
+ ),
+ salesChannels: partner.salesChannels.map(
+ (channel) => channel.salesChannel,
+ ),
+ programs: partner.programs.map((program) => ({
+ ...program,
+ ...program.program,
+ })),
+ duplicatePartnerAccounts: duplicatePartnerAccounts.filter(
+ (account) =>
+ account.id !== partner.id &&
+ ((partner.payoutMethodHash &&
+ partner.payoutMethodHash === account.payoutMethodHash) ||
+ (partner.cryptoWalletAddress &&
+ partner.cryptoWalletAddress === account.cryptoWalletAddress)),
+ ),
+ })),
+ ),
+ );
+});
diff --git a/apps/web/app/(ee)/api/admin/partners/route.ts b/apps/web/app/(ee)/api/admin/partners/trusted/route.ts
similarity index 68%
rename from apps/web/app/(ee)/api/admin/partners/route.ts
rename to apps/web/app/(ee)/api/admin/partners/trusted/route.ts
index bbd63a2e76..32d674acd3 100644
--- a/apps/web/app/(ee)/api/admin/partners/route.ts
+++ b/apps/web/app/(ee)/api/admin/partners/trusted/route.ts
@@ -1,9 +1,10 @@
import { withAdmin } from "@/lib/auth";
+import { partnerProfileChangeHistoryLogSchema } from "@/lib/zod/schemas/partner-profile";
import { prisma } from "@dub/prisma";
import { NextResponse } from "next/server";
import * as z from "zod/v4";
-// GET /api/admin/partners
+// GET /api/admin/partners/trusted
export const GET = withAdmin(async () => {
const partners = await prisma.partner.findMany({
where: {
@@ -47,7 +48,7 @@ export const GET = withAdmin(async () => {
});
});
-// POST /api/admin/partners
+// POST /api/admin/partners/trusted
export const POST = withAdmin(
async ({ req }) => {
const { partnerIdOrEmail } = z
@@ -69,7 +70,9 @@ export const POST = withAdmin(
: { email: partnerIdOrEmail },
select: {
id: true,
+ networkStatus: true,
trustedAt: true,
+ changeHistoryLog: true,
},
});
@@ -83,12 +86,26 @@ export const POST = withAdmin(
});
}
+ const partnerChangeHistoryLog = partner.changeHistoryLog
+ ? partnerProfileChangeHistoryLogSchema.parse(partner.changeHistoryLog)
+ : [];
+
+ const trustedAt = new Date();
+ partnerChangeHistoryLog.push({
+ field: "networkStatus",
+ from: partner.networkStatus,
+ to: "trusted",
+ changedAt: trustedAt,
+ });
+
const updatedPartner = await prisma.partner.update({
where: {
id: partner.id,
},
data: {
- trustedAt: new Date(),
+ networkStatus: "trusted",
+ trustedAt,
+ changeHistoryLog: partnerChangeHistoryLog,
},
select: {
id: true,
@@ -106,7 +123,7 @@ export const POST = withAdmin(
},
);
-// DELETE /api/admin/partners — clears trusted status (removes from trusted list)
+// DELETE /api/admin/partners/trusted
export const DELETE = withAdmin(
async ({ req }) => {
const { partnerId } = z
@@ -117,16 +134,36 @@ export const DELETE = withAdmin(
const partner = await prisma.partner.findUnique({
where: { id: partnerId },
- select: { id: true, trustedAt: true },
+ select: {
+ id: true,
+ networkStatus: true,
+ trustedAt: true,
+ changeHistoryLog: true,
+ },
});
if (!partner) {
return new Response("Partner not found.", { status: 404 });
}
+ const partnerChangeHistoryLog = partner.changeHistoryLog
+ ? partnerProfileChangeHistoryLogSchema.parse(partner.changeHistoryLog)
+ : [];
+
+ partnerChangeHistoryLog.push({
+ field: "networkStatus",
+ from: partner.networkStatus,
+ to: "approved",
+ changedAt: new Date(),
+ });
+
await prisma.partner.update({
where: { id: partner.id },
- data: { trustedAt: null },
+ data: {
+ networkStatus: "approved",
+ trustedAt: null,
+ changeHistoryLog: partnerChangeHistoryLog,
+ },
});
return NextResponse.json({ success: true });
diff --git a/apps/web/app/(ee)/api/cron/network/update-partner-discoverability/route.ts b/apps/web/app/(ee)/api/cron/network/update-partner-discoverability/route.ts
deleted file mode 100644
index 3461e40273..0000000000
--- a/apps/web/app/(ee)/api/cron/network/update-partner-discoverability/route.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-import { handleAndReturnErrorResponse } from "@/lib/api/errors";
-import { EXCLUDED_PROGRAM_IDS } from "@/lib/constants/partner-profile";
-import { verifyQstashSignature } from "@/lib/cron/verify-qstash";
-import { prisma } from "@dub/prisma";
-import { log, prettyPrint } from "@dub/utils";
-import { logAndRespond } from "../../utils";
-
-export const dynamic = "force-dynamic";
-
-// This route is used to update the discoverability of partners in the network
-// Runs once every hour (0 * * * *)
-// POST /api/cron/network/update-partner-discoverability
-export async function POST(req: Request) {
- try {
- const rawBody = await req.text();
-
- await verifyQstashSignature({
- req,
- rawBody,
- });
-
- const eligiblePartners = await prisma.partner.findMany({
- where: {
- programs: {
- some: {
- programId: {
- notIn: EXCLUDED_PROGRAM_IDS,
- },
- status: "approved",
- totalCommissions: {
- gte: 10_00,
- },
- },
- none: {
- status: "banned",
- },
- },
- },
- });
-
- const discoveredRes = await prisma.partner.updateMany({
- where: {
- discoverableAt: null,
- id: {
- in: eligiblePartners.map((partner) => partner.id),
- },
- },
- data: { discoverableAt: new Date() },
- });
- console.log(`Updated ${discoveredRes.count} partners to be discoverable`);
-
- const notDiscoveredRes = await prisma.partner.updateMany({
- where: {
- discoverableAt: {
- not: null,
- },
- id: {
- notIn: eligiblePartners.map((partner) => partner.id),
- },
- },
- data: { discoverableAt: null },
- });
-
- console.log(
- `Updated ${notDiscoveredRes.count} partners to be not discoverable`,
- );
-
- return logAndRespond(
- prettyPrint({
- discoverable: discoveredRes.count,
- notDiscoverable: notDiscoveredRes.count,
- }),
- );
- } catch (error) {
- await log({
- message: `/api/cron/network/update-partner-discoverability failed - ${error.message}`,
- type: "errors",
- });
-
- return handleAndReturnErrorResponse(error);
- }
-}
diff --git a/apps/web/app/(ee)/app.dub.co/embed/referrals/bounties/submission-detail.tsx b/apps/web/app/(ee)/app.dub.co/embed/referrals/bounties/submission-detail.tsx
index 7f03544c5f..c6fc08b91a 100644
--- a/apps/web/app/(ee)/app.dub.co/embed/referrals/bounties/submission-detail.tsx
+++ b/apps/web/app/(ee)/app.dub.co/embed/referrals/bounties/submission-detail.tsx
@@ -1,8 +1,8 @@
"use client";
+import { BountySubmissionStatusBadges } from "@/lib/bounty/bounty-submission-status-badges";
import { REJECT_BOUNTY_SUBMISSION_REASONS } from "@/lib/bounty/constants";
import { getPeriodLabel } from "@/lib/bounty/periods";
-import { BOUNTY_SUBMISSION_STATUS_BADGES } from "@/lib/bounty/submission-status";
import { resolveBountyDetails } from "@/lib/bounty/utils";
import { PartnerBountyProps, PartnerBountySubmission } from "@/lib/types";
import { BountySocialMetricsRewardsTable } from "@/ui/partners/bounties/bounty-social-metrics-rewards-table";
@@ -193,7 +193,7 @@ function SubmissionRightColumn({
submission: PartnerBountySubmission;
}) {
const bountyInfo = resolveBountyDetails(bounty);
- const statusBadge = BOUNTY_SUBMISSION_STATUS_BADGES[submission.status];
+ const statusBadge = BountySubmissionStatusBadges[submission.status];
const submittedDate = submission.completedAt ?? submission.createdAt;
const textValue = (text: string) => (
diff --git a/apps/web/app/(ee)/app.dub.co/embed/referrals/bounties/submissions-table.tsx b/apps/web/app/(ee)/app.dub.co/embed/referrals/bounties/submissions-table.tsx
index 52d19bfaa8..1f6ff5e0e5 100644
--- a/apps/web/app/(ee)/app.dub.co/embed/referrals/bounties/submissions-table.tsx
+++ b/apps/web/app/(ee)/app.dub.co/embed/referrals/bounties/submissions-table.tsx
@@ -1,10 +1,10 @@
"use client";
+import { BountySubmissionStatusBadges } from "@/lib/bounty/bounty-submission-status-badges";
import {
type SubmissionPeriod,
getSubmissionPeriods,
} from "@/lib/bounty/periods";
-import { BOUNTY_SUBMISSION_STATUS_BADGES } from "@/lib/bounty/submission-status";
import { PartnerBountyProps, PartnerBountySubmission } from "@/lib/types";
import { Button, StatusBadge, Table, useTable } from "@dub/ui";
import { ColumnDef } from "@tanstack/react-table";
@@ -46,7 +46,7 @@ export function EmbedBountySubmissionsTable({
original: SubmissionPeriod<PartnerBountySubmission>;
};
}) => {
- const config = BOUNTY_SUBMISSION_STATUS_BADGES[original.status];
+ const config = BountySubmissionStatusBadges[original.status];
const label =
original.status === "submitted"
? "Pending review"
@@ -78,7 +78,7 @@ export function EmbedBountySubmissionsTable({
minSize: 120,
size: 160,
cell: ({ row: { original } }) => {
- const config = BOUNTY_SUBMISSION_STATUS_BADGES[original.status];
+ const config = BountySubmissionStatusBadges[original.status];
if (!config) return null;
const label =
original.status === "submitted" ? "Pending review" : config.label;
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/network-approval-guide.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/network-approval-guide.tsx
new file mode 100644
index 0000000000..6ed63af370
--- /dev/null
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/network-approval-guide.tsx
@@ -0,0 +1,212 @@
+import { submitNetworkProfileAction } from "@/lib/actions/partners/submit-network-profile";
+import { getNetworkProfileChecklistProgress } from "@/lib/network/get-network-profile-checklist-progress";
+import usePartnerProfile from "@/lib/swr/use-partner-profile";
+import { useConfirmModal } from "@/ui/modals/confirm-modal";
+import {
+ Button,
+ CircleCheck,
+ CircleCheckFill,
+ CircleDotted,
+ CircleHalfDottedClock,
+ CircleXmark,
+ ExpandingArrow,
+ ProgressCircle,
+ StatusBadge,
+} from "@dub/ui";
+import { cn, isClickOnInteractiveChild } from "@dub/utils";
+import { motion } from "motion/react";
+import { useAction } from "next-safe-action/hooks";
+import Link from "next/link";
+import { HTMLProps, useState } from "react";
+import { toast } from "sonner";
+
+const NETWORK_STATUS_BADGE_VARIANT = {
+ submitted: {
+ variant: "pending",
+ label: "Pending approval",
+ icon: CircleHalfDottedClock,
+ },
+ rejected: {
+ variant: "error",
+ label: "Rejected",
+ icon: CircleXmark,
+ },
+ approved: {
+ variant: "success",
+ label: "Approved",
+ icon: CircleCheck,
+ },
+} as const;
+
+export function NetworkApprovalGuide() {
+ const { partner, mutate } = usePartnerProfile();
+
+ const { tasks, completedCount, totalCount, isComplete } =
+ getNetworkProfileChecklistProgress({
+ partner,
+ });
+
+ const [isExpanded, setIsExpanded] = useState(isComplete ? false : true);
+
+ const { executeAsync: submitNetworkProfile } = useAction(
+ submitNetworkProfileAction,
+ {
+ onSuccess: () => {
+ toast.success("Application submitted successfully");
+ },
+ onError: ({ error }) => {
+ toast.error(error.serverError);
+ },
+ },
+ );
+
+ const { setShowConfirmModal, confirmModal } = useConfirmModal({
+ title: "Submit application",
+ description:
+ "Are you sure you want to submit your Dub Network application for review? You won't be able to make changes to your application after submitting it.",
+ confirmText: "Confirm submission",
+ onConfirm: async () => {
+ await submitNetworkProfile();
+ await mutate();
+ },
+ });
+
+ if (!partner) return null;
+
+ return (
+ <>
+ {confirmModal}
+ <motion.div
+ initial={{ opacity: 0, height: 0 }}
+ animate={{ opacity: 1, height: "auto" }}
+ transition={{ duration: 0.2, ease: "easeOut" }}
+ className="overflow-hidden"
+ >
+ <div
+ className="text-content-inverted cursor-pointer rounded-2xl bg-neutral-900 p-2"
+ onClick={(e) => {
+ if (isClickOnInteractiveChild(e)) return;
+ setIsExpanded((e) => !e);
+ }}
+ >
+ <div className="flex flex-col items-center justify-between gap-3 px-3 py-2 md:flex-row">
+ <div>
+ <div className="flex flex-col-reverse gap-1.5 md:flex-row md:items-center">
+ <h2 className="text-lg font-semibold">
+ Join the Dub Partner Network
+ </h2>
+
+ {partner.networkStatus === "draft" || !isComplete ? (
+ <div className="bg-bg-default/10 flex w-fit items-center gap-1.5 rounded-md px-2 py-1">
+ <ProgressCircle
+ progress={completedCount / totalCount}
+ className="text-green-500 [--track-color:#fff3]"
+ />
+ <span className="text-xs font-medium">
+ {completedCount} of {totalCount} tasks completed
+ </span>
+ </div>
+ ) : (
+ (() => {
+ if (partner.networkStatus === "trusted") {
+ partner.networkStatus = "approved";
+ }
+ const {
+ variant,
+ label,
+ icon: Icon,
+ } = NETWORK_STATUS_BADGE_VARIANT[partner.networkStatus];
+ return (
+ <StatusBadge
+ className="dark"
+ icon={Icon}
+ variant={variant}
+ >
+ {label}
+ </StatusBadge>
+ );
+ })()
+ )}
+ </div>
+ <p className="text-content-inverted/60 text-sm">
+ Complete the steps to join the Dub Partner Network and start
+ applying to programs in our network.
+ </p>
+ </div>
+ {partner.networkStatus === "draft" && (
+ <Button
+ text="Submit application"
+ onClick={() => setShowConfirmModal(true)}
+ disabledTooltip={
+ !isComplete
+ ? "Complete all tasks to submit application"
+ : undefined
+ }
+ variant="secondary"
+ className="h-9 w-full md:w-fit"
+ />
+ )}
+ </div>
+
+ <motion.div
+ initial={false}
+ animate={{
+ height: isExpanded ? "auto" : 0,
+ opacity: isExpanded ? 1 : 0,
+ marginTop: isExpanded ? 8 : 0,
+ }}
+ transition={{ duration: 0.15, ease: "easeOut" }}
+ className="overflow-hidden"
+ >
+ <div
+ className="grid grid-cols-1 rounded-lg bg-neutral-800 p-2 sm:grid-cols-2"
+ onClick={(e) => e.stopPropagation()}
+ >
+ {tasks.map(({ label, completed, href }) => (
+ <ConditionalLink
+ key={label}
+ href={completed ? undefined : href}
+ className={cn(
+ "group flex items-center justify-between gap-2 rounded-md px-3 py-2",
+ !completed &&
+ href &&
+ "transition-colors duration-100 ease-out hover:bg-neutral-700",
+ )}
+ >
+ <div className="flex min-w-0 items-center gap-2">
+ {completed ? (
+ <CircleCheckFill className="size-4 shrink-0 text-green-500" />
+ ) : (
+ <CircleDotted className="size-4 shrink-0 text-neutral-400" />
+ )}
+ <span className="min-w-0 truncate text-sm">{label}</span>
+ </div>
+ {!completed && href && (
+ <div className="shrink-0 pr-4">
+ <ExpandingArrow className="group-hover:text-content-inverted text-neutral-500" />
+ </div>
+ )}
+ </ConditionalLink>
+ ))}
+ </div>
+ </motion.div>
+ </div>
+ </motion.div>
+ </>
+ );
+}
+
+function ConditionalLink({
+ href,
+ className,
+ children,
+ ...rest
+}: Partial<HTMLProps<HTMLAnchorElement>>) {
+ return href ? (
+ <Link href={href} className={className} {...rest}>
+ {children}
+ </Link>
+ ) : (
+ <div className={className}>{children}</div>
+ );
+}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
index c8533b8b34..b319358206 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
@@ -9,21 +9,14 @@ import { useMergePartnerAccountsModal } from "@/ui/partners/merge-accounts/merge
import { ThreeDots } from "@/ui/shared/icons";
import { Button, Popover, Users2 } from "@dub/ui";
import { cn } from "@dub/utils";
-import { Dispatch, SetStateAction, useMemo, useState } from "react";
+import { Dispatch, SetStateAction, useState } from "react";
import { AboutYouForm } from "./about-you-form";
import { HowYouWorkForm } from "./how-you-work-form";
+import { NetworkApprovalGuide } from "./network-approval-guide";
import { ProfileDetailsForm } from "./profile-details-form";
-import { ProfileDiscoveryGuide } from "./profile-discovery-guide";
-import { usePartnerDiscoveryRequirements } from "./use-partner-discovery-requirements";
export function ProfileSettingsPageClient() {
const { partner } = usePartnerProfile();
- const tasks = usePartnerDiscoveryRequirements();
-
- const allTasksCompleted = useMemo(
- () => tasks?.every(({ completed }) => completed) ?? false,
- [tasks],
- );
const { MergePartnerAccountsModal, setShowMergePartnerAccountsModal } =
useMergePartnerAccountsModal();
@@ -44,7 +37,7 @@ export function ProfileSettingsPageClient() {
>
<MergePartnerAccountsModal />
<PageWidthWrapper className="mb-20 flex flex-col gap-6">
- {partner && !allTasksCompleted && <ProfileDiscoveryGuide />}
+ {partner && <NetworkApprovalGuide />}
<ProfileDetailsForm
partner={partner}
setShowMergePartnerAccountsModal={setShowMergePartnerAccountsModal}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx
index cc33c1bff7..4946b35869 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx
@@ -258,7 +258,7 @@ function BasicInfoForm({
await executeAsync({
...data,
- username: data.username?.trim() ? data.username : null,
+ username: data.username || undefined,
image: imageChanged ? data.image : null,
});
})}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-discovery-guide.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-discovery-guide.tsx
deleted file mode 100644
index 4bcb319cb1..0000000000
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-discovery-guide.tsx
+++ /dev/null
@@ -1,132 +0,0 @@
-import {
- Button,
- ChevronUp,
- CircleCheckFill,
- CircleDotted,
- ExpandingArrow,
- ProgressCircle,
-} from "@dub/ui";
-import { cn, isClickOnInteractiveChild } from "@dub/utils";
-import { motion } from "motion/react";
-import Link from "next/link";
-import { HTMLProps, useState } from "react";
-import { usePartnerDiscoveryRequirements } from "./use-partner-discovery-requirements";
-
-export function ProfileDiscoveryGuide() {
- const [isExpanded, setIsExpanded] = useState(false);
-
- const tasks = usePartnerDiscoveryRequirements();
-
- if (!tasks) return null;
-
- const completedTasks = tasks.filter(({ completed }) => completed);
-
- return (
- <motion.div
- initial={{ opacity: 0, height: 0 }}
- animate={{ opacity: 1, height: "auto" }}
- transition={{ duration: 0.2, ease: "easeOut" }}
- className="overflow-hidden"
- >
- <div
- className="text-content-inverted rounded-2xl bg-neutral-900 p-2"
- onClick={(e) => {
- if (isClickOnInteractiveChild(e)) return;
- setIsExpanded((e) => !e);
- }}
- >
- <div className="flex select-none flex-col px-3 pb-4 pt-1">
- <div className="flex justify-between">
- <div className="bg-bg-default/10 mb-4 flex w-fit items-center gap-1.5 rounded-md px-2 py-1">
- <ProgressCircle
- progress={completedTasks.length / tasks.length}
- className="text-green-500 [--track-color:#fff3]"
- />
- <span className="text-xs font-medium">
- {completedTasks.length} of {tasks.length} tasks completed
- </span>
- </div>
- <Button
- type="button"
- onClick={() => setIsExpanded((e) => !e)}
- variant="outline"
- className="hover:bg-bg-default/10 size-9 p-0"
- icon={
- <ChevronUp
- className={cn(
- "text-content-inverted size-4 transition-transform duration-100",
- !isExpanded && "-scale-y-100",
- )}
- />
- }
- />
- </div>
- <div>
- <h2 className="text-lg font-semibold">Complete your profile</h2>
- <p className="text-content-inverted/60 text-base">
- Finish these steps to improve your application approval rates and
- receive more invitations from programs in our network.
- </p>
- </div>
- </div>
-
- <motion.div
- initial={false}
- animate={{
- height: isExpanded ? "auto" : 0,
- opacity: isExpanded ? 1 : 0,
- }}
- transition={{ duration: 0.15, ease: "easeOut" }}
- className="overflow-hidden"
- >
- <div
- className="grid grid-cols-1 rounded-lg bg-neutral-800 p-2 sm:grid-cols-2"
- onClick={(e) => e.stopPropagation()}
- >
- {tasks.map(({ label, completed, href }) => (
- <ConditionalLink
- key={label}
- href={completed ? undefined : href}
- className={cn(
- "group flex items-center justify-between gap-2 rounded-md px-3 py-2",
- !completed &&
- href &&
- "transition-colors duration-100 ease-out hover:bg-neutral-700",
- )}
- >
- <div className="flex min-w-0 items-center gap-2">
- {completed ? (
- <CircleCheckFill className="size-4 shrink-0 text-green-500" />
- ) : (
- <CircleDotted className="size-4 shrink-0 text-neutral-400" />
- )}
- <span className="min-w-0 truncate text-sm">{label}</span>
- </div>
- {!completed && href && (
- <div className="shrink-0 pr-4">
- <ExpandingArrow className="group-hover:text-content-inverted text-neutral-500" />
- </div>
- )}
- </ConditionalLink>
- ))}
- </div>
- </motion.div>
- </div>
- </motion.div>
- );
-}
-
-function ConditionalLink({
- href,
- className,
- children,
- ...rest
-}: Partial<HTMLProps<HTMLAnchorElement>>) {
- return href ? (
- <Link href={href} className={className} {...rest}>
- {children}
- </Link>
- ) : (
- <div className={className}>{children}</div>
- );
-}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/use-partner-discovery-requirements.ts b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/use-partner-discovery-requirements.ts
deleted file mode 100644
index df33a11c88..0000000000
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/use-partner-discovery-requirements.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { getPartnerProfileChecklistProgress } from "@/lib/network/get-partner-profile-checklist-progress";
-import usePartnerProfile from "@/lib/swr/use-partner-profile";
-import useProgramEnrollments from "@/lib/swr/use-program-enrollments";
-import { useMemo } from "react";
-
-export function usePartnerDiscoveryRequirements() {
- const { partner } = usePartnerProfile();
- const { programEnrollments } = useProgramEnrollments();
-
- return useMemo(() => {
- if (!partner || !programEnrollments) return undefined;
-
- const checklistProgress = getPartnerProfileChecklistProgress({
- partner,
- });
-
- return checklistProgress.tasks;
- }, [partner, programEnrollments]);
-}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/[bountyId]/bounty-submissions-table.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/[bountyId]/bounty-submissions-table.tsx
index 2eaf573050..e46df73490 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/[bountyId]/bounty-submissions-table.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/[bountyId]/bounty-submissions-table.tsx
@@ -1,10 +1,10 @@
"use client";
+import { BountySubmissionStatusBadges } from "@/lib/bounty/bounty-submission-status-badges";
import {
type SubmissionPeriod,
getSubmissionPeriods,
} from "@/lib/bounty/periods";
-import { BOUNTY_SUBMISSION_STATUS_BADGES } from "@/lib/bounty/submission-status";
import { resolveBountyDetails } from "@/lib/bounty/utils";
import { PartnerBountyProps, PartnerBountySubmission } from "@/lib/types";
import { useBountySubmissionDetailsSheet } from "@/ui/partners/bounties/bounty-submission-details-sheet";
@@ -56,7 +56,7 @@ export function BountySubmissionsTable({
}: {
row: { original: SubmissionPeriod<PartnerBountySubmission> };
}) => {
- const config = BOUNTY_SUBMISSION_STATUS_BADGES[original.status];
+ const config = BountySubmissionStatusBadges[original.status];
const label =
original.status === "submitted"
? "Pending review"
@@ -89,7 +89,7 @@ export function BountySubmissionsTable({
minSize: 120,
size: 160,
cell: ({ row: { original } }) => {
- const config = BOUNTY_SUBMISSION_STATUS_BADGES[original.status];
+ const config = BountySubmissionStatusBadges[original.status];
if (!config) return null;
const label =
original.status === "submitted" ? "Pending review" : config.label;
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/header-controls.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/header-controls.tsx
index d2dc7734ee..6e3fc6f957 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/header-controls.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/header-controls.tsx
@@ -1,19 +1,23 @@
"use client";
import { acceptProgramInviteAction } from "@/lib/actions/partners/accept-program-invite";
-import { getPartnerProfileChecklistProgress } from "@/lib/network/get-partner-profile-checklist-progress";
+import { submitNetworkProfileAction } from "@/lib/actions/partners/submit-network-profile";
+import { getNetworkProfileChecklistProgress } from "@/lib/network/get-network-profile-checklist-progress";
import { evaluateApplicationRequirements } from "@/lib/partners/evaluate-application-requirements";
import { mutatePrefix } from "@/lib/swr/mutate";
import usePartnerProfile from "@/lib/swr/use-partner-profile";
import useProgramEnrollment from "@/lib/swr/use-program-enrollment";
import useProgramEnrollments from "@/lib/swr/use-program-enrollments";
import { NetworkProgramProps } from "@/lib/types";
+import { useConfirmModal } from "@/ui/modals/confirm-modal";
+import { NetworkStatusBadges } from "@/ui/partners/partner-network/network-status-badges";
import { useProgramApplicationSheet } from "@/ui/partners/program-application-sheet";
import { Button, ProgressCircle, useKeyboardShortcut } from "@dub/ui";
+import { cn } from "@dub/utils";
import { useAction } from "next-safe-action/hooks";
import Link from "next/link";
import { useParams, useRouter } from "next/navigation";
-import { ReactNode, useMemo } from "react";
+import { ReactNode } from "react";
import { toast } from "sonner";
export function MarketplaceProgramHeaderControls({
@@ -51,17 +55,37 @@ function ApplyButton({ program }: { program: NetworkProgramProps }) {
onSuccess: () => mutatePrefix("/api/network/programs"),
});
- const { partner } = usePartnerProfile();
+ const { partner, mutate } = usePartnerProfile();
const { programEnrollment } = useProgramEnrollment();
- const checklistProgress = useMemo(() => {
- return partner
- ? getPartnerProfileChecklistProgress({
- partner,
- })
- : undefined;
- }, [partner]);
+ const { completedCount, totalCount, isComplete } =
+ getNetworkProfileChecklistProgress({
+ partner,
+ });
+
+ const { executeAsync: submitNetworkProfile } = useAction(
+ submitNetworkProfileAction,
+ {
+ onSuccess: () => {
+ toast.success("Application submitted successfully");
+ },
+ onError: ({ error }) => {
+ toast.error(error.serverError);
+ },
+ },
+ );
+
+ const { setShowConfirmModal, confirmModal } = useConfirmModal({
+ title: "Submit application",
+ description:
+ "Are you sure you want to submit your Dub Network application for review? You won't be able to make changes to your application after submitting it.",
+ confirmText: "Confirm submission",
+ onConfirm: async () => {
+ await submitNetworkProfile();
+ await mutate();
+ },
+ });
const { reason } = evaluateApplicationRequirements({
applicationRequirements: program.applicationRequirements,
@@ -84,27 +108,60 @@ function ApplyButton({ program }: { program: NetworkProgramProps }) {
programEnrollment.status,
) ? (
`You were ${programEnrollment.status} from this program`
- ) : checklistProgress && !checklistProgress.isComplete ? (
- <div className="max-w-xs p-4">
- <div className="text-content-default text-sm leading-5">
- Complete your partner profile to apply
+ ) : !isComplete ? (
+ <div className="max-w-xs p-3 text-center">
+ <div className="text-content-default text-pretty text-sm leading-5">
+ Complete your profile to join the Dub Partner Network. Once approved,
+ you can then apply to this program.
</div>
<Link
href="/profile"
className="bg-bg-subtle mt-3 flex items-center justify-center gap-2 rounded-lg px-2.5 py-1.5"
>
<ProgressCircle
- progress={
- checklistProgress.completedCount / checklistProgress.totalCount
- }
+ progress={completedCount / totalCount}
className="text-green-500"
/>
<span className="text-content-default text-sm font-medium">
- {checklistProgress.completedCount} of {checklistProgress.totalCount}{" "}
- tasks completed
+ {completedCount} of {totalCount} tasks completed
</span>
</Link>
</div>
+ ) : partner && !["approved", "trusted"].includes(partner.networkStatus) ? (
+ (() => {
+ const networkStatusBadge = NetworkStatusBadges[partner.networkStatus];
+ if (!("partnerTooltip" in networkStatusBadge)) {
+ return null;
+ }
+ const { partnerTooltip, icon: Icon, className } = networkStatusBadge;
+ const { content, cta } = partnerTooltip;
+
+ return (
+ <div className="max-w-xs space-y-2 p-4 text-center">
+ <div className="text-content-default text-pretty text-sm leading-5">
+ {content}
+ </div>
+ {partner.networkStatus === "draft" ? (
+ <Button
+ className="p-2"
+ text={cta}
+ onClick={() => setShowConfirmModal(true)}
+ />
+ ) : (
+ <Link
+ href="/profile"
+ className={cn(
+ "flex items-center justify-center gap-2 rounded-lg p-2",
+ className,
+ )}
+ >
+ <Icon className="size-4 shrink-0" />
+ <span className="text-sm font-medium">{cta}</span>
+ </Link>
+ )}
+ </div>
+ );
+ })()
) : (
requirementsNotMet
);
@@ -115,6 +172,7 @@ function ApplyButton({ program }: { program: NetworkProgramProps }) {
return (
<>
+ {confirmModal}
{programApplicationSheet}
<Button
text="Apply"
diff --git a/apps/web/app/api/user/referrals-token/route.ts b/apps/web/app/api/user/referrals-token/route.ts
index fedc96b116..766571fe38 100644
--- a/apps/web/app/api/user/referrals-token/route.ts
+++ b/apps/web/app/api/user/referrals-token/route.ts
@@ -4,7 +4,7 @@ import {
partnerHasEarnedCommissions,
partnerIsNotBanned,
type ProgramEnrollmentsForDiscoverability,
-} from "@/lib/network/get-discoverability-requirements";
+} from "@/lib/network/get-network-approval-requirements";
import { prisma } from "@dub/prisma";
import { NextResponse } from "next/server";
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
index fe773f0b04..c9b2e5e8b4 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
@@ -1,8 +1,8 @@
"use client";
+import { BountySubmissionStatusBadges } from "@/lib/bounty/bounty-submission-status-badges";
import { REJECT_BOUNTY_SUBMISSION_REASONS } from "@/lib/bounty/constants";
import { calculateSocialMetricsRewardAmount } from "@/lib/bounty/rewards";
-import { BOUNTY_SUBMISSION_STATUS_BADGES } from "@/lib/bounty/submission-status";
import { resolveBountyDetails } from "@/lib/bounty/utils";
import { mutatePrefix } from "@/lib/swr/mutate";
import { useApiMutation } from "@/lib/swr/use-api-mutation";
@@ -251,14 +251,13 @@ function BountySubmissionDetailsSheetContent({
value: (
<StatusBadge
variant={
- BOUNTY_SUBMISSION_STATUS_BADGES[submission.status]
- .variant
+ BountySubmissionStatusBadges[submission.status].variant
}
icon={
- BOUNTY_SUBMISSION_STATUS_BADGES[submission.status].icon
+ BountySubmissionStatusBadges[submission.status].icon
}
>
- {BOUNTY_SUBMISSION_STATUS_BADGES[submission.status].label}
+ {BountySubmissionStatusBadges[submission.status].label}
</StatusBadge>
),
},
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-row-menu.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-row-menu.tsx
index 8256235e59..111be90e5c 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-row-menu.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-row-menu.tsx
@@ -31,12 +31,8 @@ export function BountySubmissionRowMenu({
const { setShowConfirmModal, confirmModal } = useConfirmModal({
title: "Reopen submission",
- description: (
- <>
- Are you sure you want to reopen this bounty submission? This will reset
- the submission back to draft status.
- </>
- ),
+ description:
+ "Are you sure you want to reopen this bounty submission? This will reset the submission back to draft status.",
confirmText: "Reopen",
onConfirm: async () => {
try {
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
index 56d80980f5..8bed3d4b8e 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
@@ -2,7 +2,7 @@
import { isCurrencyAttribute } from "@/lib/api/workflows/utils";
import { PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES } from "@/lib/bounty/api/performance-bounty-scope-attributes";
-import { BOUNTY_SUBMISSION_STATUS_BADGES } from "@/lib/bounty/submission-status";
+import { BountySubmissionStatusBadges } from "@/lib/bounty/bounty-submission-status-badges";
import { resolveBountyDetails } from "@/lib/bounty/utils";
import { mutatePrefix } from "@/lib/swr/mutate";
import { useApiMutation } from "@/lib/swr/use-api-mutation";
@@ -230,7 +230,7 @@ export function BountySubmissionsTable() {
header: "Status",
cell: ({ row }) => {
const badge = row.original
- ? BOUNTY_SUBMISSION_STATUS_BADGES[row.original.status]
+ ? BountySubmissionStatusBadges[row.original.status]
: null;
return badge ? (
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/use-bounty-submission-filters.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/use-bounty-submission-filters.tsx
index 338ccc08cd..7ff13896b3 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/use-bounty-submission-filters.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/use-bounty-submission-filters.tsx
@@ -1,4 +1,4 @@
-import { BOUNTY_SUBMISSION_STATUS_BADGES } from "@/lib/bounty/submission-status";
+import { BountySubmissionStatusBadges } from "@/lib/bounty/bounty-submission-status-badges";
import {
SubmissionsCountByStatus,
useBountySubmissionsCount,
@@ -87,7 +87,7 @@ export function useBountySubmissionFilters({
label,
icon: Icon,
iconClassName,
- } = BOUNTY_SUBMISSION_STATUS_BADGES[status];
+ } = BountySubmissionStatusBadges[status];
return {
value: status,
label,
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/network-partner-card.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/network-partner-card.tsx
index 754e4c421b..3ae738ff28 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/network-partner-card.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/network/network-partner-card.tsx
@@ -132,7 +132,7 @@ export function NetworkPartnerCard({
) : (
<div className="size-16 animate-pulse rounded-full bg-neutral-200" />
)}
- {partner?.trustedAt && <TrustedPartnerBadge />}
+ {partner?.networkStatus === "trusted" && <TrustedPartnerBadge />}
</div>
{partner && onToggleStarred && (
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/use-partner-filters.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/use-partner-filters.tsx
index 4acbabf236..e3538b4f1b 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/use-partner-filters.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/use-partner-filters.tsx
@@ -290,16 +290,17 @@ export function usePartnerFilters(
({ status }) => !["pending", "rejected"].includes(status),
)
?.map(({ status, _count }) => {
- const Icon = PartnerStatusBadges[status].icon;
+ const {
+ label,
+ icon: Icon,
+ className,
+ } = PartnerStatusBadges[status];
return {
value: status,
- label: PartnerStatusBadges[status].label,
+ label,
icon: (
<Icon
- className={cn(
- PartnerStatusBadges[status].className,
- "size-4 bg-transparent",
- )}
+ className={cn(className, "size-4 bg-transparent")}
/>
),
right: nFormatter(_count || 0, { full: true }),
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx
index abbbc676ad..2c697ba25a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx
@@ -65,7 +65,7 @@ export default function WorkspaceInvoices() {
}
>
<PageWidthWrapper>
- <div className="rounded-xl border border-neutral-200 bg-white">
+ <div className="mb-10 rounded-xl border border-neutral-200 bg-white">
<TabSelect
className="px-4 md:px-5"
options={INVOICE_TYPES}
diff --git a/apps/web/lib/actions/partners/create-program-application.ts b/apps/web/lib/actions/partners/create-program-application.ts
index 450adeeb00..a331cf5e3e 100644
--- a/apps/web/lib/actions/partners/create-program-application.ts
+++ b/apps/web/lib/actions/partners/create-program-application.ts
@@ -8,7 +8,7 @@ import { markApplicationEventSubmitted } from "@/lib/application-events/update-a
import { getApplicationEventCookieName } from "@/lib/application-events/utils";
import { getSession } from "@/lib/auth";
import { qstash } from "@/lib/cron";
-import { getPartnerProfileChecklistProgress } from "@/lib/network/get-partner-profile-checklist-progress";
+import { getNetworkProfileChecklistProgress } from "@/lib/network/get-network-profile-checklist-progress";
import { evaluateApplicationRequirements } from "@/lib/partners/evaluate-application-requirements";
import {
formatApplicationFormData,
@@ -185,7 +185,7 @@ export const createProgramApplicationAction = actionClient
// for in-app applications from existing partners, we need to check
// if the partner has an incomplete profile, if so we prompt them to complete it
if (inAppApplication) {
- const { isComplete } = getPartnerProfileChecklistProgress({
+ const { isComplete } = getNetworkProfileChecklistProgress({
partner: {
...existingPartner,
preferredEarningStructures:
@@ -203,6 +203,12 @@ export const createProgramApplicationAction = actionClient
"Please complete your partner profile to submit your application: https://partners.dub.co/profile",
);
}
+
+ if (!["approved", "trusted"].includes(existingPartner.networkStatus)) {
+ throw new Error(
+ "Your partner network profile is not approved. Please wait for it to be approved before applying to this program.",
+ );
+ }
}
return createApplicationAndEnrollment({
diff --git a/apps/web/lib/actions/partners/submit-network-profile.ts b/apps/web/lib/actions/partners/submit-network-profile.ts
new file mode 100644
index 0000000000..0bdfe1fe6a
--- /dev/null
+++ b/apps/web/lib/actions/partners/submit-network-profile.ts
@@ -0,0 +1,89 @@
+"use server";
+
+import { throwIfNoPermission } from "@/lib/auth/partner-users/throw-if-no-permission";
+import { getNetworkProfileChecklistProgress } from "@/lib/network/get-network-profile-checklist-progress";
+import { partnerProfileChangeHistoryLogSchema } from "@/lib/zod/schemas/partner-profile";
+import { sendEmail } from "@dub/email";
+import NetworkPartnerApplicationSubmitted from "@dub/email/templates/network-partner-application-submitted";
+import { prisma } from "@dub/prisma";
+import { authPartnerActionClient } from "../safe-action";
+
+// Submit a partner network profile
+export const submitNetworkProfileAction = authPartnerActionClient.action(
+ async ({ ctx }) => {
+ const { partner, partnerUser } = ctx;
+
+ throwIfNoPermission({
+ role: partnerUser.role,
+ permission: "partner_profile.update",
+ });
+
+ if (partner.networkStatus !== "draft") {
+ throw new Error("Partner network profile not in 'draft' status");
+ }
+
+ const partnerProfile = await prisma.partner.findUniqueOrThrow({
+ where: {
+ id: partner.id,
+ },
+ include: {
+ platforms: true,
+ preferredEarningStructures: true,
+ salesChannels: true,
+ },
+ });
+
+ const { isComplete } = getNetworkProfileChecklistProgress({
+ partner: {
+ ...partnerProfile,
+ preferredEarningStructures:
+ partnerProfile.preferredEarningStructures.map(
+ ({ preferredEarningStructure }) => preferredEarningStructure,
+ ),
+ salesChannels: partnerProfile.salesChannels.map(
+ ({ salesChannel }) => salesChannel,
+ ),
+ },
+ });
+
+ if (!isComplete) {
+ throw new Error(
+ "Please complete your partner profile to submit your application: https://partners.dub.co/profile",
+ );
+ }
+
+ const partnerChangeHistoryLog = partner.changeHistoryLog
+ ? partnerProfileChangeHistoryLogSchema.parse(partner.changeHistoryLog)
+ : [];
+
+ partnerChangeHistoryLog.push({
+ field: "networkStatus",
+ from: partner.networkStatus,
+ to: "submitted",
+ changedAt: new Date(),
+ });
+
+ await prisma.partner.update({
+ where: {
+ id: partner.id,
+ },
+ data: {
+ networkStatus: "submitted",
+ changeHistoryLog: partnerChangeHistoryLog,
+ submittedAt: new Date(),
+ },
+ });
+
+ if (partner.email) {
+ await sendEmail({
+ to: partner.email,
+ subject: "Dub Partner Network application submitted",
+ variant: "notifications",
+ react: NetworkPartnerApplicationSubmitted({
+ name: partner.name,
+ email: partner.email,
+ }),
+ });
+ }
+ },
+);
diff --git a/apps/web/lib/actions/partners/update-partner-profile.ts b/apps/web/lib/actions/partners/update-partner-profile.ts
index b8f4854e1a..7de5a02147 100644
--- a/apps/web/lib/actions/partners/update-partner-profile.ts
+++ b/apps/web/lib/actions/partners/update-partner-profile.ts
@@ -3,12 +3,13 @@
import { confirmEmailChange } from "@/lib/auth/confirm-email-change";
import { throwIfNoPermission } from "@/lib/auth/partner-users/throw-if-no-permission";
import { qstash } from "@/lib/cron";
+import { isReservedUsername } from "@/lib/edge-config";
import { storage } from "@/lib/storage";
import { stripe } from "@/lib/stripe";
import { partnerProfileChangeHistoryLogSchema } from "@/lib/zod/schemas/partner-profile";
import {
MAX_PARTNER_DESCRIPTION_LENGTH,
- PartnerProfileSchema,
+ PartnerProfileDetailsSchema,
} from "@/lib/zod/schemas/partners";
import { prisma } from "@dub/prisma";
import { Partner, PartnerProfileType } from "@dub/prisma/client";
@@ -19,54 +20,42 @@ import {
nanoid,
PARTNERS_DOMAIN,
RESERVED_SLUGS,
+ validSlugRegex,
} from "@dub/utils";
import { waitUntil } from "@vercel/functions";
import * as z from "zod/v4";
import { uploadedImageSchema } from "../../zod/schemas/images";
import { authPartnerActionClient } from "../safe-action";
-const USERNAME_REGEX = /^(?![_-])(?!.*[_-]{2})[a-z0-9_-]{3,30}(?<![_-])$/;
-
-// TODO: Add more reserved usernames
-const RESERVED_USERNAMES = [...RESERVED_SLUGS, "dub"];
-
-const usernameSchema = z
- .string()
- .trim()
- .toLowerCase()
- .pipe(
- z
- .string()
- .min(3, "Username must be at least 3 characters")
- .max(30, "Username must be at most 30 characters")
- .regex(USERNAME_REGEX, "Invalid username format"),
- )
- .pipe(
- z
- .string()
- .refine(
- (v) => !RESERVED_USERNAMES.includes(v),
- "This username is reserved",
- ),
- )
- .nullish();
-
const updatePartnerProfileSchema = z
.object({
name: z.string().trim().min(1, "Name is required").optional(),
email: z.email().optional(),
+ username: z.string().trim().toLowerCase().min(3).max(100).optional(),
image: uploadedImageSchema.nullish(),
description: z.string().max(MAX_PARTNER_DESCRIPTION_LENGTH).nullish(),
country: z.enum(Object.keys(COUNTRIES) as [string, ...string[]]).nullish(),
profileType: z.enum(PartnerProfileType).optional(),
companyName: z.string().nullish(),
- username: usernameSchema,
})
- .extend(PartnerProfileSchema.partial().shape)
+ .extend(PartnerProfileDetailsSchema.partial().shape)
.transform((data) => ({
...data,
companyName: data.profileType === "individual" ? null : data.companyName,
- }));
+ }))
+ .refine(
+ (data) => {
+ if (data.profileType === "company") {
+ return !!data.companyName;
+ }
+
+ return true;
+ },
+ {
+ message: "Legal company name is required when profile type is 'company'.",
+ path: ["companyName"],
+ },
+ );
// Update a partner profile
export const updatePartnerProfileAction = authPartnerActionClient
@@ -94,12 +83,6 @@ export const updatePartnerProfileAction = authPartnerActionClient
username,
} = parsedInput;
- if (
- profileType === "company" &&
- (companyName === undefined ? !partner.companyName : !companyName)
- )
- throw new Error("Legal company name is required.");
-
await updatedComplianceFieldsChecks({
partner,
input: parsedInput,
@@ -119,6 +102,12 @@ export const updatePartnerProfileAction = authPartnerActionClient
}
if (username && username !== partner.username) {
+ if (!validSlugRegex.test(username) || RESERVED_SLUGS.includes(username)) {
+ throw new Error("Invalid username");
+ }
+ if (await isReservedUsername(username)) {
+ throw new Error("Invalid username");
+ }
const existingPartner = await prisma.partner.findUnique({
where: {
username,
@@ -174,12 +163,6 @@ export const updatePartnerProfileAction = authPartnerActionClient
},
}),
},
- include: {
- preferredEarningStructures: true,
- salesChannels: true,
- programs: true,
- platforms: true,
- },
});
// If the email is being changed, we need to verify the new email address
diff --git a/apps/web/lib/api/network/calculate-partner-ranking.ts b/apps/web/lib/api/network/calculate-partner-ranking.ts
index 9202ef407f..3a84eec53a 100644
--- a/apps/web/lib/api/network/calculate-partner-ranking.ts
+++ b/apps/web/lib/api/network/calculate-partner-ranking.ts
@@ -18,7 +18,7 @@ export interface PartnerRankingParams extends PartnerRankingFilters {
* Scoring Breakdown (0-65+ points):
*
* 1. Trusted Partner Bonus (200 points): Top priority boost
- * - Partners with trustedAt IS NOT NULL get 200 bonus points
+ * - Partners with networkStatus = "trusted" get 200 bonus points
* - This ensures trusted partners appear at the very top
*
* 2. Similarity Score (0-50 points): Performance in similar programs
@@ -239,13 +239,13 @@ export async function calculatePartnerRanking({
${hasProfileCheck} as hasProfile,
-- FINAL SCORE (0-765+ points): Similarity-based ranking for discovery
- -- Trusted partners (trustedAt IS NOT NULL) get 200 bonus points to rank at the top
+ -- Trusted partners (networkStatus = "trusted") get 200 bonus points to rank at the top
-- Partners with profiles get 500 bonus points to ensure they rank above those without profiles
(
-- Profile bonus: 500 points for partners with platforms (ensures they rank above those without)
CASE WHEN ${hasProfileCheck} THEN 500 ELSE 0 END +
- -- Trusted partner bonus: 200 points for partners with trustedAt set
- CASE WHEN p.trustedAt IS NOT NULL THEN 200 ELSE 0 END +
+ -- Trusted partner bonus: 200 points for partners with networkStatus = "trusted"
+ CASE WHEN p.networkStatus = "trusted" THEN 200 ELSE 0 END +
COALESCE(similarProgramMetrics.similarityScore, 0) +
COALESCE(similarProgramMetrics.programMatchScore, 0)
) as finalScore
diff --git a/apps/web/lib/bounty/submission-status.ts b/apps/web/lib/bounty/bounty-submission-status-badges.ts
similarity index 94%
rename from apps/web/lib/bounty/submission-status.ts
rename to apps/web/lib/bounty/bounty-submission-status-badges.ts
index 9b5144af9d..69da3be6a4 100644
--- a/apps/web/lib/bounty/submission-status.ts
+++ b/apps/web/lib/bounty/bounty-submission-status-badges.ts
@@ -7,7 +7,7 @@ import {
Lock,
} from "@dub/ui/icons";
-export const BOUNTY_SUBMISSION_STATUS_BADGES = {
+export const BountySubmissionStatusBadges = {
notSubmitted: {
label: "Not submitted",
variant: "neutral",
@@ -23,13 +23,13 @@ export const BOUNTY_SUBMISSION_STATUS_BADGES = {
draft: {
label: "In progress",
variant: "pending",
- icon: CircleHalfDottedCheck,
+ icon: CircleHalfDottedClock,
iconClassName: "text-orange-600",
},
submitted: {
label: "Submitted",
variant: "new",
- icon: CircleHalfDottedClock,
+ icon: CircleHalfDottedCheck,
iconClassName: "text-blue-600",
},
approved: {
diff --git a/apps/web/lib/network/get-discoverability-requirements.ts b/apps/web/lib/network/get-network-approval-requirements.ts
similarity index 97%
rename from apps/web/lib/network/get-discoverability-requirements.ts
rename to apps/web/lib/network/get-network-approval-requirements.ts
index d37b54446a..8001106520 100644
--- a/apps/web/lib/network/get-discoverability-requirements.ts
+++ b/apps/web/lib/network/get-network-approval-requirements.ts
@@ -32,7 +32,7 @@ export const partnerIsNotBanned = (
return programEnrollments.every((pe) => pe.status !== "banned");
};
-export function getDiscoverabilityRequirements({
+export function getNetworkApprovalRequirements({
partner,
}: {
partner: Pick<
diff --git a/apps/web/lib/network/get-partner-profile-checklist-progress.ts b/apps/web/lib/network/get-network-profile-checklist-progress.ts
similarity index 57%
rename from apps/web/lib/network/get-partner-profile-checklist-progress.ts
rename to apps/web/lib/network/get-network-profile-checklist-progress.ts
index a0f4464b9b..37152028f5 100644
--- a/apps/web/lib/network/get-partner-profile-checklist-progress.ts
+++ b/apps/web/lib/network/get-network-profile-checklist-progress.ts
@@ -1,10 +1,10 @@
import { PartnerProps } from "../types";
-import { getDiscoverabilityRequirements } from "./get-discoverability-requirements";
+import { getNetworkApprovalRequirements } from "./get-network-approval-requirements";
-export function getPartnerProfileChecklistProgress({
+export function getNetworkProfileChecklistProgress({
partner,
}: {
- partner: Pick<
+ partner?: Pick<
PartnerProps,
| "image"
| "description"
@@ -14,7 +14,16 @@ export function getPartnerProfileChecklistProgress({
| "platforms"
>;
}) {
- const tasks = getDiscoverabilityRequirements({
+ if (!partner) {
+ return {
+ tasks: [],
+ completedCount: 0,
+ totalCount: 0,
+ isComplete: false,
+ };
+ }
+
+ const tasks = getNetworkApprovalRequirements({
partner,
});
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 7183914d21..4533ab16e1 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -68,6 +68,7 @@ import {
fieldDiffSchema,
getActivityLogsQuerySchema,
} from "./zod/schemas/activity-log";
+import { adminNetworkPartnerSchema } from "./zod/schemas/admin";
import {
BountyListSchema,
bountyPerformanceConditionSchema,
@@ -552,6 +553,8 @@ export type PartnerApplicationProps = z.infer<typeof PartnerApplicationSchema>;
export type NetworkPartnerProps = z.infer<typeof NetworkPartnerSchema>;
+export type AdminNetworkPartner = z.infer<typeof adminNetworkPartnerSchema>;
+
export type PartnerConversionScore = z.infer<
typeof PartnerConversionScoreSchema
>;
diff --git a/apps/web/lib/webhook/sample-events/partner-enrolled.json b/apps/web/lib/webhook/sample-events/partner-enrolled.json
index 3994d05d4f..ae55f9f58a 100644
--- a/apps/web/lib/webhook/sample-events/partner-enrolled.json
+++ b/apps/web/lib/webhook/sample-events/partner-enrolled.json
@@ -6,6 +6,7 @@
"country": "MR",
"companyName": null,
"description": "I'm a content creator who works with brands to grow their business.",
+ "networkStatus": "draft",
"tenantId": "64dc9a8c-5cf9-4446-b53b-cdc15199fafc",
"programId": "prog_CYCu7IMAapjkRpTnr8F1azjN",
"partnerId": "pn_1K9BZE1K285BSTX4W6MPKXJFZ",
diff --git a/apps/web/lib/zod/schemas/admin.ts b/apps/web/lib/zod/schemas/admin.ts
new file mode 100644
index 0000000000..1b59ff46d6
--- /dev/null
+++ b/apps/web/lib/zod/schemas/admin.ts
@@ -0,0 +1,97 @@
+import {
+ FraudAlertStatus,
+ PartnerNetworkStatus,
+ ProgramEnrollmentStatus,
+} from "@dub/prisma/client";
+import * as z from "zod/v4";
+import { getPaginationQuerySchema } from "./misc";
+import { partnerProfileChangeHistoryLogSchema } from "./partner-profile";
+import {
+ EnrolledPartnerSchemaExtended,
+ partnerPlatformSchema,
+ PartnerSchema,
+} from "./partners";
+import { ProgramSchema } from "./programs";
+import { UserSchema } from "./users";
+import { centsSchema } from "./utils";
+
+export const adminFraudAlertSchema = z.object({
+ id: z.string(),
+ reason: z.string(),
+ status: z.enum(FraudAlertStatus),
+ reviewedAt: z.date().nullable(),
+ reviewNote: z.string().nullable(),
+ createdAt: z.date(),
+ partner: PartnerSchema.pick({
+ id: true,
+ name: true,
+ email: true,
+ image: true,
+ }),
+ program: ProgramSchema.pick({
+ id: true,
+ name: true,
+ logo: true,
+ }),
+ reviewedBy: UserSchema.pick({
+ id: true,
+ name: true,
+ }).nullable(),
+});
+
+export const adminNetworkPartnerSchema = EnrolledPartnerSchemaExtended.pick({
+ id: true,
+ name: true,
+ companyName: true,
+ email: true,
+ image: true,
+ description: true,
+ country: true,
+ createdAt: true,
+ defaultPayoutMethod: true,
+ paypalEmail: true,
+ stripeConnectId: true,
+ payoutsEnabledAt: true,
+ identityVerifiedAt: true,
+ monthlyTraffic: true,
+ industryInterests: true,
+ preferredEarningStructures: true,
+ salesChannels: true,
+}).extend({
+ submittedAt: z.date().nullable(),
+ reviewedAt: z.date().nullable(),
+ networkStatus: PartnerSchema.shape.networkStatus,
+ platforms: z.array(partnerPlatformSchema),
+ changeHistoryLog: partnerProfileChangeHistoryLogSchema.nullable(),
+ programs: z.array(
+ ProgramSchema.pick({
+ id: true,
+ name: true,
+ logo: true,
+ slug: true,
+ url: true,
+ }).extend({
+ status: z.enum(ProgramEnrollmentStatus),
+ totalSaleAmount: centsSchema,
+ totalCommissions: centsSchema,
+ }),
+ ),
+ duplicatePartnerAccounts: z.array(
+ PartnerSchema.pick({
+ id: true,
+ name: true,
+ email: true,
+ image: true,
+ country: true,
+ }),
+ ),
+});
+
+export const adminNetworkPartnerQuerySchema = z
+ .object({
+ networkStatus: z.enum(PartnerNetworkStatus).optional(),
+ country: z.string().optional(),
+ search: z.string().trim().min(1).optional(),
+ sortOrder: z.enum(["asc", "desc"]).optional().default("desc"),
+ })
+ .extend(getPaginationQuerySchema({ pageSize: 100 }));
diff --git a/apps/web/lib/zod/schemas/fraud.ts b/apps/web/lib/zod/schemas/fraud.ts
index e001c3f81a..6b8177bd65 100644
--- a/apps/web/lib/zod/schemas/fraud.ts
+++ b/apps/web/lib/zod/schemas/fraud.ts
@@ -1,13 +1,8 @@
import { PAID_TRAFFIC_PLATFORMS } from "@/lib/api/fraud/constants";
-import {
- FraudAlertStatus,
- FraudEventStatus,
- FraudRuleType,
-} from "@dub/prisma/client";
+import { FraudEventStatus, FraudRuleType } from "@dub/prisma/client";
import * as z from "zod/v4";
import { getPaginationQuerySchema } from "./misc";
import { EnrolledPartnerSchema, PartnerSchema } from "./partners";
-import { ProgramSchema } from "./programs";
import { UserSchema } from "./users";
export const MAX_RESOLUTION_REASON_LENGTH = 200;
@@ -313,27 +308,3 @@ export const fraudEventSchemas = {
partnerDuplicateAccount: baseFraudEventSchema,
};
-
-export const fraudAlertSchema = z.object({
- id: z.string(),
- reason: z.string(),
- status: z.enum(FraudAlertStatus),
- reviewedAt: z.date().nullable(),
- reviewNote: z.string().nullable(),
- createdAt: z.date(),
- partner: PartnerSchema.pick({
- id: true,
- name: true,
- email: true,
- image: true,
- }),
- program: ProgramSchema.pick({
- id: true,
- name: true,
- logo: true,
- }),
- reviewedBy: UserSchema.pick({
- id: true,
- name: true,
- }).nullable(),
-});
diff --git a/apps/web/lib/zod/schemas/partner-network.ts b/apps/web/lib/zod/schemas/partner-network.ts
index e2964fe4dd..fd6dabdc0d 100644
--- a/apps/web/lib/zod/schemas/partner-network.ts
+++ b/apps/web/lib/zod/schemas/partner-network.ts
@@ -75,7 +75,7 @@ export const NetworkPartnerSchema = PartnerSchema.pick({
image: true,
description: true,
createdAt: true,
- trustedAt: true,
+ networkStatus: true,
monthlyTraffic: true,
preferredEarningStructures: true,
salesChannels: true,
diff --git a/apps/web/lib/zod/schemas/partner-profile.ts b/apps/web/lib/zod/schemas/partner-profile.ts
index 9452200645..70fc5ece7f 100644
--- a/apps/web/lib/zod/schemas/partner-profile.ts
+++ b/apps/web/lib/zod/schemas/partner-profile.ts
@@ -5,6 +5,7 @@ import {
import { PARTNER_CUSTOMERS_MAX_PAGE_SIZE } from "@/lib/constants/partner-profile";
import {
CommissionType,
+ PartnerNetworkStatus,
PartnerPayoutMethod,
PartnerProfileType,
PartnerRole,
@@ -211,6 +212,12 @@ export const partnerProfileChangeHistoryLogSchema = z.array(
to: z.enum(PartnerProfileType),
changedAt: z.coerce.date(),
}),
+ z.object({
+ field: z.literal("networkStatus"),
+ from: z.enum(PartnerNetworkStatus),
+ to: z.enum(PartnerNetworkStatus),
+ changedAt: z.coerce.date(),
+ }),
]),
);
diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.ts
index 94b4d2dc6a..656c9c6354 100644
--- a/apps/web/lib/zod/schemas/partners.ts
+++ b/apps/web/lib/zod/schemas/partners.ts
@@ -5,6 +5,7 @@ import {
IndustryInterest,
MonthlyTraffic,
PartnerBannedReason,
+ PartnerNetworkStatus,
PartnerPayoutMethod,
PartnerProfileType,
PlatformType,
@@ -304,7 +305,7 @@ export const partnerPlatformSchema = z.object({
views: z.bigint().default(BigInt(0)),
});
-export const PartnerPartnerPlatformsSchema = z.object({
+export const OldPartnerPlatformsFields = z.object({
website: z
.string()
.nullish()
@@ -331,7 +332,7 @@ export const PartnerPartnerPlatformsSchema = z.object({
.describe("The partner's TikTok username (e.g. `johndoe`)."),
});
-export const PartnerProfileSchema = z.object({
+export const PartnerProfileDetailsSchema = z.object({
monthlyTraffic: z
.enum(MonthlyTraffic)
.nullable()
@@ -361,16 +362,7 @@ export const PartnerSchema = z
.object({
id: z.string().describe("The partner's unique ID on Dub."),
name: z.string().max(190).describe("The partner's full legal name."),
- companyName: z
- .string()
- .max(190)
- .nullable()
- .describe(
- "If the partner profile type is a company, this is the partner's legal company name.",
- ),
- profileType: z
- .enum(PartnerProfileType)
- .describe("The partner's profile type on Dub."),
+ username: z.string().nullable().describe("The partner's unique username."),
email: z
.string()
.max(190)
@@ -378,7 +370,6 @@ export const PartnerSchema = z
.describe(
"The partner's email address. Should be a unique value across Dub.",
),
- username: z.string().nullable().describe("The partner's unique username."),
image: z.string().nullable().describe("The partner's avatar image."),
description: z
.string()
@@ -389,6 +380,19 @@ export const PartnerSchema = z
.string()
.nullable()
.describe("The partner's country (required for tax purposes)."),
+ companyName: z
+ .string()
+ .max(190)
+ .nullable()
+ .describe(
+ "If the partner profile type is a company, this is the partner's legal company name.",
+ ),
+ profileType: z
+ .enum(PartnerProfileType)
+ .describe("The partner's profile type on Dub."),
+ networkStatus: z
+ .enum(PartnerNetworkStatus)
+ .describe("The partner's network status on Dub."),
defaultPayoutMethod: z
.enum(PartnerPayoutMethod)
.nullable()
@@ -427,16 +431,6 @@ export const PartnerSchema = z
createdAt: z
.date()
.describe("The date when the partner was created on Dub."),
- discoverableAt: z
- .date()
- .nullable()
- .describe("The date when the partner was added to the partner network."),
- trustedAt: z
- .date()
- .nullable()
- .describe(
- "The date when the partner received the trusted badge in the partner network.",
- ),
identityVerificationStatus: z
.enum(IdentityVerificationStatus)
.nullable()
@@ -457,11 +451,11 @@ export const PartnerSchema = z
.nullable()
.describe("The date when the partner's identity was verified."),
})
- .extend(PartnerPartnerPlatformsSchema.shape)
- .extend(PartnerProfileSchema.partial().shape);
+ .extend(OldPartnerPlatformsFields.shape)
+ .extend(PartnerProfileDetailsSchema.partial().shape);
export const PartnerWithProfileSchema = PartnerSchema.extend(
- PartnerProfileSchema.shape,
+ PartnerProfileDetailsSchema.shape,
);
export const PartnerRewindSchema = z.object({
@@ -482,16 +476,16 @@ export const PartnerRewindSchema = z.object({
export const EnrolledPartnerSchema = PartnerSchema.pick({
id: true,
name: true,
- companyName: true,
email: true,
image: true,
description: true,
country: true,
+ companyName: true,
+ networkStatus: true,
defaultPayoutMethod: true,
paypalEmail: true,
stripeConnectId: true,
payoutsEnabledAt: true,
- trustedAt: true,
identityVerifiedAt: true,
})
.extend(
@@ -571,16 +565,13 @@ export const EnrolledPartnerSchema = PartnerSchema.pick({
"Return On Ad Spend (ROAS) (`Total Revenue ÷ Total Commissions`)",
),
})
- .extend(
- PartnerPartnerPlatformsSchema.pick({
- website: true,
- youtube: true,
- twitter: true,
- linkedin: true,
- instagram: true,
- tiktok: true,
- }).shape,
- );
+ .extend(OldPartnerPlatformsFields.shape)
+ .extend({
+ trustedAt: z.date().nullish().meta({
+ deprecated: true,
+ description: "DEPRECATED: Use `networkStatus` instead.",
+ }),
+ });
export const EnrolledPartnerSchemaExtended = EnrolledPartnerSchema.extend({
lastLeadAt: z.date().nullish(),
@@ -592,16 +583,14 @@ export const EnrolledPartnerSchemaExtended = EnrolledPartnerSchema.extend({
id: true,
provider: true,
}).nullish(),
-})
- .extend(
- PartnerSchema.pick({
- monthlyTraffic: true,
- industryInterests: true,
- preferredEarningStructures: true,
- salesChannels: true,
- }).shape,
- )
- .extend(PartnerPartnerPlatformsSchema.shape);
+}).extend(
+ PartnerSchema.pick({
+ monthlyTraffic: true,
+ industryInterests: true,
+ preferredEarningStructures: true,
+ salesChannels: true,
+ }).shape,
+);
export const WebhookPartnerSchema = PartnerSchema.pick({
id: true,
diff --git a/apps/web/lib/zod/schemas/program-application.ts b/apps/web/lib/zod/schemas/program-application.ts
index d07b5ba27d..f19ea2cc25 100644
--- a/apps/web/lib/zod/schemas/program-application.ts
+++ b/apps/web/lib/zod/schemas/program-application.ts
@@ -3,7 +3,7 @@ import { getPaginationQuerySchema } from "./misc";
import {
EnrolledPartnerSchema,
getPartnersQuerySchema,
- PartnerPartnerPlatformsSchema,
+ OldPartnerPlatformsFields,
PARTNERS_MAX_PAGE_SIZE,
} from "./partners";
import { ProgramEnrollmentSchema } from "./programs";
@@ -26,16 +26,7 @@ export const PartnerApplicationSchema = z.object({
status: true,
}).shape,
)
- .extend(
- PartnerPartnerPlatformsSchema.pick({
- website: true,
- youtube: true,
- twitter: true,
- linkedin: true,
- instagram: true,
- tiktok: true,
- }).shape,
- ),
+ .extend(OldPartnerPlatformsFields.shape),
applicationFormData: z
.array(
z.object({
diff --git a/apps/web/lib/zod/schemas/workspaces.ts b/apps/web/lib/zod/schemas/workspaces.ts
index 3b60f890fd..9507b3a894 100644
--- a/apps/web/lib/zod/schemas/workspaces.ts
+++ b/apps/web/lib/zod/schemas/workspaces.ts
@@ -193,12 +193,9 @@ export const createWorkspaceSchema = z.object({
.max(48, "Slug must be less than 48 characters")
.transform((v) => slugify(v))
.refine((v) => validSlugRegex.test(v), { message: "Invalid slug format" })
- .refine(
- async (v) => !(RESERVED_SLUGS.includes(v) || DEFAULT_REDIRECTS[v]),
- {
- message: "Cannot use reserved slugs",
- },
- ),
+ .refine((v) => !(RESERVED_SLUGS.includes(v) || DEFAULT_REDIRECTS[v]), {
+ message: "Cannot use reserved slugs",
+ }),
logo: z
.union([uploadedImageSchema, googleUserContentUrlSchema])
.transform((v) => v || null)
diff --git a/apps/web/tests/partners/resource.ts b/apps/web/tests/partners/resource.ts
index 9d187161af..c49c0e6441 100644
--- a/apps/web/tests/partners/resource.ts
+++ b/apps/web/tests/partners/resource.ts
@@ -29,6 +29,6 @@ export const normalizedPartnerDateFields = z.object({
createdAt: z.string(),
bannedAt: z.string().nullish(),
payoutsEnabledAt: z.string().nullish(),
- trustedAt: z.string().nullish(),
identityVerifiedAt: z.string().nullish(),
+ trustedAt: z.string().nullish(),
});
diff --git a/apps/web/ui/partners/bounties/bounty-submission-details-sheet.tsx b/apps/web/ui/partners/bounties/bounty-submission-details-sheet.tsx
index 8ba7fcea22..d4e4a2ed98 100644
--- a/apps/web/ui/partners/bounties/bounty-submission-details-sheet.tsx
+++ b/apps/web/ui/partners/bounties/bounty-submission-details-sheet.tsx
@@ -1,8 +1,8 @@
"use client";
+import { BountySubmissionStatusBadges } from "@/lib/bounty/bounty-submission-status-badges";
import { REJECT_BOUNTY_SUBMISSION_REASONS } from "@/lib/bounty/constants";
import { getPeriodLabel } from "@/lib/bounty/periods";
-import { BOUNTY_SUBMISSION_STATUS_BADGES } from "@/lib/bounty/submission-status";
import { resolveBountyDetails } from "@/lib/bounty/utils";
import { PartnerBountyProps, PartnerBountySubmission } from "@/lib/types";
import { CommissionStatusBadges } from "@/ui/partners/commission-status-badges";
@@ -123,7 +123,7 @@ function SubmissionDetailsView({
submission: PartnerBountySubmission;
}) {
const bountyInfo = resolveBountyDetails(bounty);
- const statusBadge = BOUNTY_SUBMISSION_STATUS_BADGES[submission.status];
+ const statusBadge = BountySubmissionStatusBadges[submission.status];
const submittedDate = submission.completedAt ?? submission.createdAt;
const textValue = (text: string) => (
diff --git a/apps/web/ui/partners/fraud-risks/partner-application-risk-summary.tsx b/apps/web/ui/partners/fraud-risks/partner-application-risk-summary.tsx
index fec6b97ee2..0d2b1b6aa0 100644
--- a/apps/web/ui/partners/fraud-risks/partner-application-risk-summary.tsx
+++ b/apps/web/ui/partners/fraud-risks/partner-application-risk-summary.tsx
@@ -4,7 +4,7 @@ import { FRAUD_SEVERITY_CONFIG } from "@/lib/api/fraud/constants";
import { getPlanCapabilities } from "@/lib/plan-capabilities";
import { usePartnerApplicationRisks } from "@/lib/swr/use-partner-application-risks";
import useWorkspace from "@/lib/swr/use-workspace";
-import { EnrolledPartnerExtendedProps, FraudSeverity } from "@/lib/types";
+import { FraudSeverity } from "@/lib/types";
import { Button, ShieldKeyhole } from "@dub/ui";
import { cn } from "@dub/utils";
import Link from "next/link";
@@ -15,7 +15,9 @@ import { usePartnerApplicationRiskSummaryModal } from "./partner-application-ris
import { PartnerCrossProgramSummary } from "./partner-cross-program-summary";
interface PartnerApplicationRiskSummaryProps {
- partner: EnrolledPartnerExtendedProps;
+ partner: {
+ id: string;
+ };
}
// Displays the risk analysis for a partner application
diff --git a/apps/web/ui/partners/partner-avatar.tsx b/apps/web/ui/partners/partner-avatar.tsx
index a070d9c116..e5015aac71 100644
--- a/apps/web/ui/partners/partner-avatar.tsx
+++ b/apps/web/ui/partners/partner-avatar.tsx
@@ -5,7 +5,9 @@ export function PartnerAvatar({
partner,
className,
}: {
- partner: NullableOptional<PartnerProps>;
+ partner: NullableOptional<
+ Pick<PartnerProps, "id" | "name" | "email" | "image">
+ >;
className?: string;
}) {
return (
diff --git a/apps/web/ui/partners/partner-info-cards.tsx b/apps/web/ui/partners/partner-info-cards.tsx
index 272c438128..6c63fe5a38 100644
--- a/apps/web/ui/partners/partner-info-cards.tsx
+++ b/apps/web/ui/partners/partner-info-cards.tsx
@@ -1,7 +1,7 @@
import useGroup from "@/lib/swr/use-group";
-import useProgram from "@/lib/swr/use-program";
import useWorkspace from "@/lib/swr/use-workspace";
import {
+ AdminNetworkPartner,
BountyListProps,
EnrolledPartnerExtendedProps,
NetworkPartnerProps,
@@ -67,6 +67,7 @@ type PartnerInfoCardsProps = {
} & (
| { type?: "enrolled"; partner?: EnrolledPartnerExtendedProps }
| { type: "network"; partner?: NetworkPartnerProps }
+ | { type: "admin"; partner?: AdminNetworkPartner }
);
type BasicField = {
@@ -91,13 +92,9 @@ export function PartnerInfoCards({
}: PartnerInfoCardsProps) {
const { id: workspaceId, slug: workspaceSlug } = useWorkspace();
- const { program } = useProgram();
-
const isEnrolled = type === "enrolled" || type === undefined;
const isNetwork = type === "network";
-
- const showPayoutMethodField =
- isEnrolled && program?.payoutMode !== "external";
+ const isAdmin = type === "admin";
const {
partnerGroupHistorySheet,
@@ -144,36 +141,32 @@ export function PartnerInfoCards({
},
];
- if (isEnrolled && partner) {
+ if ((isEnrolled || isAdmin) && partner) {
basicFields = basicFields.concat([
{
id: "createdAt",
icon: <Users className="size-3.5" />,
- text: `${partner.status === "approved" ? "Partner since" : "Applied"} ${formatDate(partner.createdAt)}`,
+ text: `${"status" in partner && partner.status === "pending" ? "Applied" : "Partner since"} ${formatDate(partner.createdAt)}`,
timestamp: partner.createdAt,
},
- ...(showPayoutMethodField
- ? [
- {
- id: "payoutMethod" as const,
- icon: partner.defaultPayoutMethod ? (
- createElement(
- getPayoutMethodIconConfig(partner.defaultPayoutMethod).Icon,
- { className: "size-3.5 shrink-0" },
- )
- ) : (
- <CircleMinus className="size-3.5 shrink-0" />
- ),
- text:
- partner.defaultPayoutMethod && partner.payoutsEnabledAt
- ? `${getPayoutMethodLabel(partner.defaultPayoutMethod)} connected ${formatDateTimeSmart(partner.payoutsEnabledAt)}`
- : "No payout method connected",
- ...(partner.payoutsEnabledAt
- ? { timestamp: partner.payoutsEnabledAt }
- : {}),
- },
- ]
- : []),
+ {
+ id: "payoutMethod" as const,
+ icon: partner.defaultPayoutMethod ? (
+ createElement(
+ getPayoutMethodIconConfig(partner.defaultPayoutMethod).Icon,
+ { className: "size-3.5 shrink-0" },
+ )
+ ) : (
+ <CircleMinus className="size-3.5 shrink-0" />
+ ),
+ text:
+ partner.defaultPayoutMethod && partner.payoutsEnabledAt
+ ? `${getPayoutMethodLabel(partner.defaultPayoutMethod)} connected ${formatDateTimeSmart(partner.payoutsEnabledAt)}`
+ : "No payout method connected",
+ ...(partner.payoutsEnabledAt
+ ? { timestamp: partner.payoutsEnabledAt }
+ : {}),
+ },
// TODO: once more partners verify their identity, we can show this by default
...(partner.identityVerifiedAt
? [
@@ -230,7 +223,9 @@ export function PartnerInfoCards({
) : (
<div className="size-20 animate-pulse rounded-full bg-neutral-200" />
)}
- {partner?.trustedAt && <TrustedPartnerBadge />}
+ {partner?.networkStatus === "trusted" && (
+ <TrustedPartnerBadge />
+ )}
</div>
<div className="flex items-center gap-2">
@@ -264,7 +259,7 @@ export function PartnerInfoCards({
)}
</div>
- {isEnrolled &&
+ {(isEnrolled || isAdmin) &&
(partner ? (
partner.email && (
<div className="mt-0.5 flex items-center gap-1">
@@ -332,118 +327,120 @@ export function PartnerInfoCards({
</div>
</div>
- <div className="border-border-subtle flex flex-col gap-4 rounded-xl border p-4">
- {/* Group */}
- <div className="flex flex-col gap-2">
- {isEnrolled && (
- <div className="flex min-h-7 items-center justify-between">
- <h3 className="text-content-emphasis text-sm font-semibold">
- Group
- </h3>
+ {!isAdmin && (
+ <div className="border-border-subtle flex flex-col gap-4 rounded-xl border p-4">
+ {/* Group */}
+ <div className="flex flex-col gap-2">
+ {isEnrolled && (
+ <div className="flex min-h-7 items-center justify-between">
+ <h3 className="text-content-emphasis text-sm font-semibold">
+ Group
+ </h3>
- {partner && partner.status !== "pending" && hasActivityLogs && (
- <Button
- variant="outline"
- text="View history"
- className="h-7 w-fit rounded-lg px-1.5 text-xs font-medium text-neutral-400"
- onClick={() => setGroupHistoryOpen(true)}
- />
- )}
- </div>
- )}
+ {partner && partner.status !== "pending" && hasActivityLogs && (
+ <Button
+ variant="outline"
+ text="View history"
+ className="h-7 w-fit rounded-lg px-1.5 text-xs font-medium text-neutral-400"
+ onClick={() => setGroupHistoryOpen(true)}
+ />
+ )}
+ </div>
+ )}
- {partnerGroupHistorySheet}
- {partner ? (
- <PartnerInfoGroup
- partner={partner}
- changeButtonText="Change"
- hideChangeButton={
- "status" in partner &&
- INACTIVE_ENROLLMENT_STATUSES.includes(partner.status)
- }
- className="rounded-lg bg-white shadow-sm"
- selectedGroupId={selectedGroupId}
- setSelectedGroupId={setSelectedGroupId}
- />
- ) : (
- <div className="my-px h-11 w-full animate-pulse rounded-lg bg-neutral-200" />
- )}
- </div>
+ {partnerGroupHistorySheet}
+ {partner ? (
+ <PartnerInfoGroup
+ partner={partner}
+ changeButtonText="Change"
+ hideChangeButton={
+ "status" in partner &&
+ INACTIVE_ENROLLMENT_STATUSES.includes(partner.status)
+ }
+ className="rounded-lg bg-white shadow-sm"
+ selectedGroupId={selectedGroupId}
+ setSelectedGroupId={setSelectedGroupId}
+ />
+ ) : (
+ <div className="my-px h-11 w-full animate-pulse rounded-lg bg-neutral-200" />
+ )}
+ </div>
- {isEnrolled && partner?.status === "approved" && (
- <>
- {/* Rewards */}
- <div className="flex flex-col gap-2">
- <h3 className="text-content-emphasis text-sm font-semibold">
- Rewards
- </h3>
- {group ? (
- group.clickReward ||
- group.leadReward ||
- group.saleReward ||
- group.discount ? (
- <ProgramRewardList
- rewards={[
- group.clickReward,
- group.leadReward,
- group.saleReward,
- ].filter((r): r is RewardProps => r !== null)}
- discount={group.discount}
- variant="plain"
- className="text-content-subtle gap-2 text-xs leading-4"
- iconClassName="size-3.5"
- />
- ) : (
- <span className="text-content-subtle text-xs">
- No rewards
- </span>
- )
- ) : (
- <div className="h-4 w-32 animate-pulse rounded bg-neutral-200" />
- )}
- </div>
- {/* Eligible bounties */}
- <div className="flex flex-col gap-2">
- <h3 className="text-content-emphasis text-sm font-semibold">
- Eligible Bounties
- </h3>
- {bounties ? (
- bounties.length ? (
- <div className="flex flex-col gap-2">
- {bounties.map((bounty) => {
- const Icon =
- bounty.type === "performance" ? Trophy : Heart;
- return (
- <Link
- key={bounty.id}
- target="_blank"
- href={`/${workspaceSlug}/program/bounties/${bounty.id}`}
- className="text-content-subtle flex cursor-alias items-center gap-2 decoration-dotted underline-offset-2 hover:underline"
- >
- <Icon className="size-3.5 shrink-0" />
- <span className="text-xs font-medium">
- {bounty.name}
- </span>
- </Link>
- );
- })}
- </div>
+ {isEnrolled && partner?.status === "approved" && (
+ <>
+ {/* Rewards */}
+ <div className="flex flex-col gap-2">
+ <h3 className="text-content-emphasis text-sm font-semibold">
+ Rewards
+ </h3>
+ {group ? (
+ group.clickReward ||
+ group.leadReward ||
+ group.saleReward ||
+ group.discount ? (
+ <ProgramRewardList
+ rewards={[
+ group.clickReward,
+ group.leadReward,
+ group.saleReward,
+ ].filter((r): r is RewardProps => r !== null)}
+ discount={group.discount}
+ variant="plain"
+ className="text-content-subtle gap-2 text-xs leading-4"
+ iconClassName="size-3.5"
+ />
+ ) : (
+ <span className="text-content-subtle text-xs">
+ No rewards
+ </span>
+ )
) : (
+ <div className="h-4 w-32 animate-pulse rounded bg-neutral-200" />
+ )}
+ </div>
+ {/* Eligible bounties */}
+ <div className="flex flex-col gap-2">
+ <h3 className="text-content-emphasis text-sm font-semibold">
+ Eligible Bounties
+ </h3>
+ {bounties ? (
+ bounties.length ? (
+ <div className="flex flex-col gap-2">
+ {bounties.map((bounty) => {
+ const Icon =
+ bounty.type === "performance" ? Trophy : Heart;
+ return (
+ <Link
+ key={bounty.id}
+ target="_blank"
+ href={`/${workspaceSlug}/program/bounties/${bounty.id}`}
+ className="text-content-subtle flex cursor-alias items-center gap-2 decoration-dotted underline-offset-2 hover:underline"
+ >
+ <Icon className="size-3.5 shrink-0" />
+ <span className="text-xs font-medium">
+ {bounty.name}
+ </span>
+ </Link>
+ );
+ })}
+ </div>
+ ) : (
+ <p className="text-content-subtle text-xs">
+ No eligible bounties
+ </p>
+ )
+ ) : errorBounties ? (
<p className="text-content-subtle text-xs">
- No eligible bounties
+ Failed to load bounties
</p>
- )
- ) : errorBounties ? (
- <p className="text-content-subtle text-xs">
- Failed to load bounties
- </p>
- ) : (
- <div className="h-4 w-24 animate-pulse rounded bg-neutral-200" />
- )}
- </div>
- </>
- )}
- </div>
+ ) : (
+ <div className="h-4 w-24 animate-pulse rounded bg-neutral-200" />
+ )}
+ </div>
+ </>
+ )}
+ </div>
+ )}
</div>
);
}
diff --git a/apps/web/ui/partners/partner-network/network-status-badges.ts b/apps/web/ui/partners/partner-network/network-status-badges.ts
new file mode 100644
index 0000000000..9ee854af2e
--- /dev/null
+++ b/apps/web/ui/partners/partner-network/network-status-badges.ts
@@ -0,0 +1,54 @@
+import {
+ CircleCheck,
+ CircleHalfDottedCheck,
+ CircleHalfDottedClock,
+ CircleXmark,
+} from "@dub/ui/icons";
+
+export const NetworkStatusBadges = {
+ draft: {
+ partnerTooltip: {
+ content:
+ "Submit your application to join the Dub Partner Network. After approval, you can then apply to this program.",
+ cta: "Submit application",
+ },
+ label: "Draft",
+ variant: "pending",
+ className: "bg-bg-attention text-content-attention",
+ icon: CircleHalfDottedClock,
+ },
+ submitted: {
+ partnerTooltip: {
+ content:
+ "Your Dub Partner Network application is under review. You'll be able to apply to this program once approved.",
+ cta: "Pending approval",
+ },
+ label: "Submitted",
+ variant: "new",
+ className: "bg-bg-info text-content-info",
+ icon: CircleHalfDottedCheck,
+ },
+ rejected: {
+ partnerTooltip: {
+ content: "Your Dub Partner Network application was rejected.",
+ cta: "Rejected",
+ },
+ label: "Rejected",
+ variant: "error",
+ className: "bg-bg-error text-content-error",
+ icon: CircleXmark,
+ },
+ // not show in partner tooltip
+ approved: {
+ label: "Approved",
+ variant: "success",
+ className: "bg-bg-success text-content-success",
+ icon: CircleCheck,
+ },
+ trusted: {
+ label: "Trusted",
+ variant: "success",
+ className: "bg-bg-success text-content-success",
+ icon: CircleCheck,
+ },
+};
diff --git a/apps/web/ui/partners/partner-social-column.tsx b/apps/web/ui/partners/partner-social-column.tsx
index a0af68f06a..f1f7fb76c6 100644
--- a/apps/web/ui/partners/partner-social-column.tsx
+++ b/apps/web/ui/partners/partner-social-column.tsx
@@ -1,6 +1,6 @@
import { PartnerPlatformProps } from "@/lib/types";
import { PlatformType } from "@dub/prisma/client";
-import { BadgeCheck2Fill, Tooltip } from "@dub/ui";
+import { BadgeCheck2Fill, TimestampTooltip } from "@dub/ui";
import { getDomainWithoutWWW } from "@dub/utils";
const PLATFORMS_WITH_AT: PlatformType[] = [
@@ -14,7 +14,10 @@ export function PartnerSocialColumn({
platform,
platformName,
}: {
- platform: PartnerPlatformProps | null | undefined;
+ platform:
+ | Pick<PartnerPlatformProps, "identifier" | "verifiedAt">
+ | null
+ | undefined;
platformName: PlatformType;
}) {
if (!platform?.identifier) {
@@ -35,11 +38,17 @@ export function PartnerSocialColumn({
{value}
</span>
{verified && (
- <Tooltip content="Verified" disableHoverableContent>
+ <TimestampTooltip
+ timestamp={platform.verifiedAt}
+ rows={["local", "utc", "unix"]}
+ side="top"
+ prefix="Verified"
+ delayDuration={150}
+ >
<div>
<BadgeCheck2Fill className="size-4 text-green-600" />
</div>
- </Tooltip>
+ </TimestampTooltip>
)}
</div>
);
diff --git a/packages/email/src/templates/network-partner-application-approved.tsx b/packages/email/src/templates/network-partner-application-approved.tsx
new file mode 100644
index 0000000000..cb06a6025e
--- /dev/null
+++ b/packages/email/src/templates/network-partner-application-approved.tsx
@@ -0,0 +1,89 @@
+import { DUB_WORDMARK } from "@dub/utils";
+import {
+ Body,
+ Container,
+ Head,
+ Heading,
+ Html,
+ Img,
+ Link,
+ Preview,
+ Section,
+ Tailwind,
+ Text,
+} from "@react-email/components";
+import { Footer } from "../components/footer";
+
+export default function NetworkPartnerApplicationApproved({
+ name,
+ email = "[email protected]",
+}: {
+ name?: string | null;
+ email: string;
+}) {
+ return (
+ <Html>
+ <Head />
+ <Preview>
+ Your application to join the Dub Network has been approved.
+ </Preview>
+ <Tailwind>
+ <Body className="mx-auto my-auto bg-white font-sans">
+ <Container className="email-container mx-auto my-10 max-w-[600px] px-10 py-5">
+ <Section className="mt-2 text-center">
+ <Img
+ src={DUB_WORDMARK}
+ width="65"
+ height="32"
+ alt="Dub"
+ style={{
+ display: "block",
+ margin: "0 auto",
+ }}
+ />
+ </Section>
+
+ <Section className="mb-8 mt-8 text-center">
+ <Img
+ src="https://assets.dub.co/misc/program-marketplace-email-header.jpg"
+ width="500"
+ height="292"
+ alt="Dub Program Marketplace"
+ style={{
+ display: "block",
+ maxWidth: "100%",
+ height: "auto",
+ margin: "0 auto",
+ }}
+ />
+ </Section>
+
+ <Heading className="mx-0 mb-4 mt-0 p-0 text-center text-2xl font-semibold text-black">
+ Congratulations{name ? `, ${name}!` : "!"}
+ </Heading>
+
+ <Text className="mx-auto mb-4 mt-0 max-w-[420px] text-center text-base leading-7 text-neutral-600">
+ Your application to join the <strong>Dub Network</strong> has been
+ approved. You can now apply to more programs on the marketplace,
+ and get discovered by brands.
+ </Text>
+
+ <Section className="mb-8 text-center">
+ <Link
+ href="https://partners.dub.co/programs/marketplace"
+ className="box-border inline-block rounded-lg bg-neutral-900 px-6 py-3 text-center text-sm font-medium text-white no-underline"
+ >
+ View the marketplace
+ </Link>
+ </Section>
+
+ <Footer
+ email={email}
+ notificationSettingsUrl="https://partners.dub.co/profile/notifications"
+ />
+ </Container>
+ </Body>
+ </Tailwind>
+ </Html>
+ );
+}
diff --git a/packages/email/src/templates/network-partner-application-rejected.tsx b/packages/email/src/templates/network-partner-application-rejected.tsx
new file mode 100644
index 0000000000..b4a4bf31ef
--- /dev/null
+++ b/packages/email/src/templates/network-partner-application-rejected.tsx
@@ -0,0 +1,73 @@
+import { DUB_WORDMARK } from "@dub/utils";
+import {
+ Body,
+ Container,
+ Head,
+ Heading,
+ Html,
+ Img,
+ Link,
+ Preview,
+ Section,
+ Tailwind,
+ Text,
+} from "@react-email/components";
+import { Footer } from "../components/footer";
+
+export default function NetworkPartnerApplicationRejected({
+ name,
+ email = "[email protected]",
+}: {
+ name?: string | null;
+ email: string;
+}) {
+ return (
+ <Html>
+ <Head />
+ <Preview>Dub Partner Network application update</Preview>
+ <Tailwind>
+ <Body className="mx-auto my-auto bg-white font-sans">
+ <Container className="mx-auto my-8 max-w-[600px] px-8 py-8">
+ <Section className="mt-2">
+ <Img src={DUB_WORDMARK} width="61" height="32" alt="Dub" />
+ </Section>
+
+ <Heading className="mx-0 mb-8 mt-10 p-0 text-xl font-semibold text-neutral-900">
+ Dub Partner Network application update
+ </Heading>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ {name ? `Hi ${name}, t` : "T"}hanks for your interest in joining
+ the <strong>Dub Partner Network</strong>.
+ </Text>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ After a thorough review, we're sorry to say that we are unable to
+ approve your application at this time.
+ </Text>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ Unfortunately, we cannot provide individual feedback about your
+ application. We encourage you to keep improving on your profile
+ and reapply in the future.
+ </Text>
+
+ <Section className="mb-10 mt-8">
+ <Link
+ className="rounded-lg bg-neutral-900 px-6 py-3 text-[13px] font-medium text-white no-underline"
+ href="https://partners.dub.co"
+ >
+ View dashboard
+ </Link>
+ </Section>
+
+ <Footer
+ email={email}
+ notificationSettingsUrl="https://partners.dub.co/profile/notifications"
+ />
+ </Container>
+ </Body>
+ </Tailwind>
+ </Html>
+ );
+}
diff --git a/packages/email/src/templates/network-partner-application-submitted.tsx b/packages/email/src/templates/network-partner-application-submitted.tsx
new file mode 100644
index 0000000000..08e8cbe707
--- /dev/null
+++ b/packages/email/src/templates/network-partner-application-submitted.tsx
@@ -0,0 +1,73 @@
+import { DUB_WORDMARK } from "@dub/utils";
+import {
+ Body,
+ Container,
+ Head,
+ Heading,
+ Html,
+ Img,
+ Link,
+ Preview,
+ Section,
+ Tailwind,
+ Text,
+} from "@react-email/components";
+import { Footer } from "../components/footer";
+
+export default function NetworkPartnerApplicationSubmitted({
+ name,
+ email = "[email protected]",
+}: {
+ name?: string | null;
+ email: string;
+}) {
+ return (
+ <Html>
+ <Head />
+ <Preview>Dub Partner Network application submitted</Preview>
+ <Tailwind>
+ <Body className="mx-auto my-auto bg-white font-sans">
+ <Container className="mx-auto my-8 max-w-[600px] px-8 py-8">
+ <Section className="mt-2">
+ <Img src={DUB_WORDMARK} width="61" height="32" alt="Dub" />
+ </Section>
+
+ <Heading className="mx-0 mb-8 mt-10 p-0 text-xl font-semibold text-neutral-900">
+ Dub Partner Network application submitted
+ </Heading>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ {name ? `Hi ${name}, t` : "T"}hanks for applying to the{" "}
+ <strong>Dub Partner Network</strong>!
+ </Text>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ Your application is now under review, and you are one step closer
+ to partnering with world-class companies like Framer, Superhuman,
+ Beehiiv, and many more.
+ </Text>
+
+ <Text className="text-sm leading-6 text-neutral-600">
+ We will review your application within 5 to 7 business days, and
+ you will receive an email after review.
+ </Text>
+
+ <Section className="mb-10 mt-8">
+ <Link
+ className="rounded-lg bg-neutral-900 px-6 py-3 text-[13px] font-medium text-white no-underline"
+ href="https://partners.dub.co"
+ >
+ View dashboard
+ </Link>
+ </Section>
+
+ <Footer
+ email={email}
+ notificationSettingsUrl="https://partners.dub.co/profile/notifications"
+ />
+ </Container>
+ </Body>
+ </Tailwind>
+ </Html>
+ );
+}
diff --git a/packages/prisma/schema/application.prisma b/packages/prisma/schema/application.prisma
index fd4c757787..11c60e4cbf 100644
--- a/packages/prisma/schema/application.prisma
+++ b/packages/prisma/schema/application.prisma
@@ -39,7 +39,7 @@ model ProgramApplication {
}
model ProgramApplicationEvent {
- id String @id @default(cuid())
+ id String @id @default(cuid())
programId String
visitedAt DateTime @default(now())
diff --git a/packages/prisma/schema/partner.prisma b/packages/prisma/schema/partner.prisma
index 5dac85ef84..1f022d36ba 100644
--- a/packages/prisma/schema/partner.prisma
+++ b/packages/prisma/schema/partner.prisma
@@ -8,6 +8,14 @@ enum PartnerProfileType {
company
}
+enum PartnerNetworkStatus {
+ draft
+ submitted
+ approved
+ rejected
+ trusted
+}
+
enum MonthlyTraffic {
ZeroToOneThousand
OneThousandToTenThousand
@@ -35,15 +43,16 @@ enum IdentityVerificationStatus {
}
model Partner {
- id String @id @default(cuid())
- name String
- username String? @unique
- companyName String?
- profileType PartnerProfileType @default(individual)
- email String? @unique
- image String? @db.Text
- description String? @db.Text
- country String?
+ id String @id @default(cuid())
+ name String
+ username String? @unique
+ email String? @unique
+ image String? @db.Text
+ description String? @db.Text
+ country String?
+ companyName String?
+ profileType PartnerProfileType @default(individual)
+ networkStatus PartnerNetworkStatus @default(draft)
// identity verification fields
identityVerificationStatus IdentityVerificationStatus?
@@ -62,10 +71,12 @@ model Partner {
cryptoWalletAddress String?
// timestamp fields
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
- discoverableAt DateTime?
- trustedAt DateTime?
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+ discoverableAt DateTime?
+ submittedAt DateTime?
+ reviewedAt DateTime?
+ trustedAt DateTime?
// miscellaneous fields
invoiceSettings Json?
@@ -101,8 +112,10 @@ model Partner {
referredApplications ProgramApplicationEvent[]
@@index(country)
- @@index(discoverableAt)
- @@index(trustedAt)
+ @@index(networkStatus)
+ @@index(createdAt)
+ @@index(discoverableAt) // TODO: remove index once we fully migrate to networkStatus
+ @@index(trustedAt) // TODO: remove index once we fully migrate to networkStatus
@@index(payoutMethodHash)
@@index(cryptoWalletAddress)
@@index(identityVerifiedAt)
diff --git a/packages/prisma/schema/tag.prisma b/packages/prisma/schema/tag.prisma
index 403c7549a9..4ac77bc35a 100644
--- a/packages/prisma/schema/tag.prisma
+++ b/packages/prisma/schema/tag.prisma
@@ -54,4 +54,4 @@ model ProgramPartnerTag {
@@index(partnerId)
@@index([programId, partnerId])
@@index([partnerTagId, programId])
-}
\ No newline at end of file
+}
diff --git a/packages/ui/src/timestamp-tooltip.tsx b/packages/ui/src/timestamp-tooltip.tsx
index 5d4250337a..5ce38a90e2 100644
--- a/packages/ui/src/timestamp-tooltip.tsx
+++ b/packages/ui/src/timestamp-tooltip.tsx
@@ -13,6 +13,7 @@ export type TimestampTooltipProps = {
timestamp: Date | string | number | null | undefined;
rows?: ("local" | "utc" | "unix")[];
interactive?: boolean;
+ prefix?: string;
className?: string;
} & Omit<TooltipProps, "content">;
@@ -29,6 +30,7 @@ export function TimestampTooltip({
timestamp,
rows,
interactive = true,
+ prefix,
...tooltipProps
}: TimestampTooltipProps) {
if (!timestamp || new Date(timestamp).toString() === "Invalid Date")
@@ -41,6 +43,7 @@ export function TimestampTooltip({
timestamp={timestamp}
rows={rows}
interactive={interactive}
+ prefix={prefix}
/>
}
disableHoverableContent={!interactive}
@@ -53,7 +56,11 @@ function TimestampTooltipContent({
timestamp,
rows = ["local", "utc"],
interactive,
-}: Pick<TimestampTooltipProps, "timestamp" | "rows" | "interactive">) {
+ prefix,
+}: Pick<
+ TimestampTooltipProps,
+ "timestamp" | "rows" | "interactive" | "prefix"
+>) {
if (!timestamp)
throw new Error("Falsy timestamp not permitted in TimestampTooltipContent");
@@ -145,7 +152,10 @@ function TimestampTooltipContent({
return (
<div className="flex max-w-[360px] flex-col gap-2 px-2.5 py-2 text-left text-xs">
{diff > 0 && (
- <span className="text-content-subtle cursor-default">{relative}</span>
+ <span className="text-content-subtle cursor-default">
+ {prefix ? `${prefix} ` : ""}
+ {relative}
+ </span>
)}
<table>
<tbody>
diff --git a/packages/utils/src/constants/reserved-slugs.ts b/packages/utils/src/constants/reserved-slugs.ts
index 576e39e373..7fa2974771 100644
--- a/packages/utils/src/constants/reserved-slugs.ts
+++ b/packages/utils/src/constants/reserved-slugs.ts
@@ -5,6 +5,7 @@
*/
export const RESERVED_SLUGS = [
+ "dub",
"va",
"static",
"stats",