The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Industry interests
Tim Wilson3e219892cad7
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.tsxindex bd9fe193f6..2ab68c25be 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@@ -1,4 +1,5 @@import { updatePartnerProfileAction } from "@/lib/actions/partners/update-partner-profile";+import { industryInterests } from "@/lib/partners/partner-profile";import { PartnerProps } from "@/lib/types";import { MAX_PARTNER_DESCRIPTION_LENGTH } from "@/lib/zod/schemas/partners";import { MaxCharactersCounter } from "@/ui/shared/max-characters-counter";@@ -6,10 +7,11 @@ 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 { useEffect, useState } from "react";import { Controller, useForm } from "react-hook-form";import ReactTextareaAutosize from "react-textarea-autosize";import { toast } from "sonner";+import { IndustryInterestsModal } from "./industry-interests-modal";import { SettingsRow } from "./settings-row";type AboutYouFormData = {@@ -54,6 +56,9 @@ export function AboutYouForm({ partner }: { partner?: PartnerProps }) {},});+ const [showIndustryInterestsModal, setShowIndustryInterestsModal] =+ useState(false);+return (<div className="border-border-subtle divide-border-subtle flex flex-col divide-y rounded-lg border"><div className="px-6 py-8">@@ -106,12 +111,46 @@ export function AboutYouForm({ partner }: { partner?: PartnerProps }) {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"- />+ <>+ <IndustryInterestsModal+ show={showIndustryInterestsModal}+ setShow={setShowIndustryInterestsModal}+ interests={field.value}+ onSave={(interests) => field.onChange(interests)}+ />+ <div className="mb-4 flex flex-wrap items-center gap-3">+ {field.value.length > 0+ ? industryInterests+ .filter(({ id }) => field.value.includes(id))+ .map((interest) => (+ <div+ key={interest.id}+ className={cn(+ "ring-border-subtle flex select-none items-center gap-2.5 rounded-full bg-white px-4 py-3 ring-1",+ )}+ >+ <interest.icon className="size-4 text-neutral-600" />+ <span className="text-content-emphasis text-sm font-medium">+ {interest.label}+ </span>+ </div>+ ))+ : [...Array(3)].map((_, idx) => (+ <div+ key={idx}+ className={cn(+ "border-border-subtle h-11 w-32 rounded-full border border-dashed bg-white",+ )}+ />+ ))}+ </div>+ <Button+ text={`${field.value.length ? "Edit" : "Add"} interests`}+ onClick={() => setShowIndustryInterestsModal(true)}+ variant="secondary"+ className="h-8 w-fit rounded-lg px-3"+ />+ </>)}/></SettingsRow>diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/industry-interests-modal.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/industry-interests-modal.tsxnew file mode 100644index 0000000000..bb9445c897--- /dev/null+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/industry-interests-modal.tsx@@ -0,0 +1,130 @@+import { industryInterests } from "@/lib/partners/partner-profile";+import { MAX_PARTNER_INDUSTRY_INTERESTS } from "@/lib/zod/schemas/partners";+import { IndustryInterest } from "@dub/prisma/client";+import { Button, Modal, useScrollProgress } from "@dub/ui";+import { cn } from "@dub/utils";+import { Dispatch, SetStateAction, useRef, useState } from "react";++type IndustryInterestsModalProps = {+ show: boolean;+ setShow: Dispatch<SetStateAction<boolean>>;+ interests: IndustryInterest[];+ onSave: (interests: IndustryInterest[]) => void;+};++export function IndustryInterestsModal({+ show,+ setShow,+ ...rest+}: IndustryInterestsModalProps) {+ return (+ <Modal showModal={show} setShowModal={setShow} className="max-w-lg">+ <IndustryInterestsModalInner show={show} setShow={setShow} {...rest} />+ </Modal>+ );+}++function IndustryInterestsModalInner({+ show,+ setShow,+ interests,+ onSave,+}: {+ show: boolean;+ setShow: Dispatch<SetStateAction<boolean>>;+ interests: IndustryInterest[];+ onSave: (interests: IndustryInterest[]) => void;+}) {+ const scrollRef = useRef<HTMLDivElement>(null);+ const { scrollProgress, updateScrollProgress } = useScrollProgress(scrollRef);++ const [selectedInterests, setSelectedInterests] =+ useState<IndustryInterest[]>(interests);++ const isMaxSelected =+ selectedInterests.length >= MAX_PARTNER_INDUSTRY_INTERESTS;++ return (+ <div>+ <div className="p-4 pb-2 sm:p-6 sm:pb-4">+ <h4 className="text-content-emphasis text-lg font-semibold">+ Add industry Interests+ </h4>+ <p className="text-content-subtle text-sm">+ Add the industries you care and post content about.+ </p>+ </div>+ <div className="relative">+ <div+ ref={scrollRef}+ onScroll={updateScrollProgress}+ className="scrollbar-hide flex max-h-[calc(100dvh-200px)] flex-wrap items-center gap-3 overflow-y-auto px-4 pb-8 pt-2 sm:px-6"+ >+ {industryInterests.map((interest) => (+ <label+ key={interest.id}+ className={cn(+ "ring-border-subtle flex cursor-pointer select-none items-center gap-2.5 rounded-full bg-white px-4 py-3 ring-1 transition-all duration-100 ease-out",+ selectedInterests.includes(interest.id)+ ? "bg-bg-muted ring-2 ring-black"+ : isMaxSelected+ ? "cursor-not-allowed opacity-50"+ : "cursor-pointer",+ )}+ >+ <input+ type="checkbox"+ className="hidden"+ disabled={+ isMaxSelected && !selectedInterests.includes(interest.id)+ }+ onChange={(e) =>+ e.target.checked+ ? setSelectedInterests([...selectedInterests, interest.id])+ : setSelectedInterests(+ selectedInterests.filter((id) => id !== interest.id),+ )+ }+ />+ <interest.icon className="size-4 text-neutral-600" />+ <span className="text-content-emphasis text-sm font-medium">+ {interest.label}+ </span>+ </label>+ ))}+ </div>++ {/* Scroll fade */}+ <div+ className="pointer-events-none absolute bottom-0 left-0 hidden h-16 w-full rounded-b-lg bg-gradient-to-t from-white sm:block"+ style={{ opacity: 1 - Math.pow(scrollProgress, 2) }}+ />+ </div>++ <div className="border-border-subtle flex items-center justify-between gap-4 border-t px-4 py-5 sm:px-6">+ <div>+ <p className="text-content-subtle text-sm tabular-nums">+ {selectedInterests.length}/{MAX_PARTNER_INDUSTRY_INTERESTS} selected+ </p>+ </div>+ <div className="flex items-center gap-2">+ <Button+ text="Cancel"+ variant="secondary"+ className="h-8 w-fit px-3"+ onClick={() => setShow(false)}+ />+ <Button+ text="Save interests"+ variant="primary"+ className="h-8 w-fit px-3"+ onClick={() => {+ onSave(selectedInterests);+ setShow(false);+ }}+ />+ </div>+ </div>+ </div>+ );+}diff --git a/apps/web/lib/partners/partner-profile.ts b/apps/web/lib/partners/partner-profile.tsnew file mode 100644index 0000000000..3af8d95d7f--- /dev/null+++ b/apps/web/lib/partners/partner-profile.ts@@ -0,0 +1,154 @@+import { IndustryInterest } from "@dub/prisma/client";+import {+ BookOpen,+ BracketsCurly,+ BriefcaseFill,+ Brush,+ ChartArea2,+ ChartLine,+ CreditCard,+ FileContent,+ Flask,+ GamingConsole,+ Gift,+ Heart,+ Icon,+ LifeRing,+ MarketingTarget,+ MobilePhone,+ MoneyBill,+ Msgs,+ PaperPlane,+ ShieldKeyhole,+ Sparkle3,+ Trophy,+ TV,+ UsersSettings,+} from "@dub/ui";++export const industryInterests: {+ id: IndustryInterest;+ icon: Icon;+ label: string;+}[] = [+ {+ id: IndustryInterest.AI,+ label: "AI",+ icon: Sparkle3,+ },+ {+ id: IndustryInterest.SaaS,+ label: "SaaS",+ icon: Sparkle3,+ },+ {+ id: IndustryInterest.Sales,+ label: "Sales",+ icon: ChartArea2,+ },+ {+ id: IndustryInterest.DevTool,+ label: "Dev Tools",+ icon: BracketsCurly,+ },+ {+ id: IndustryInterest.Marketing,+ label: "Marketing",+ icon: MarketingTarget,+ },+ {+ id: IndustryInterest.Ecommerce,+ label: "Ecommerce",+ icon: CreditCard,+ },+ {+ id: IndustryInterest.Creative_And_Design,+ label: "Creative & Design",+ icon: Brush,+ },+ {+ id: IndustryInterest.Productivity_Software,+ label: "Productivity Software",+ icon: BriefcaseFill,+ },+ {+ id: IndustryInterest.Gaming,+ label: "Gaming",+ icon: GamingConsole,+ },+ {+ id: IndustryInterest.Finance,+ label: "Finance",+ icon: MoneyBill,+ },+ {+ id: IndustryInterest.Customer_Service_And_Support,+ label: "Customer Service & Support",+ icon: LifeRing,+ },+ {+ id: IndustryInterest.Content_Management,+ label: "Content Management",+ icon: FileContent,+ },+ {+ id: IndustryInterest.Analytics_And_Data,+ label: "Analytics & Data",+ icon: ChartLine,+ },+ {+ id: IndustryInterest.Security,+ label: "Security",+ icon: ShieldKeyhole,+ },+ {+ id: IndustryInterest.Social_Media,+ label: "Social Media",+ icon: Msgs,+ },+ {+ id: IndustryInterest.Education_And_Learning,+ label: "Education & Learning",+ icon: BookOpen,+ },+ {+ id: IndustryInterest.Entertainment_And_Media,+ label: "Entertainment & Media",+ icon: TV,+ },+ {+ id: IndustryInterest.Consumer_Tech,+ label: "Consumer Tech",+ icon: MobilePhone,+ },+ {+ id: IndustryInterest.Sports,+ label: "Sports",+ icon: Trophy,+ },+ {+ id: IndustryInterest.Health_And_Fitness,+ label: "Health & Fitness",+ icon: Heart,+ },+ {+ id: IndustryInterest.Food_And_Beverage,+ label: "Food & Beverage",+ icon: Gift,+ },+ {+ id: IndustryInterest.Travel_And_Lifestyle,+ label: "Travel & Lifestyle",+ icon: PaperPlane,+ },+ {+ id: IndustryInterest.Human_Resources,+ label: "Human Resources",+ icon: UsersSettings,+ },+ {+ id: IndustryInterest.Science_And_Engineering,+ label: "Science & Engineering",+ icon: Flask,+ },+];diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.tsindex 818631891a..49ddf9966b 100644--- a/apps/web/lib/zod/schemas/partners.ts+++ b/apps/web/lib/zod/schemas/partners.ts@@ -240,12 +240,15 @@ export const PartnerOnlinePresenceSchema = z.object({tiktokVerifiedAt: z.date().nullish(),});+export const MAX_PARTNER_INDUSTRY_INTERESTS = 8;+export const PartnerProfileSchema = z.object({monthlyTraffic: z.nativeEnum(MonthlyTraffic).describe("The partner's monthly traffic."),industryInterests: z.array(z.nativeEnum(IndustryInterest))+ .max(MAX_PARTNER_INDUSTRY_INTERESTS).describe("The partner's industry interests."),preferredEarningStructure: z.array(z.nativeEnum(PreferredEarningStructure))diff --git a/packages/ui/src/hooks/use-scroll-progress.ts b/packages/ui/src/hooks/use-scroll-progress.tsindex b45fcdb05f..894abf13e0 100644--- a/packages/ui/src/hooks/use-scroll-progress.ts+++ b/packages/ui/src/hooks/use-scroll-progress.ts@@ -10,6 +10,7 @@ export function useScrollProgress(const [scrollProgress, setScrollProgress] = useState(1);const updateScrollProgress = useCallback(() => {+ console.log("updateScrollProgress", ref.current);if (!ref.current) return;const scroll =direction === "vertical" ? ref.current.scrollTop : ref.current.scrollLeft;