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.

WIP industry interests

Tim Wilson2bc01feceb60
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/about-you-form.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/about-you-form.tsx
index bb78e9701b..bd9fe193f6 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/about-you-form.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/about-you-form.tsx
@@ -2,17 +2,19 @@ import { updatePartnerProfileAction } from "@/lib/actions/partners/update-partne
import { PartnerProps } from "@/lib/types";
import { MAX_PARTNER_DESCRIPTION_LENGTH } from "@/lib/zod/schemas/partners";
import { MaxCharactersCounter } from "@/ui/shared/max-characters-counter";
+import { IndustryInterest } from "@dub/prisma/client";
import { Button, useEnterSubmit } from "@dub/ui";
import { cn } from "@dub/utils";
import { useAction } from "next-safe-action/hooks";
import { useEffect } from "react";
-import { useForm } from "react-hook-form";
+import { Controller, useForm } from "react-hook-form";
import ReactTextareaAutosize from "react-textarea-autosize";
import { toast } from "sonner";
import { SettingsRow } from "./settings-row";
type AboutYouFormData = {
description: string;
+ industryInterests: IndustryInterest[];
};
export function AboutYouForm({ partner }: { partner?: PartnerProps }) {
@@ -27,6 +29,7 @@ export function AboutYouForm({ partner }: { partner?: PartnerProps }) {
} = useForm<AboutYouFormData>({
defaultValues: {
description: partner?.description ?? undefined,
+ industryInterests: partner?.industryInterests ?? [],
},
});
@@ -95,6 +98,29 @@ export function AboutYouForm({ partner }: { partner?: PartnerProps }) {
</div>
</SettingsRow>
+ <SettingsRow
+ heading="Industry interests"
+ description="Add the industries you care and post content about. This helps programs in those areas discover you."
+ >
+ <Controller
+ control={control}
+ name="industryInterests"
+ render={({ field }) => (
+ <Button
+ text={`${field.value.length ? "Edit" : "Add"} interests`}
+ onClick={() => toast.info("WIP")}
+ variant="secondary"
+ className="h-8 w-fit rounded-lg px-3"
+ />
+ )}
+ />
+ </SettingsRow>
+
+ <SettingsRow
+ heading="Estimated monthly traffic"
+ description="Including websites, newsletters, and social accounts."
+ ></SettingsRow>
+
<div className="flex items-center justify-end rounded-b-lg border-t border-neutral-200 bg-neutral-50 px-6 py-4">
<Button
text="Save changes"
diff --git a/apps/web/lib/auth/partner.ts b/apps/web/lib/auth/partner.ts
index db4682b417..6cf86f1f27 100644
--- a/apps/web/lib/auth/partner.ts
+++ b/apps/web/lib/auth/partner.ts
@@ -57,7 +57,13 @@ export const withPartnerProfile = (handler: WithPartnerProfileHandler) => {
},
},
include: {
- partner: true,
+ partner: {
+ include: {
+ industryInterests: true,
+ preferredEarningStructure: true,
+ salesChannels: true,
+ },
+ },
},
});
@@ -69,12 +75,30 @@ export const withPartnerProfile = (handler: WithPartnerProfileHandler) => {
});
}
+ const {
+ industryInterests,
+ preferredEarningStructure,
+ salesChannels,
+ ...partner
+ } = partnerUser.partner;
+
return await handler({
req,
params,
searchParams,
session,
- partner: partnerUser.partner as PartnerProps,
+ partner: {
+ ...partner,
+ industryInterests: industryInterests.map(
+ ({ industryInterest }) => industryInterest,
+ ),
+ preferredEarningStructure: preferredEarningStructure.map(
+ ({ preferredEarningStructure }) => preferredEarningStructure,
+ ),
+ salesChannels: salesChannels.map(
+ ({ salesChannel }) => salesChannel,
+ ),
+ } as PartnerProps,
});
} catch (error) {
req.log.error(error);
diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.ts
index 5d749dfcab..818631891a 100644
--- a/apps/web/lib/zod/schemas/partners.ts
+++ b/apps/web/lib/zod/schemas/partners.ts
@@ -248,7 +248,7 @@ export const PartnerProfileSchema = z.object({
.array(z.nativeEnum(IndustryInterest))
.describe("The partner's industry interests."),
preferredEarningStructure: z
- .nativeEnum(PreferredEarningStructure)
+ .array(z.nativeEnum(PreferredEarningStructure))
.describe("The partner's preferred earning structure."),
salesChannels: z
.array(z.nativeEnum(SalesChannel))