The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add optional terms URL and age verification to partner application form
Kiran Ke869f8a4c79b
diff --git a/apps/web/app/partners.dub.co/(apply)/[programSlug]/apply/form.tsx b/apps/web/app/partners.dub.co/(apply)/[programSlug]/apply/form.tsxindex 423be3a8c3..e3d27950b5 100644--- a/apps/web/app/partners.dub.co/(apply)/[programSlug]/apply/form.tsx+++ b/apps/web/app/partners.dub.co/(apply)/[programSlug]/apply/form.tsx@@ -25,7 +25,10 @@ type FormData = {export function ProgramApplicationForm({program,}: {- program: Pick<Program, "id" | "slug" | "name">;+ program: Pick<+ Program,+ "id" | "slug" | "name" | "termsUrl" | "ageVerification"+ >;}) {const { isMobile } = useMediaQuery();const router = useRouter();@@ -180,35 +183,49 @@ export function ProgramApplicationForm({/></label>- <div className="flex items-center gap-2">- <input- type="checkbox"- id="ageVerification"- className={cn(- "h-4 w-4 rounded border-neutral-300 text-[var(--brand)] focus:ring-[var(--brand)]",- errors.ageVerification && "border-red-400 focus:ring-red-500",- )}- {...register("ageVerification", { required: true })}- />- <label htmlFor="ageVerification" className="text-sm text-neutral-800">- I am 21 years or older- </label>- </div>-- <div className="flex items-center gap-2">- <input- type="checkbox"- id="termsAgreement"- className={cn(- "h-4 w-4 rounded border-neutral-300 text-[var(--brand)] focus:ring-[var(--brand)]",- errors.termsAgreement && "border-red-400 focus:ring-red-500",- )}- {...register("termsAgreement", { required: true })}- />- <label htmlFor="termsAgreement" className="text-sm text-neutral-800">- I agree to the {program.name} affiliate participation agreement- </label>- </div>+ {program.ageVerification && (+ <div className="flex items-center gap-2">+ <input+ type="checkbox"+ id="ageVerification"+ className={cn(+ "h-4 w-4 rounded border-neutral-300 text-[var(--brand)] focus:ring-[var(--brand)]",+ errors.ageVerification && "border-red-400 focus:ring-red-500",+ )}+ {...register("ageVerification", {+ required: true,+ })}+ />+ <label htmlFor="ageVerification" className="text-sm text-neutral-800">+ I'm {program.ageVerification} years or older+ </label>+ </div>+ )}++ {program.termsUrl && (+ <div className="flex items-center gap-2">+ <input+ type="checkbox"+ id="termsAgreement"+ className={cn(+ "h-4 w-4 rounded border-neutral-300 text-[var(--brand)] focus:ring-[var(--brand)]",+ errors.termsAgreement && "border-red-400 focus:ring-red-500",+ )}+ {...register("termsAgreement", { required: true })}+ />+ <label htmlFor="termsAgreement" className="text-sm text-neutral-800">+ I agree to the{" "}+ <a+ href={program.termsUrl}+ target="_blank"+ rel="noopener noreferrer"+ className="text-[var(--brand)] underline hover:opacity-80"+ >+ {program.name} affiliate participation agreement+ </a>+ </label>+ </div>+ )}<Buttontext="Submit application"diff --git a/apps/web/app/partners.dub.co/(apply)/[programSlug]/apply/page.tsx b/apps/web/app/partners.dub.co/(apply)/[programSlug]/apply/page.tsxindex af0b294c1b..f3e05700a5 100644--- a/apps/web/app/partners.dub.co/(apply)/[programSlug]/apply/page.tsx+++ b/apps/web/app/partners.dub.co/(apply)/[programSlug]/apply/page.tsx@@ -54,9 +54,7 @@ export default async function ApplicationPage({{/* Application form */}<div className="mt-10">- <ProgramApplicationForm- program={{ id: program.id, name: program.name, slug: program.slug }}- />+ <ProgramApplicationForm program={program} /></div></div></div>diff --git a/packages/prisma/schema/program.prisma b/packages/prisma/schema/program.prismaindex 9651e4b57a..d541eafe80 100644--- a/packages/prisma/schema/program.prisma+++ b/packages/prisma/schema/program.prisma@@ -40,6 +40,8 @@ model Program {holdingPeriodDays Int @default(0) // number of days to wait before earnings are added to a payoutdefaultRewardId String? // default reward for the programlanderData Json? @db.Json+ termsUrl String?+ ageVerification Int?createdAt DateTime @default(now())updatedAt DateTime @updatedAt