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.

Task completion logic

Tim Wilson282c2249e1f7
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
index fd8d589079..d9114fa8f4 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx
@@ -1,6 +1,7 @@
"use client";
import usePartnerProfile from "@/lib/swr/use-partner-profile";
+import useProgramEnrollments from "@/lib/swr/use-program-enrollments";
import { PageContent } from "@/ui/layout/page-content";
import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
import { useMergePartnerAccountsModal } from "@/ui/partners/merge-accounts/merge-partner-accounts-modal";
@@ -12,6 +13,7 @@ import { ProfileDiscoveryGuide } from "./profile-discovery-guide";
export function ProfileSettingsPageClient() {
const { partner } = usePartnerProfile();
+ const { programEnrollments } = useProgramEnrollments();
return (
<PageContent
@@ -24,7 +26,12 @@ export function ProfileSettingsPageClient() {
controls={<Controls />}
>
<PageWidthWrapper className="mb-20 flex flex-col gap-6">
- {partner && <ProfileDiscoveryGuide partner={partner} />}
+ {partner && programEnrollments && (
+ <ProfileDiscoveryGuide
+ partner={partner}
+ programEnrollments={programEnrollments}
+ />
+ )}
<ProfileDetailsForm partner={partner} />
<AboutYouForm partner={partner} />
<HowYouWorkForm partner={partner} />
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-discovery-guide.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-discovery-guide.tsx
index 41cc5d672d..a08f7e21b5 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-discovery-guide.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-discovery-guide.tsx
@@ -1,4 +1,6 @@
-import { PartnerProps } from "@/lib/types";
+import { ONLINE_PRESENCE_FIELDS } from "@/lib/partners/online-presence";
+import { PARTNER_DISCOVERY_MIN_COMMISSIONS } from "@/lib/partners/partner-profile";
+import { PartnerProps, ProgramEnrollmentProps } from "@/lib/types";
import {
Button,
ChevronUp,
@@ -10,43 +12,59 @@ import {
import { cn, isClickOnInteractiveChild } from "@dub/utils";
import { motion } from "motion/react";
import Link from "next/link";
-import { HTMLProps, useState } from "react";
+import { HTMLProps, useMemo, useState } from "react";
-export function ProfileDiscoveryGuide({ partner }: { partner: PartnerProps }) {
+export function ProfileDiscoveryGuide({
+ partner,
+ programEnrollments,
+}: {
+ partner: PartnerProps;
+ programEnrollments: ProgramEnrollmentProps[];
+}) {
if (partner.discoverableAt) return null;
const [isExpanded, setIsExpanded] = useState(false);
- const tasks = [
- {
- label: "Add basic profile info",
- completed: true,
- },
- {
- label: "Verify your website or social account",
- href: "#sites",
- completed: false,
- },
- {
- label: "Write your bio",
- href: "#about",
- completed: false,
- },
- {
- label: "Select your industry interests",
- href: "#interests",
- completed: false,
- },
- {
- label: "Choose your sales channels",
- href: "#channels",
- completed: false,
- },
- {
- label: "Earn $100 in commissions",
- completed: false,
- },
- ];
+ const tasks = useMemo(
+ () => [
+ {
+ label: "Add basic profile info",
+ completed: true,
+ },
+ {
+ label: "Verify your website or social account",
+ href: "#sites",
+ completed: ONLINE_PRESENCE_FIELDS.some(
+ (field) => field.data(partner).verified,
+ ),
+ },
+ {
+ label: "Write your bio",
+ href: "#about",
+ completed: !!partner.description,
+ },
+ {
+ label: "Select your industry interests",
+ href: "#interests",
+ completed: Boolean(partner.industryInterests?.length),
+ },
+ {
+ label: "Choose your sales channels",
+ href: "#channels",
+ completed: Boolean(partner.salesChannels?.length),
+ },
+ {
+ label: "Earn $100 in commissions",
+ completed:
+ programEnrollments.reduce(
+ (acc, programEnrollment) =>
+ acc + programEnrollment.totalCommissions,
+ 0,
+ ) >= PARTNER_DISCOVERY_MIN_COMMISSIONS,
+ },
+ ],
+ [partner, programEnrollments],
+ );
const completedTasks = tasks.filter(({ completed }) => completed);
diff --git a/apps/web/lib/partners/partner-profile.ts b/apps/web/lib/partners/partner-profile.ts
index 68b3f9682f..f8e533ee44 100644
--- a/apps/web/lib/partners/partner-profile.ts
+++ b/apps/web/lib/partners/partner-profile.ts
@@ -32,6 +32,8 @@ import {
UsersSettings,
} from "@dub/ui/icons";
+export const PARTNER_DISCOVERY_MIN_COMMISSIONS = 100_00;
+
export const industryInterests: {
id: IndustryInterest;
icon: Icon;