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.

allow updating country / profileType if no stripeConnectId yet

Steven Tey5e862798305f
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/partners/invite-partner-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/partners/invite-partner-sheet.tsx
index 29da9a3121..2dea7bc87d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/partners/invite-partner-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/partners/invite-partner-sheet.tsx
@@ -155,10 +155,6 @@ function InvitePartnerSheetContent({ setIsOpen }: InvitePartnerSheetProps) {
autoComplete="off"
/>
</div>
- <p className="mt-1 text-xs text-neutral-500">
- Partner will be able to claim their profile by signing up to Dub
- Partners with this email
- </p>
</div>
<div>
diff --git a/apps/web/app/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx b/apps/web/app/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx
index 4b85c60b6d..2a6b0aada1 100644
--- a/apps/web/app/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx
+++ b/apps/web/app/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx
@@ -39,6 +39,7 @@ export function OnboardingForm({
| "image"
| "profileType"
| "companyName"
+ | "stripeConnectId"
>
> | null;
lockName?: boolean;
@@ -163,10 +164,10 @@ export function OnboardingForm({
name="country"
rules={{ required: true }}
render={({ field }) => (
- // Disable the combobox if the partner already has a country
+ // Disable the combobox if the partner already has a stripeConnectId
<CountryCombobox
{...field}
- disabled={!!partner?.country}
+ disabled={!!partner?.stripeConnectId}
error={errors.country ? true : false}
/>
)}
@@ -214,17 +215,17 @@ export function OnboardingForm({
]}
selected={profileType}
selectAction={(option: "individual" | "company") => {
- if (!partner?.profileType) {
+ if (!partner?.stripeConnectId) {
setValue("profileType", option);
}
}}
className={cn(
"flex w-full items-center gap-0.5 rounded-lg border-neutral-300 bg-neutral-100 p-0.5",
- partner?.profileType && "cursor-not-allowed opacity-70",
+ partner?.stripeConnectId && "cursor-not-allowed opacity-70",
)}
optionClassName={cn(
"h-9 flex items-center justify-center rounded-lg flex-1",
- partner?.profileType && "pointer-events-none",
+ partner?.stripeConnectId && "pointer-events-none",
)}
indicatorClassName="bg-white"
/>
diff --git a/apps/web/lib/actions/partners/onboard-partner.ts b/apps/web/lib/actions/partners/onboard-partner.ts
index 67feb74c05..7e6f04bf00 100644
--- a/apps/web/lib/actions/partners/onboard-partner.ts
+++ b/apps/web/lib/actions/partners/onboard-partner.ts
@@ -3,16 +3,15 @@
import { createId } from "@/lib/api/create-id";
import { completeProgramApplications } from "@/lib/partners/complete-program-applications";
import { storage } from "@/lib/storage";
-import { createConnectedAccount } from "@/lib/stripe/create-connected-account";
import { onboardPartnerSchema } from "@/lib/zod/schemas/partners";
import { prisma } from "@dub/prisma";
import { Prisma } from "@dub/prisma/client";
-import { CONNECT_SUPPORTED_COUNTRIES, nanoid } from "@dub/utils";
+import { nanoid } from "@dub/utils";
import { waitUntil } from "@vercel/functions";
import { authUserActionClient } from "../safe-action";
// Onboard a new partner:
-// - If the Partner already exists and matches the user's email, update the Partner (ghost partner)
+// - If the Partner already exists and matches the user's email, update the Partner
// - If the Partner doesn't exist, create it
export const onboardPartnerAction = authUserActionClient
.schema(onboardPartnerSchema)
@@ -27,20 +26,6 @@ export const onboardPartnerAction = authUserActionClient
},
});
- // only create a connected account if the partner doesn't already have one
- // and the country is supported
- const connectedAccount =
- !existingPartner?.stripeConnectId &&
- CONNECT_SUPPORTED_COUNTRIES.includes(country)
- ? await createConnectedAccount({
- name,
- email: user.email,
- country,
- profileType,
- companyName,
- })
- : null;
-
const partnerId = existingPartner
? existingPartner.id
: createId({ prefix: "pn_" });
@@ -53,12 +38,16 @@ export const onboardPartnerAction = authUserActionClient
const payload: Prisma.PartnerCreateInput = {
name,
email: user.email,
- country: existingPartner?.country || country,
- profileType: existingPartner?.profileType || profileType,
- companyName: existingPartner?.companyName || companyName,
+ // you can only update these fields if the partner doesn't already have a stripeConnectId
+ ...(existingPartner?.stripeConnectId
+ ? {}
+ : {
+ country,
+ profileType,
+ companyName,
+ }),
...(description && { description }),
image: imageUrl,
- ...(connectedAccount && { stripeConnectId: connectedAccount.id }),
users: {
connectOrCreate: {
where: {