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 program links

Tim Wilson1cb68c14c9b4
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/overview-links.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/overview-links.tsx
new file mode 100644
index 0000000000..032b13d732
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/overview-links.tsx
@@ -0,0 +1,112 @@
+import useProgram from "@/lib/swr/use-program";
+import useWorkspace from "@/lib/swr/use-workspace";
+import { ProgramOverviewCard } from "@/ui/partners/program-overview-card";
+import { ButtonLink } from "@/ui/placeholders/button-link";
+import {
+ ArrowUpRight,
+ Brush,
+ Copy,
+ InputField,
+ Post,
+ useCopyToClipboard,
+ Window,
+} from "@dub/ui";
+import { cn, PARTNERS_DOMAIN } from "@dub/utils";
+import Link from "next/link";
+import { useMemo } from "react";
+import { toast } from "sonner";
+
+export function OverviewLinks() {
+ const { slug } = useWorkspace();
+ const { program } = useProgram();
+
+ const [_, copyToClipboard] = useCopyToClipboard();
+
+ const links = useMemo(
+ () => [
+ {
+ icon: Post,
+ label: "Landing page",
+ href: `${PARTNERS_DOMAIN}/${program?.slug}`,
+ disabled: !program?.landerPublishedAt,
+ },
+ {
+ icon: InputField,
+ label: "Application page",
+ href: `${PARTNERS_DOMAIN}/${program?.slug}/apply`,
+ disabled: !program?.landerPublishedAt,
+ },
+ {
+ icon: Window,
+ label: "Partner portal",
+ href: `${PARTNERS_DOMAIN}`,
+ },
+ ],
+ [slug, program],
+ );
+
+ return (
+ <ProgramOverviewCard className="py-4">
+ <div className="flex justify-between px-4">
+ <h2 className="text-content-emphasis text-sm font-medium">
+ Program links
+ </h2>
+ <ButtonLink
+ href={`/${slug}/program/branding`}
+ variant="secondary"
+ className="-mr-1 -mt-1 h-7 px-2 text-sm"
+ >
+ <Brush className="mr-1.5 size-4 shrink-0" />
+ Branding
+ </ButtonLink>
+ </div>
+ <div className="mt-3 flex flex-col px-2">
+ {links.map((link) => (
+ <div
+ key={link.label}
+ className={cn(
+ "group relative",
+ link.disabled && "pointer-events-none opacity-50",
+ )}
+ >
+ <Link
+ key={link.label}
+ href={link.href}
+ target="_blank"
+ className={cn(
+ "relative flex items-center justify-between gap-2 rounded-lg p-2 pl-3 text-sm font-semibold transition-colors",
+ "group-hover:bg-bg-inverted/5 group-hover:active:bg-bg-inverted/10",
+ )}
+ aria-disabled={link.disabled}
+ >
+ <div className="flex min-w-0 items-center gap-2.5">
+ <link.icon className="size-4 shrink-0" />
+ <span className="min-w-0 truncate">{link.label}</span>
+ <ArrowUpRight className="size-3 shrink-0 -translate-x-0.5 opacity-0 transition-[transform,opacity] group-hover:translate-x-0 group-hover:opacity-100 [&_*]:stroke-2" />
+ </div>
+
+ <div className="h-8 w-12" />
+ </Link>
+ <button
+ type="button"
+ onClick={() =>
+ copyToClipboard(link.href, {
+ onSuccess: () => {
+ toast.success("Copied to clipboard");
+ },
+ })
+ }
+ className={cn(
+ "text-content-default bg-bg-inverted/5 absolute right-2 top-1/2 flex h-8 -translate-y-1/2 items-center rounded-lg px-4 transition-[opacity,background-color]",
+ "opacity-0 focus-visible:opacity-100 group-hover:opacity-100",
+ "hover:bg-bg-inverted/10 active:bg-bg-inverted/15",
+ )}
+ >
+ <Copy className="size-4" />
+ </button>
+ </div>
+ ))}
+ </div>
+ </ProgramOverviewCard>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx
index 9f28963382..9c0c18a87a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx
@@ -13,6 +13,7 @@ import { fetcher } from "@dub/utils";
import { useMemo } from "react";
import useSWR from "swr";
import { OverviewChart } from "./overview-chart";
+import { OverviewLinks } from "./overview-links";
import { OverviewTasks } from "./overview-tasks";
export default function ProgramOverviewPageClient() {
@@ -81,7 +82,7 @@ export default function ProgramOverviewPageClient() {
<OverviewTasks />
{/* Program links */}
- <div className="border-border-subtle h-48 rounded-[0.625rem] border bg-white"></div>
+ <OverviewLinks />
</div>
</div>
<div className="@2xl:grid-cols-2 @4xl:grid-cols-3 grid grid-cols-1 gap-6">
diff --git a/apps/web/lib/zod/schemas/programs.ts b/apps/web/lib/zod/schemas/programs.ts
index 5a79e44cad..e99884ea80 100644
--- a/apps/web/lib/zod/schemas/programs.ts
+++ b/apps/web/lib/zod/schemas/programs.ts
@@ -28,6 +28,7 @@ export const ProgramSchema = z.object({
minPayoutAmount: z.number(),
linkStructure: z.nativeEnum(LinkStructure),
linkParameter: z.string().nullish(),
+ landerPublishedAt: z.date().nullish(),
// Discounts (for dual-sided incentives)
discounts: z.array(DiscountSchema).nullish(),
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index f3cedfa6b6..7886f54bc9 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -127,6 +127,7 @@ export * from "./history";
export * from "./hyperlink";
export * from "./icosahedron";
export * from "./incognito";
+export * from "./input-field";
export * from "./input-password";
export * from "./input-password-pointer";
export * from "./input-search";
diff --git a/packages/ui/src/icons/nucleo/input-field.tsx b/packages/ui/src/icons/nucleo/input-field.tsx
new file mode 100644
index 0000000000..0af3b1136c
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/input-field.tsx
@@ -0,0 +1,86 @@
+import { SVGProps } from "react";
+
+export function InputField(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">
+ <path
+ d="M11.25,13.25H3.75c-1.105,0-2-.895-2-2V6.75c0-1.105,.895-2,2-2h7.5"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M14,4.75h.25c1.105,0,2,.895,2,2v4.5c0,1.105-.895,2-2,2h-.25"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M9.25,1.75c1.105,0,2,.895,2,2"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M13.25,1.75c-1.105,0-2,.895-2,2"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M9.25,16.25c1.105,0,2-.895,2-2"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <path
+ d="M13.25,16.25c-1.105,0-2-.895-2-2"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="11.25"
+ x2="11.25"
+ y1="3.75"
+ y2="14.25"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="9.75"
+ x2="12.75"
+ y1="9.75"
+ y2="9.75"
+ />
+ </g>
+ </svg>
+ );
+}