The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
remove country selector from partner application form
Pedro Ladeira53eca86994b8
diff --git a/apps/web/lib/actions/partners/create-program-application.ts b/apps/web/lib/actions/partners/create-program-application.tsindex 3f94be79b0..e819bed043 100644--- a/apps/web/lib/actions/partners/create-program-application.ts+++ b/apps/web/lib/actions/partners/create-program-application.ts@@ -1,6 +1,7 @@"use server";import { createId } from "@/lib/api/create-id";+import { isCI, isLocalDev } from "@/lib/api/environment";import { detectAndRecordFraudApplication } from "@/lib/api/fraud/detect-record-fraud-application";import { notifyPartnerApplication } from "@/lib/api/partners/notify-partner-application";import { getIP } from "@/lib/api/utils/get-ip";@@ -34,11 +35,11 @@ import {import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";import { waitUntil } from "@vercel/functions";import { addDays } from "date-fns";-import { cookies } from "next/headers";+import { cookies, headers } from "next/headers";import * as z from "zod/v4";import { actionClient } from "../safe-action";-export type PartnerData = { name: string; country: string };+export type PartnerData = { name: string; country?: string };interface Response {programApplicationId: string;@@ -390,7 +391,7 @@ async function createApplicationAndEnrollment({programEnrollmentId: enrollmentId,partnerData: {name: data.name,- country: data.country,+ country: partner.country ?? data.country ?? undefined,},};}@@ -404,9 +405,15 @@ async function createApplication({data: z.infer<typeof createProgramApplicationSchema>;group: PartnerGroup;}) {+ const headerList = await headers();+ const country =+ headerList.get("x-vercel-ip-country") ??+ (isLocalDev || isCI ? "US" : undefined);+const application = await prisma.programApplication.create({data: {...sanitizeData(data, group),+ country,id: createId({ prefix: "pga_" }),programId: program.id,groupId: group.id,@@ -449,7 +456,7 @@ async function createApplication({programApplicationId: application.id,partnerData: {name: data.name,- country: data.country,+ country,},};}diff --git a/apps/web/lib/zod/schemas/programs.ts b/apps/web/lib/zod/schemas/programs.tsindex 84a023cbf4..ca4468e23f 100644--- a/apps/web/lib/zod/schemas/programs.ts+++ b/apps/web/lib/zod/schemas/programs.ts@@ -235,7 +235,7 @@ export const createProgramApplicationSchema = z.object({groupId: z.string().optional(),name: z.string().trim().min(1).max(100),email: z.email().trim().min(1).max(100),- country: z.enum(COUNTRY_CODES),+ country: z.enum(COUNTRY_CODES).optional(),formData: programApplicationFormDataWithValuesSchema,inAppApplication: z.boolean().optional(),});diff --git a/apps/web/ui/partners/groups/design/application-form/program-application-form.tsx b/apps/web/ui/partners/groups/design/application-form/program-application-form.tsxindex 9c46ede526..27c64a4a28 100644--- a/apps/web/ui/partners/groups/design/application-form/program-application-form.tsx+++ b/apps/web/ui/partners/groups/design/application-form/program-application-form.tsx@@ -16,9 +16,8 @@ import { useSession } from "next-auth/react";import { useAction } from "next-safe-action/hooks";import { useRouter } from "next/navigation";import { useCallback, useEffect, useState } from "react";-import { Controller, FormProvider, useForm } from "react-hook-form";+import { FormProvider, useForm } from "react-hook-form";import { toast } from "sonner";-import { CountryCombobox } from "../../../country-combobox";import { ProgramApplicationFormField } from "./fields";import { FormControlRequiredBadge } from "./fields/form-control";import { formDataForApplicationFormData } from "./form-data-for-application-form-data";@@ -26,7 +25,6 @@ import { formDataForApplicationFormData } from "./form-data-for-application-formtype FormData = {name: string;email: string;- country: string;termsAgreement: boolean;formData: ProgramApplicationFormDataWithValues;};@@ -51,7 +49,6 @@ export function ProgramApplicationForm({defaultValues: {name: "",email: "",- country: "",termsAgreement: false,formData: formDataForApplicationFormData(group.applicationFormData?.fields ?? [],@@ -60,7 +57,6 @@ export function ProgramApplicationForm({});const {- control,register,handleSubmit,setError,@@ -200,29 +196,6 @@ export function ProgramApplicationForm({/></label>- <label className="flex flex-col">- <div className="flex items-center gap-1.5">- <span className="text-content-emphasis text-sm font-medium">- Country- </span>- <FormControlRequiredBadge />- </div>-- <Controller- control={control}- name="country"- rules={{ required: true }}- render={({ field }) => (- <CountryCombobox- value={field.value || ""}- onChange={field.onChange}- error={errors.country ? true : false}- className="focus:border-[var(--brand)] focus:ring-[var(--brand)]"- />- )}- />- </label>-{group?.applicationFormData?.fields.map((field, index) => {return (<ProgramApplicationFormFielddiff --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 a7e60f2fa6..0310f6e529 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@@ -21,7 +21,6 @@ const RequiredFieldsPreview = () => {<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-1 flex items-center justify-center gap-2"><UserCheck className="size-4 text-blue-500" />@@ -89,69 +88,4 @@ const EmailIcon = () => {);};-const CountryIcon = () => {- return (- <svg- width="19"- height="18"- viewBox="0 0 19 18"- fill="none"- xmlns="http://www.w3.org/2000/svg"- className="size-[18px]"- >- <g clipPath="url(#clip0_2001_4832)">- <path- d="M13.8342 2.98072L12.3227 2.90943C11.3282 2.86253 10.5689 3.78613 10.8071 4.75273L11.0791 5.85623C11.1385 6.09733 11.042 6.34993 10.837 6.48993C10.6714 6.60303 10.46 6.62513 10.2746 6.54873L9.34748 6.16663C8.62258 5.86783 7.79498 5.96233 7.15608 6.41693C6.59028 6.81943 6.23868 7.45783 6.20088 8.15113L6.12988 9.45323"- stroke="#1C398E"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round"- />- <path- d="M14.8334 16.75C14.8334 16.75 12.0834 15.241 12.0834 13C12.0834 11.481 13.3144 10.25 14.8334 10.25C16.3524 10.25 17.5834 11.481 17.5834 13C17.5834 15.241 14.8334 16.75 14.8334 16.75Z"- stroke="#1C398E"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round"- />- <path- d="M14.8334 13.75C15.2474 13.75 15.5834 13.4142 15.5834 13C15.5834 12.5858 15.2474 12.25 14.8334 12.25C14.4194 12.25 14.0834 12.5858 14.0834 13C14.0834 13.4142 14.4194 13.75 14.8334 13.75Z"- fill="#1C398E"- />- <path- d="M3.42505 5.74561C3.85365 6.86961 4.80365 8.68821 6.32995 9.68311C6.75585 9.91771 7.73366 10.681 7.66566 11.8893C7.57246 13.5436 8.57834 13.6635 9.37714 14.2579C9.78724 14.563 9.89175 15.5008 9.83175 16.2409"- stroke="#1C398E"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round"- />- <path- d="M6.58759 9.84737C7.51069 9.65277 8.60939 9.32137 9.85959 10.0263"- stroke="#1C398E"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round"- />- <path- d="M9.83337 16.25C5.82927 16.25 2.58337 13.0041 2.58337 9C2.58337 4.9959 5.82927 1.75 9.83337 1.75C13.3602 1.75 16.2987 4.2682 16.9492 7.6046"- stroke="#1C398E"- strokeWidth="1.5"- strokeLinecap="round"- strokeLinejoin="round"- />- </g>- <defs>- <clipPath id="clip0_2001_4832">- <rect- width="18"- height="18"- fill="white"- transform="translate(0.833374)"- />- </clipPath>- </defs>- </svg>- );-};-export default RequiredFieldsPreview;diff --git a/apps/web/ui/partners/program-application-sheet.tsx b/apps/web/ui/partners/program-application-sheet.tsxindex 6a51bf9fbe..18717f92c5 100644--- a/apps/web/ui/partners/program-application-sheet.tsx+++ b/apps/web/ui/partners/program-application-sheet.tsx@@ -130,7 +130,14 @@ function ProgramApplicationSheetForm({});const onSubmit = async (data: FormData) => {- if (!group || !program || !partner?.email || !partner.country) return;+ if (!group || !program || !partner?.email) return;++ if (!partner.country) {+ toast.error(+ "You haven't set your country yet. Please contact support to apply.",+ );+ return;+ }const result = await executeAsync({...data,