The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add coupon code support to PartnerLinkCard and update schemas
Kiran K460ad471e194
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsxindex 11f7c71712..9a6b409f34 100644--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-card.tsx@@ -15,6 +15,8 @@ import {LinkLogo,LoadingSpinner,PenWriting,+ Tag,+ useCopyToClipboard,useInViewport,UserCheck,useRouterStuff,@@ -24,6 +26,7 @@ import { cn, getApexDomain, getPrettyUrl } from "@dub/utils";import NumberFlow from "@number-flow/react";import Link from "next/link";import { ComponentProps, useMemo, useRef } from "react";+import { toast } from "sonner";import { usePartnerLinksContext } from "./page-client";const CHARTS = [@@ -109,6 +112,8 @@ export function PartnerLinkCard({ link }: { link: PartnerProfileLinkProps }) {linkKey: link.key,});+ const [copied, copyToClipboard] = useCopyToClipboard();+return (<CardList.CardinnerClassName="px-0 py-0 hover:cursor-pointer group"@@ -132,24 +137,48 @@ export function PartnerLinkCard({ link }: { link: PartnerProfileLinkProps }) {<div className="flex min-w-0 flex-col"><div className="flex flex-col">- <div className="group/shortlink relative flex w-fit items-center gap-1 py-0 pl-1 pr-1.5 transition-colors duration-150 hover:rounded-lg hover:bg-neutral-100">- <a- href={partnerLink}- target="_blank"- rel="noopener noreferrer"- className="truncate text-sm font-semibold leading-6 text-neutral-700 transition-colors hover:text-black"- >- {getPrettyUrl(partnerLink)}- </a>- <span className="flex items-center">- <CopyButton- value={partnerLink}- variant="neutral"- className="p-0.5 opacity-0 transition-opacity duration-150 group-hover/shortlink:opacity-100"- />- </span>+ <div className="flex items-center gap-1">+ <div className="group/shortlink relative flex w-fit items-center gap-1 py-0 pl-1 pr-1.5 transition-colors duration-150 hover:rounded-lg hover:bg-neutral-100">+ <a+ href={partnerLink}+ target="_blank"+ rel="noopener noreferrer"+ className="truncate text-sm font-semibold leading-6 text-neutral-700 transition-colors hover:text-black"+ >+ {getPrettyUrl(partnerLink)}+ </a>+ <span className="flex items-center">+ <CopyButton+ value={partnerLink}+ variant="neutral"+ className="p-0.5 opacity-0 transition-opacity duration-150 group-hover/shortlink:opacity-100"+ />+ </span>+ </div>+{link.comments && <CommentsBadge comments={link.comments} />}++ {link.couponCode && (+ <button+ className="relative flex h-5 w-fit items-center gap-1 rounded-lg bg-green-100 py-0 pl-1 pr-1.5"+ onClick={(e) => {+ e.stopPropagation();+ toast.promise(copyToClipboard(link.couponCode!), {+ success: "Copied to clipboard",+ });+ }}+ >+ <Tag+ className="size-3 text-green-700"+ strokeWidth={1.5}+ />+ <div className="text-xs font-medium text-green-700 transition-colors">+ {link.couponCode}+ </div>+ </button>+ )}</div>+{/* The max width implementation here is a bit hacky, we should improve in the future */}<div className="group/desturl flex max-w-[100px] items-center gap-1 py-0 pl-1 pr-1.5 transition-colors duration-150 hover:rounded-lg hover:bg-neutral-100 sm:w-fit sm:max-w-[400px]"><ArrowTurnRight2 className="h-3 w-3 shrink-0 text-neutral-400" />diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.tsindex a0e613d4a4..db07a6a1f1 100644--- a/apps/web/lib/zod/schemas/links.ts+++ b/apps/web/lib/zod/schemas/links.ts@@ -695,6 +695,12 @@ export const LinkSchema = z.number().default(0).describe("The number of leads that converted to paying customers."),+ couponCode: z+ .string()+ .nullable()+ .describe(+ "The Stripe coupon code linked to this partner link, used for coupon code-based tracking.",+ ),sales: z.number().default(0)@@ -707,7 +713,6 @@ export const LinkSchema = z.describe("The total dollar value of sales (in cents) generated by the short link.",),-lastClicked: z.string().nullable()diff --git a/apps/web/lib/zod/schemas/partner-profile.ts b/apps/web/lib/zod/schemas/partner-profile.tsindex 662c0ccc31..0c5d1ea0b7 100644--- a/apps/web/lib/zod/schemas/partner-profile.ts+++ b/apps/web/lib/zod/schemas/partner-profile.ts@@ -82,6 +82,7 @@ export const PartnerProfileLinkSchema = LinkSchema.pick({sales: true,saleAmount: true,comments: true,+ couponCode: true,}).extend({createdAt: z.string().or(z.date()),});