The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Application terms and conditions addtion (#3399)
Marcus Farrell23d042b227c9
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-help-and-support.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-help-and-support.tsxindex 22c5e7cbd1..c99731dce6 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-help-and-support.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/resources/program-help-and-support.tsx@@ -52,6 +52,7 @@ export function ProgramHelpAndSupportContent({control,register,handleSubmit,+ getValues,formState: { isDirty, isValid, isSubmitting },} = useForm<FormData>({mode: "onBlur",@@ -67,6 +68,15 @@ export function ProgramHelpAndSupportContent({onSuccess: async () => {toast.success("Communication settings updated successfully.");await mutate(`/api/programs/${program?.id}?workspaceId=${workspaceId}`);++ // Notify other tabs (e.g., the application builder) that program data changed+ try {+ const channel = new BroadcastChannel("program-terms-updated");+ channel.postMessage({ termsUrl: getValues("termsUrl") || null });+ channel.close();+ } catch {+ // BroadcastChannel not supported, fall back to revalidateOnFocus+ }},onError: ({ error }) => {toast.error(diff --git a/apps/web/ui/partners/groups/design/application-form/modals/add-field-modal.tsx b/apps/web/ui/partners/groups/design/application-form/modals/add-field-modal.tsxindex dfd591e792..51b4616a50 100644--- a/apps/web/ui/partners/groups/design/application-form/modals/add-field-modal.tsx+++ b/apps/web/ui/partners/groups/design/application-form/modals/add-field-modal.tsx@@ -2,7 +2,6 @@import { programApplicationFormFieldSchema } from "@/lib/zod/schemas/program-application-form";import { Icon, Modal } from "@dub/ui";-import { cn } from "@dub/utils";import { Dispatch, Fragment, ReactNode, SetStateAction, useState } from "react";import { useWatch } from "react-hook-form";import * as z from "zod/v4";@@ -25,8 +24,8 @@ import {ShortTextFieldThumbnail,} from "./short-text-field-modal";import {- WebsiteAndSocialsFieldIcon,WebsiteAndSocialsFieldModal,+ WebsiteAndSocialsFieldThumbnail,} from "./website-and-socials-field-modal";type AddFieldModalProps = {@@ -40,6 +39,7 @@ export function AddFieldModal(props: AddFieldModalProps) {<ModalshowModal={props.showAddFieldModal}setShowModal={props.setShowAddFieldModal}+ className="max-w-2xl"><AddFieldModalInner {...props} /></Modal>@@ -51,7 +51,6 @@ export const DESIGNER_FIELDS: ({label: string;description: string;modal: React.ComponentType<any>;- fullWidth?: boolean;} & (| { icon: Icon; thumbnail?: never }| { thumbnail: ReactNode; icon?: never }@@ -90,15 +89,13 @@ export const DESIGNER_FIELDS: ({description: "Let applicants upload images",modal: ImageUploadFieldModal,thumbnail: <ImageUploadFieldThumbnail />,- fullWidth: true,},{id: "website-and-socials",label: "Website and socials",description: "Collect website and social media links",modal: WebsiteAndSocialsFieldModal,- icon: WebsiteAndSocialsFieldIcon,- fullWidth: true,+ thumbnail: <WebsiteAndSocialsFieldThumbnail />,},];@@ -130,7 +127,7 @@ function AddFieldModalInner({<h3 className="text-base font-semibold leading-6 text-neutral-800">Insert field</h3>- <div className="mt-4 grid grid-cols-2 gap-4">+ <div className="mt-4 grid grid-cols-2 gap-4 md:grid-cols-3">{fields.map((field) => (<Fragment key={field.id}><field.modal@@ -158,23 +155,14 @@ function AddFieldModalInner({<buttontype="button"onClick={() => setModalState(field.id)}- className={cn(- "flex rounded-md border border-transparent bg-neutral-100 p-4 text-left outline-none ring-black/10 transition-all duration-150 hover:border-neutral-800 hover:ring focus-visible:border-neutral-800",- field.fullWidth && "col-span-2 flex-row items-center gap-4",- !field.fullWidth && "flex-col gap-4",- )}+ className="flex flex-col gap-4 rounded-md border border-transparent bg-neutral-100 p-4 text-left outline-none ring-black/10 transition-all duration-150 hover:border-neutral-800 hover:ring focus-visible:border-neutral-800">{field.icon ? (<div className="flex size-12 items-center justify-center overflow-hidden rounded-md border border-neutral-200 bg-white"><field.icon className="size-5 text-neutral-600" /></div>) : (- <div- className={cn(- "flex items-center justify-center overflow-hidden rounded-md border border-neutral-200 bg-white",- field.fullWidth ? "size-12" : "h-24 w-full",- )}- >+ <div className="flex h-24 w-full items-center justify-center overflow-hidden rounded-md border border-neutral-200 bg-white">{field.thumbnail}</div>)}diff --git a/apps/web/ui/partners/groups/design/application-form/modals/image-upload-field-modal.tsx b/apps/web/ui/partners/groups/design/application-form/modals/image-upload-field-modal.tsxindex 5832e7e0f0..c3f62051f2 100644--- a/apps/web/ui/partners/groups/design/application-form/modals/image-upload-field-modal.tsx+++ b/apps/web/ui/partners/groups/design/application-form/modals/image-upload-field-modal.tsx@@ -258,7 +258,7 @@ export function ImageUploadFieldThumbnail() {viewBox="0 0 48 48"fill="none"xmlns="http://www.w3.org/2000/svg"- className="size-full"+ className="size-full p-4"><rect x="0.5" y="0.5" width="47" height="47" rx="5.5" fill="white" /><rect x="0.5" y="0.5" width="47" height="47" rx="5.5" stroke="#E5E5E5" />diff --git a/apps/web/ui/partners/groups/design/application-form/modals/website-and-socials-field-modal.tsx b/apps/web/ui/partners/groups/design/application-form/modals/website-and-socials-field-modal.tsxindex e2a2f20f8d..2136b5dcb1 100644--- a/apps/web/ui/partners/groups/design/application-form/modals/website-and-socials-field-modal.tsx+++ b/apps/web/ui/partners/groups/design/application-form/modals/website-and-socials-field-modal.tsx@@ -308,7 +308,7 @@ function SiteControl({);}-export function WebsiteAndSocialsFieldIcon() {+export function WebsiteAndSocialsFieldThumbnail() {return (<svgwidth="48"@@ -316,7 +316,7 @@ export function WebsiteAndSocialsFieldIcon() {viewBox="0 0 48 48"fill="none"xmlns="http://www.w3.org/2000/svg"- className="size-12"+ className="size-full p-4"><rect x="0.5" y="0.5" width="47" height="47" rx="5.5" fill="white" /><rect x="0.5" y="0.5" width="47" height="47" rx="5.5" stroke="#E5E5E5" />diff --git a/apps/web/ui/partners/groups/design/application-form/program-terms-preview.tsx b/apps/web/ui/partners/groups/design/application-form/program-terms-preview.tsxnew file mode 100644index 0000000000..6c914faec8--- /dev/null+++ b/apps/web/ui/partners/groups/design/application-form/program-terms-preview.tsx@@ -0,0 +1,100 @@+"use client";++import useProgram from "@/lib/swr/use-program";+import useWorkspace from "@/lib/swr/use-workspace";+import { ProgramProps } from "@/lib/types";+import { ArrowUpRight2, Button, SquareCheck, UserCheck } from "@dub/ui";+import { cn } from "@dub/utils";+import { useEffect } from "react";++const PROGRAM_TERMS_CHANNEL = "program-terms-updated";++export default function ProgramTermsPreview() {+ const { slug } = useWorkspace();+ const { program, mutate } = useProgram(+ {},+ { dedupingInterval: 5000, revalidateOnFocus: true },+ );++ // Listen for cross-tab updates from the resources page+ useEffect(() => {+ const channel = new BroadcastChannel(PROGRAM_TERMS_CHANNEL);+ channel.onmessage = (event) => {+ const termsUrl = event.data?.termsUrl ?? null;+ // Optimistically update the cache, then revalidate in background+ mutate(+ (current) =>+ current ? ({ ...current, termsUrl } as ProgramProps) : current,+ { revalidate: true },+ );+ };+ return () => channel.close();+ }, [mutate]);++ const hasTerms = Boolean(program?.termsUrl);+ const resourcesUrl = `/${slug}/program/resources`;++ return (+ <div+ className={cn(+ "rounded-xl px-1 pb-1.5 pt-1",+ hasTerms ? "bg-blue-50" : "bg-amber-100",+ )}+ >+ <div+ className={cn(+ "flex items-center justify-center gap-2 rounded-lg border py-2",+ hasTerms+ ? "border-blue-200 bg-blue-100"+ : "border-amber-100 bg-amber-50",+ )}+ >+ <div className="flex items-center gap-1">+ <SquareCheck+ className={cn(+ "size-4",+ hasTerms ? "text-blue-900" : "text-amber-900",+ )}+ />+ <span+ className={cn(+ "text-sm font-medium",+ hasTerms ? "text-blue-900" : "text-amber-900",+ )}+ >+ Program terms agreement+ </span>+ </div>+ <Button+ type="button"+ variant={hasTerms ? "secondary" : "primary"}+ text={hasTerms ? "Edit link" : "Add link"}+ right={<ArrowUpRight2 className="size-3" />}+ className={cn(+ "h-6 w-fit gap-1 px-1.5 text-xs",+ hasTerms && "border-blue-200",+ )}+ onClick={() => window.open(resourcesUrl, "_blank")}+ />+ </div>+ <div className="mt-1 flex items-center justify-center gap-1">+ <UserCheck+ className={cn(+ "size-3.5",+ hasTerms ? "text-blue-900" : "text-amber-500",+ )}+ />+ <span+ className={cn(+ "text-xs font-medium",+ hasTerms ? "text-blue-900" : "text-amber-900",+ )}+ >+ Required applicant field+ </span>+ </div>+ </div>+ );+}++export { PROGRAM_TERMS_CHANNEL };diff --git a/apps/web/ui/partners/groups/design/application-form/required-fields-preview.tsx b/apps/web/ui/partners/groups/design/application-form/required-fields-preview.tsxindex d62f0efc4f..a7e60f2fa6 100644--- a/apps/web/ui/partners/groups/design/application-form/required-fields-preview.tsx+++ b/apps/web/ui/partners/groups/design/application-form/required-fields-preview.tsx@@ -1,3 +1,5 @@+import { UserCheck } from "@dub/ui";+const RequiredFieldItemPreview = ({icon,label,@@ -6,7 +8,7 @@ const RequiredFieldItemPreview = ({label: string;}) => {return (- <div className="flex flex-1 flex-col items-center justify-center gap-1.5 rounded-lg bg-blue-100 py-4">+ <div className="flex flex-1 items-center justify-center gap-1.5 rounded-lg border border-blue-200 bg-blue-100 py-2"><div className="relative h-4 w-4">{icon}</div><div className="text-sm font-medium text-blue-900">{label}</div></div>@@ -15,18 +17,16 @@ const RequiredFieldItemPreview = ({const RequiredFieldsPreview = () => {return (- <div className="rounded-[10px] border border-blue-200 bg-blue-50 px-4 pb-2 pt-4">- <div className="grid w-full grid-cols-1 gap-4 lg:grid-cols-3">+ <div className="rounded-xl bg-blue-50 px-1 pb-1.5 pt-1">+ <div className="grid w-full grid-cols-1 gap-1 lg:grid-cols-3"><RequiredFieldItemPreview icon={<SignatureIcon />} label="Name" /><RequiredFieldItemPreview icon={<EmailIcon />} label="Email" /><RequiredFieldItemPreview icon={<CountryIcon />} label="Country" /></div>- <div className="mt-2 flex items-center justify-center gap-2">- <div className="relative h-4 w-4">- <LockIcon />- </div>- <div className="text-sm font-medium text-blue-900">- Mandatory fields+ <div className="mt-1 flex items-center justify-center gap-2">+ <UserCheck className="size-4 text-blue-500" />+ <div className="text-xs font-medium text-blue-900">+ Required applicant fields</div></div></div>@@ -154,39 +154,4 @@ const CountryIcon = () => {);};-const LockIcon = () => {- return (- <svg- width="17"- height="16"- viewBox="0 0 17 16"- fill="none"- xmlns="http://www.w3.org/2000/svg"- className="size-[16px]"- >- <path- d="M5.61115 7.33344V4.44455C5.61115 2.849 6.90448 1.55566 8.50003 1.55566C10.0956 1.55566 11.3889 2.849 11.3889 4.44455V7.33344"- stroke="#2B7FFF"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round"- />- <path- d="M8.5 10.4446V11.3335"- stroke="#2B7FFF"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round"- />- <path- d="M11.8334 7.3335H5.16669C4.18485 7.3335 3.38892 8.12943 3.38892 9.11127V12.6668C3.38892 13.6487 4.18485 14.4446 5.16669 14.4446H11.8334C12.8152 14.4446 13.6111 13.6487 13.6111 12.6668V9.11127C13.6111 8.12943 12.8152 7.3335 11.8334 7.3335Z"- stroke="#2B7FFF"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round"- />- </svg>- );-};-export default RequiredFieldsPreview;diff --git a/apps/web/ui/partners/groups/design/previews/application-preview.tsx b/apps/web/ui/partners/groups/design/previews/application-preview.tsxindex ac5077087f..0ed607afc9 100644--- a/apps/web/ui/partners/groups/design/previews/application-preview.tsx+++ b/apps/web/ui/partners/groups/design/previews/application-preview.tsx@@ -35,6 +35,7 @@ import {DESIGNER_FIELDS,} from "../application-form/modals/add-field-modal";import { useEditApplicationHeroModal } from "../application-form/modals/edit-application-hero-modal";+import ProgramTermsPreview from "../application-form/program-terms-preview";import RequiredFieldsPreview from "../application-form/required-fields-preview";import { useBrandingFormContext } from "../branding-form";@@ -230,7 +231,7 @@ export function ApplicationPreview({<EditToolbaronEdit={() => setShowEditApplicationHeroModal(true)}/>- <div className="mx-auto max-w-screen-sm">+ <div className="relative mx-auto max-w-screen-sm"><div className="px-6"><ApplicationFormHeroprogram={program}@@ -325,12 +326,27 @@ export function ApplicationPreview({})}{fields.length === 0 && (- <div className="flex justify-center py-10">- <AddFieldButton onClick={() => setAddFieldIndex(0)} />+ <div className="group/empty relative py-10">+ <div className="border-subtle pointer-events-none absolute inset-y-0 left-1/2 w-[1080px] max-w-[calc(100cqw-32px)] -translate-x-1/2 overflow-hidden rounded-xl border opacity-40 transition-opacity duration-300 ease-out group-hover/empty:opacity-100">+ <Grid+ cellSize={60}+ className="text-border-subtle inset-[unset] left-1/2 top-1/2 h-[max(1200px,100%)] w-[1200px] -translate-x-1/2 -translate-y-1/2"+ />+ </div>+ <div className="relative flex justify-center">+ <AddFieldButton onClick={() => setAddFieldIndex(0)} />+ </div></div>)}</div>+ {/* Program terms agreement */}+ <div className="relative mx-auto max-w-screen-sm py-6">+ <div className="px-6">+ <ProgramTermsPreview />+ </div>+ </div>+{/* Buttons */}<div className="mx-auto mb-6 max-w-screen-sm"><div className="px-6">diff --git a/apps/web/ui/partners/groups/design/previews/lander-preview.tsx b/apps/web/ui/partners/groups/design/previews/lander-preview.tsxindex c3c954d278..e0edb1c952 100644--- a/apps/web/ui/partners/groups/design/previews/lander-preview.tsx+++ b/apps/web/ui/partners/groups/design/previews/lander-preview.tsx@@ -333,8 +333,16 @@ export function LanderPreview({ group }: { group: GroupWithProgramProps }) {})}{!landerData?.blocks?.length && (- <div className="flex justify-center py-10">- <AddBlockButton onClick={() => setAddBlockIndex(0)} />+ <div className="group/empty relative py-10">+ <div className="border-subtle pointer-events-none absolute inset-y-0 left-1/2 w-[1080px] max-w-[calc(100cqw-32px)] -translate-x-1/2 overflow-hidden rounded-xl border opacity-40 transition-opacity duration-300 ease-out group-hover/empty:opacity-100">+ <Grid+ cellSize={60}+ className="text-border-subtle inset-[unset] left-1/2 top-1/2 h-[max(1200px,100%)] w-[1200px] -translate-x-1/2 -translate-y-1/2"+ />+ </div>+ <div className="relative flex justify-center">+ <AddBlockButton onClick={() => setAddBlockIndex(0)} />+ </div></div>)}</div>diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.tsindex eb59f3709e..de4348a974 100644--- a/packages/ui/src/icons/nucleo/index.ts+++ b/packages/ui/src/icons/nucleo/index.ts@@ -215,6 +215,7 @@ export * from "./sort-alpha-ascending";export * from "./sort-alpha-descending";export * from "./sparkle3";export * from "./square-chart";+export * from "./square-check";export * from "./square-layout-grid5";export * from "./square-layout-grid6";export * from "./square-user-sparkle2";diff --git a/packages/ui/src/icons/nucleo/square-check.tsx b/packages/ui/src/icons/nucleo/square-check.tsxnew file mode 100644index 0000000000..b42dc4f8ae--- /dev/null+++ b/packages/ui/src/icons/nucleo/square-check.tsx@@ -0,0 +1,32 @@+import { SVGProps } from "react";++export function SquareCheck(props: SVGProps<SVGSVGElement>) {+ return (+ <svg+ height="16"+ width="16"+ viewBox="0 0 16 16"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <g fill="currentColor">+ <path+ d="M4.88867 8.00114C5.65578 8.77181 6.25489 9.66158 6.75534 10.634C7.91712 8.41981 9.36867 6.66425 11.1109 5.36914"+ fill="none"+ stroke="currentColor"+ strokeWidth="1.5"+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ <path+ d="M11.7777 2.44531H4.22211C3.24027 2.44531 2.44434 3.24125 2.44434 4.22309V11.7786C2.44434 12.7605 3.24027 13.5564 4.22211 13.5564H11.7777C12.7595 13.5564 13.5554 12.7605 13.5554 11.7786V4.22309C13.5554 3.24125 12.7595 2.44531 11.7777 2.44531Z"+ fill="none"+ stroke="currentColor"+ strokeWidth="1.5"+ strokeLinecap="round"+ strokeLinejoin="round"+ />+ </g>+ </svg>+ );+}diff --git a/packages/ui/src/icons/nucleo/user-check.tsx b/packages/ui/src/icons/nucleo/user-check.tsxindex 3410662064..1014531916 100644--- a/packages/ui/src/icons/nucleo/user-check.tsx+++ b/packages/ui/src/icons/nucleo/user-check.tsx@@ -3,40 +3,37 @@ import { SVGProps } from "react";export function UserCheck(props: SVGProps<SVGSVGElement>) {return (<svg- height="18"- width="18"- viewBox="0 0 18 18"+ viewBox="0 0 14 14"xmlns="http://www.w3.org/2000/svg"{...props}>- <g fill="currentColor">- <circle- cx="9"- cy="4.5"+ <g fill="currentColor" clipPath="url(#user-check-clip)">+ <path+ d="M7.00022 5.63911C8.18166 5.63911 9.13911 4.68166 9.13911 3.50022C9.13911 2.31877 8.18166 1.36133 7.00022 1.36133C5.81877 1.36133 4.86133 2.31877 4.86133 3.50022C4.86133 4.68166 5.81877 5.63911 7.00022 5.63911Z"fill="none"- r="2.75"stroke="currentColor"+ strokeWidth="1.5"strokeLinecap="round"strokeLinejoin="round"- strokeWidth="1.5"/><path- d="M13.314,11.5c-1.121-1.078-2.635-1.75-4.313-1.75-2.551,0-4.739,1.53-5.709,3.72-.365,.825,.087,1.774,.947,2.045,1.225,.386,2.846,.734,4.762,.734"+ d="M7.32045 7.59994C7.21452 7.59294 7.10904 7.58398 7.00124 7.58398C5.01713 7.58398 3.31536 8.77399 2.56092 10.4773C2.27703 11.119 2.62858 11.857 3.29747 12.068C4.10542 12.3224 5.1457 12.5452 6.34869 12.6101"fill="none"stroke="currentColor"- strokeLinecap="round"- strokeLinejoin="round"strokeWidth="1.5"- />- <polyline- fill="none"- points="11.25 14.75 12.859 16.25 16.256 11.75"- stroke="currentColor"strokeLinecap="round"strokeLinejoin="round"- strokeWidth="1.5"+ />+ <path+ d="M10.8894 7.77734C9.17358 7.77734 7.77832 9.17299 7.77832 10.8885C7.77832 12.6039 9.17358 13.9996 10.8894 13.9996C12.6053 13.9996 14.0005 12.6039 14.0005 10.8885C14.0005 9.17299 12.6053 7.77734 10.8894 7.77734ZM12.6842 10.3067L10.9342 12.2511C10.8271 12.37 10.676 12.4395 10.5157 12.4437C10.5104 12.4441 10.5058 12.4441 10.5005 12.4441C10.3464 12.4441 10.1975 12.383 10.0881 12.2732L9.11586 11.301C8.88798 11.0731 8.88798 10.704 9.11586 10.4762C9.34375 10.2483 9.71289 10.2483 9.9407 10.4762L10.4785 11.0135L11.8168 9.52594C12.0332 9.28748 12.4009 9.26772 12.6409 9.48262C12.8802 9.6983 12.8999 10.067 12.6842 10.3067Z"+ fill="currentColor"/></g>+ <defs>+ <clipPath id="user-check-clip">+ <rect width="14" height="14" fill="white" />+ </clipPath>+ </defs></svg>);}