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.

Hook things up

Tim Wilson547eedaf169e
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/how-you-work-form.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/how-you-work-form.tsx
index 9eb50ae52f..976a2be00b 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/how-you-work-form.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/how-you-work-form.tsx
@@ -15,7 +15,7 @@ import { PreferredEarningStructure, SalesChannel } from "@dub/prisma/client";
import { cn } from "@dub/utils";
type HowYouWorkFormData = {
- preferredEarningStructure: PreferredEarningStructure[];
+ preferredEarningStructures: PreferredEarningStructure[];
salesChannels: SalesChannel[];
};
@@ -29,7 +29,7 @@ export function HowYouWorkForm({ partner }: { partner?: PartnerProps }) {
formState: { isSubmitting, isSubmitSuccessful },
} = useForm<HowYouWorkFormData>({
defaultValues: {
- preferredEarningStructure: partner?.preferredEarningStructure ?? [],
+ preferredEarningStructures: partner?.preferredEarningStructures ?? [],
salesChannels: partner?.salesChannels ?? [],
},
});
@@ -78,7 +78,7 @@ export function HowYouWorkForm({ partner }: { partner?: PartnerProps }) {
<div className="@sm/panel:grid-cols-2 grid grid-cols-1 gap-4">
<Controller
control={control}
- name="preferredEarningStructure"
+ name="preferredEarningStructures"
render={({ field }) => (
<>
{preferredEarningStructures.map((earningStructure) => (
diff --git a/apps/web/lib/actions/partners/update-partner-profile.ts b/apps/web/lib/actions/partners/update-partner-profile.ts
index 501aeeb9bf..7884142910 100644
--- a/apps/web/lib/actions/partners/update-partner-profile.ts
+++ b/apps/web/lib/actions/partners/update-partner-profile.ts
@@ -51,6 +51,10 @@ export const updatePartnerProfileAction = authPartnerActionClient
country,
profileType,
companyName,
+ monthlyTraffic,
+ industryInterests,
+ preferredEarningStructures,
+ salesChannels,
} = parsedInput;
if (profileType === "company" && !companyName)
@@ -85,6 +89,34 @@ export const updatePartnerProfileAction = authPartnerActionClient
country,
profileType,
companyName,
+ monthlyTraffic,
+
+ ...(industryInterests && {
+ industryInterests: {
+ deleteMany: {},
+ create: industryInterests.map((name) => ({
+ industryInterest: name,
+ })),
+ },
+ }),
+
+ ...(preferredEarningStructures && {
+ preferredEarningStructures: {
+ deleteMany: {},
+ create: preferredEarningStructures.map((name) => ({
+ preferredEarningStructure: name,
+ })),
+ },
+ }),
+
+ ...(salesChannels && {
+ salesChannels: {
+ deleteMany: {},
+ create: salesChannels.map((name) => ({
+ salesChannel: name,
+ })),
+ },
+ }),
},
});
diff --git a/apps/web/lib/auth/partner.ts b/apps/web/lib/auth/partner.ts
index 6cf86f1f27..372957f3f4 100644
--- a/apps/web/lib/auth/partner.ts
+++ b/apps/web/lib/auth/partner.ts
@@ -60,7 +60,7 @@ export const withPartnerProfile = (handler: WithPartnerProfileHandler) => {
partner: {
include: {
industryInterests: true,
- preferredEarningStructure: true,
+ preferredEarningStructures: true,
salesChannels: true,
},
},
@@ -77,7 +77,7 @@ export const withPartnerProfile = (handler: WithPartnerProfileHandler) => {
const {
industryInterests,
- preferredEarningStructure,
+ preferredEarningStructures,
salesChannels,
...partner
} = partnerUser.partner;
@@ -92,7 +92,7 @@ export const withPartnerProfile = (handler: WithPartnerProfileHandler) => {
industryInterests: industryInterests.map(
({ industryInterest }) => industryInterest,
),
- preferredEarningStructure: preferredEarningStructure.map(
+ preferredEarningStructures: preferredEarningStructures.map(
({ preferredEarningStructure }) => preferredEarningStructure,
),
salesChannels: salesChannels.map(
diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.ts
index 49ddf9966b..627ba19f47 100644
--- a/apps/web/lib/zod/schemas/partners.ts
+++ b/apps/web/lib/zod/schemas/partners.ts
@@ -250,9 +250,9 @@ export const PartnerProfileSchema = z.object({
.array(z.nativeEnum(IndustryInterest))
.max(MAX_PARTNER_INDUSTRY_INTERESTS)
.describe("The partner's industry interests."),
- preferredEarningStructure: z
+ preferredEarningStructures: z
.array(z.nativeEnum(PreferredEarningStructure))
- .describe("The partner's preferred earning structure."),
+ .describe("The partner's preferred earning structures."),
salesChannels: z
.array(z.nativeEnum(SalesChannel))
.describe("The partner's sales channels."),
diff --git a/packages/prisma/schema/partner.prisma b/packages/prisma/schema/partner.prisma
index 4865287105..7d0c73c12f 100644
--- a/packages/prisma/schema/partner.prisma
+++ b/packages/prisma/schema/partner.prisma
@@ -69,9 +69,9 @@ model Partner {
sentMessages Message[] @relation("SenderPartner")
comments PartnerComment[]
- industryInterests PartnerIndustryInterest[]
- preferredEarningStructure PartnerPreferredEarningStructure[]
- salesChannels PartnerSalesChannel[]
+ industryInterests PartnerIndustryInterest[]
+ preferredEarningStructures PartnerPreferredEarningStructure[]
+ salesChannels PartnerSalesChannel[]
}
model PartnerInvite {