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.

Update overview UI

Tim Wilsonf6552157098a
diff --git a/apps/web/app/api/partners/[partnerId]/programs/[programId]/route.ts b/apps/web/app/api/partners/[partnerId]/programs/[programId]/route.ts
index 1ab8b55c6b..d4f4ac76c3 100644
--- a/apps/web/app/api/partners/[partnerId]/programs/[programId]/route.ts
+++ b/apps/web/app/api/partners/[partnerId]/programs/[programId]/route.ts
@@ -15,6 +15,7 @@ export const GET = withPartner(async ({ partner, params }) => {
},
include: {
link: true,
+ program: true,
},
});
diff --git a/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/[programId]/hero-background.tsx b/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/[programId]/hero-background.tsx
new file mode 100644
index 0000000000..dfcbdebeb8
--- /dev/null
+++ b/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/[programId]/hero-background.tsx
@@ -0,0 +1,34 @@
+import { Logo } from "@dub/ui";
+import Image from "next/image";
+
+const heroGradient =
+ "conic-gradient(from 45deg at 65% 70%, #855AFC 0deg, #3A8BFD 72deg, #00FFF9 144deg, #5CFF80 197.89deg, #855AFC 260.96deg, #FF0000 360deg)";
+
+export function HeroBackground() {
+ return (
+ <div className="pointer-events-none absolute inset-0 [mask-image:radial-gradient(100%_100%_at_top_right,black,transparent)] max-[350px]:opacity-50 sm:[mask-image:linear-gradient(to_right,transparent_50%,black_70%)]">
+ <div className="absolute -right-[60px] top-[40px] isolate w-[600px] -translate-y-1/2 overflow-hidden bg-white sm:-right-[60px] sm:top-1/2 sm:w-[1200px] md:right-0">
+ <div
+ className="absolute -inset-[50%] opacity-15 blur-[100px]"
+ style={{
+ backgroundImage: heroGradient,
+ }}
+ />
+ <Image
+ src="https://assets.dub.co/misc/referrals-hero-background.svg"
+ alt="Refer and earn"
+ width={1200}
+ height={630}
+ className="relative"
+ />
+ <div
+ className="absolute -inset-[50%] mix-blend-soft-light blur-[100px]"
+ style={{
+ backgroundImage: heroGradient,
+ }}
+ />
+ <Logo className="absolute right-[9.9%] top-[49.9%] size-10 -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-full bg-white sm:size-20 sm:drop-shadow-lg" />
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/[programId]/page-client.tsx b/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/[programId]/page-client.tsx
index 5daa63c458..69662c0646 100644
--- a/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/[programId]/page-client.tsx
+++ b/apps/web/app/partners.dub.co/(dashboard)/[partnerId]/[programId]/page-client.tsx
@@ -22,18 +22,25 @@ import {
useRouterStuff,
useTable,
} from "@dub/ui";
-import { CircleDollar, Copy, LoadingSpinner } from "@dub/ui/src/icons";
+import {
+ CircleDollar,
+ Copy,
+ LoadingSpinner,
+ MoneyBill2,
+} from "@dub/ui/src/icons";
import {
currencyFormatter,
formatDate,
getPrettyUrl,
nFormatter,
+ pluralize,
} from "@dub/utils";
import { LinearGradient } from "@visx/gradient";
import { endOfDay, startOfDay, subDays } from "date-fns";
import Link from "next/link";
import { useParams } from "next/navigation";
import { createContext, useContext, useId, useMemo } from "react";
+import { HeroBackground } from "./hero-background";
const ProgramOverviewContext = createContext<{
start?: Date;
@@ -66,24 +73,58 @@ export default function ProgramPageClient() {
const interval =
start || end ? undefined : searchParams?.get("interval") ?? "30d";
+ const program = programEnrollment?.program;
+
return (
<MaxWidthWrapper className="pb-10">
- <div className="flex flex-col items-start justify-between gap-4 rounded-lg border border-neutral-300 bg-neutral-50 p-4 sm:flex-row sm:items-center md:p-8">
- <div>
- <span className="block text-xl font-medium leading-none text-neutral-900">
- Referral link
- </span>
- <p className="mt-2 text-sm text-neutral-500">
- Track events and conversions when using your referral link
- </p>
+ <div className="relative flex flex-col rounded-lg border border-neutral-300 bg-neutral-50 p-4 md:p-6">
+ <HeroBackground />
+ <span className="flex items-center gap-2 text-sm text-neutral-500">
+ <MoneyBill2 className="size-4" />
+ Refer and earn
+ </span>
+ <div className="mt-24 text-lg text-neutral-900 sm:max-w-[50%]">
+ {program ? (
+ <>
+ Earn{" "}
+ <strong className="font-semibold">
+ {program.commissionType === "percentage"
+ ? program.commissionAmount * 100 + "%"
+ : currencyFormatter(program.commissionAmount / 100, {
+ minimumFractionDigits: 2,
+ maximumFractionDigits: 2,
+ })}{" "}
+ </strong>
+ for each conversion
+ {program.recurringCommission &&
+ (program.recurringDuration > 0 || program.isLifetimeRecurring) ? (
+ <>
+ , and again{" "}
+ <strong className="font-semibold">
+ every {program.recurringInterval || "cycle"} for{" "}
+ {program.isLifetimeRecurring
+ ? "the customer's lifetime."
+ : `${program.recurringDuration} ${pluralize(program.recurringInterval || "cycle", program.recurringDuration)}.`}
+ </strong>
+ </>
+ ) : (
+ "."
+ )}
+ </>
+ ) : (
+ <div className="mb-7 h-7 w-full animate-pulse rounded-md bg-neutral-200" />
+ )}
</div>
- <div className="flex items-center gap-2">
+ <span className="mb-1.5 mt-6 block text-sm text-neutral-800">
+ Referral link
+ </span>
+ <div className="xs:flex-row flex flex-col items-center gap-2">
{programEnrollment?.link ? (
<input
type="text"
readOnly
value={getPrettyUrl(programEnrollment?.link.shortLink)}
- className="h-10 rounded-md border border-neutral-300 px-3 text-sm focus:border-gray-500 focus:outline-none focus:ring-gray-500 lg:min-w-72"
+ className="xs:w-auto h-10 w-full rounded-md border border-neutral-300 px-3 text-sm focus:border-gray-500 focus:outline-none focus:ring-gray-500 lg:min-w-72"
/>
) : (
<div className="h-10 w-16 animate-pulse rounded-md bg-neutral-200 lg:w-72" />
@@ -97,7 +138,7 @@ export default function ProgramPageClient() {
)
}
text={copied ? "Copied link" : "Copy link"}
- className="w-fit"
+ className="xs:w-fit"
onClick={() =>
copyToClipboard(getPrettyUrl(programEnrollment?.link?.shortLink))
}
diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.ts
index f3eba7692e..f50f87e439 100644
--- a/apps/web/lib/zod/schemas/partners.ts
+++ b/apps/web/lib/zod/schemas/partners.ts
@@ -1,4 +1,9 @@
-import { CommissionType, PartnerStatus, ProgramType } from "@prisma/client";
+import {
+ CommissionInterval,
+ CommissionType,
+ PartnerStatus,
+ ProgramType,
+} from "@prisma/client";
import { z } from "zod";
import { LinkSchema } from "./links";
@@ -25,6 +30,7 @@ export const ProgramSchema = z.object({
commissionType: z.nativeEnum(CommissionType),
recurringCommission: z.boolean(),
recurringDuration: z.number(),
+ recurringInterval: z.nativeEnum(CommissionInterval).nullable(),
isLifetimeRecurring: z.boolean(),
createdAt: z.date(),
updatedAt: z.date(),
@@ -42,6 +48,7 @@ export const ProgramEnrollmentSchema = z.object({
sales: true,
saleAmount: true,
}).nullable(),
+ program: ProgramSchema,
createdAt: z.date(),
updatedAt: z.date(),
});
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index 2e7efe4ed5..a5d91c60a4 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -85,6 +85,7 @@ export * from "./magnifier";
export * from "./map-position";
export * from "./menu3";
export * from "./mobile-phone";
+export * from "./money-bill2";
export * from "./money-bills2";
export * from "./note";
export * from "./office-building";
diff --git a/packages/ui/src/icons/nucleo/money-bill2.tsx b/packages/ui/src/icons/nucleo/money-bill2.tsx
new file mode 100644
index 0000000000..940ec7290f
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/money-bill2.tsx
@@ -0,0 +1,34 @@
+import { SVGProps } from "react";
+
+export function MoneyBill2(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ height="18"
+ width="18"
+ viewBox="0 0 18 18"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ >
+ <g fill="currentColor">
+ <circle
+ cx="9"
+ cy="9"
+ fill="none"
+ r="2"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M1.75,13.75V4.25c2.396,1.074,4.568,1.221,7.25,0s4.854-1.25,7.25,0V13.75c-2.396-1.25-4.568-1.221-7.25,0s-4.854,1.074-7.25,0Z"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ </g>
+ </svg>
+ );
+}