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.

remove test, rearrange files

Steven Tey1b5281267eca
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx
index 0416dc9afd..6d61a6fefb 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx
@@ -101,7 +101,7 @@ export function ProfileDetailsForm({ partner }: { partner?: PartnerProps }) {
</SettingsRow>
<SettingsRow
- id="sites"
+ id="platforms"
heading="Website and socials"
description="Add your website and social accounts you use to share links. Verifying as many platforms as possible helps build trust with programs."
>
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/use-partner-discovery-requirements.ts b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/use-partner-discovery-requirements.ts
index cb1a68dc27..cce1a4a837 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/use-partner-discovery-requirements.ts
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/use-partner-discovery-requirements.ts
@@ -1,4 +1,4 @@
-import { getPartnerProfileChecklistProgress } from "@/lib/network/get-discoverability-requirements";
+import { getPartnerProfileChecklistProgress } from "@/lib/network/get-partner-profile-checklist-progress";
import usePartnerProfile from "@/lib/swr/use-partner-profile";
import useProgramEnrollments from "@/lib/swr/use-program-enrollments";
import { useMemo } from "react";
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/header-controls.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/header-controls.tsx
index 9caa5baa51..65e4574cd5 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/header-controls.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/header-controls.tsx
@@ -1,7 +1,7 @@
"use client";
import { acceptProgramInviteAction } from "@/lib/actions/partners/accept-program-invite";
-import { getPartnerProfileChecklistProgress } from "@/lib/network/get-discoverability-requirements";
+import { getPartnerProfileChecklistProgress } from "@/lib/network/get-partner-profile-checklist-progress";
import { mutatePrefix } from "@/lib/swr/mutate";
import usePartnerProfile from "@/lib/swr/use-partner-profile";
import useProgramEnrollments from "@/lib/swr/use-program-enrollments";
diff --git a/apps/web/lib/actions/partners/create-program-application.ts b/apps/web/lib/actions/partners/create-program-application.ts
index 0e18a141e0..5423193278 100644
--- a/apps/web/lib/actions/partners/create-program-application.ts
+++ b/apps/web/lib/actions/partners/create-program-application.ts
@@ -6,7 +6,7 @@ import { notifyPartnerApplication } from "@/lib/api/partners/notify-partner-appl
import { getIP } from "@/lib/api/utils/get-ip";
import { getSession } from "@/lib/auth";
import { qstash } from "@/lib/cron";
-import { getPartnerProfileChecklistProgress } from "@/lib/network/get-discoverability-requirements";
+import { getPartnerProfileChecklistProgress } from "@/lib/network/get-partner-profile-checklist-progress";
import {
formatApplicationFormData,
formatWebsiteAndSocialsFields,
diff --git a/apps/web/lib/network/get-discoverability-requirements.ts b/apps/web/lib/network/get-discoverability-requirements.ts
index 2dccca325c..4dac5f23bc 100644
--- a/apps/web/lib/network/get-discoverability-requirements.ts
+++ b/apps/web/lib/network/get-discoverability-requirements.ts
@@ -28,46 +28,6 @@ export const partnerIsNotBanned = (
return programEnrollments.every((pe) => pe.status !== "banned");
};
-export type DiscoverabilityRequirement = {
- label: string;
- href?: string;
- completed: boolean;
-};
-
-export function getPartnerProfileChecklistProgress({
- partner,
- programEnrollments,
-}: {
- partner: Pick<
- PartnerProps,
- | "image"
- | "description"
- | "monthlyTraffic"
- | "preferredEarningStructures"
- | "salesChannels"
- | "platforms"
- >;
- programEnrollments: Pick<
- EnrolledPartnerProps,
- "programId" | "status" | "totalCommissions"
- >[];
-}) {
- const tasks = getDiscoverabilityRequirements({
- partner,
- programEnrollments,
- });
-
- const completedCount = tasks.filter(({ completed }) => completed).length;
- const totalCount = tasks.length;
-
- return {
- tasks,
- completedCount,
- totalCount,
- isComplete: completedCount === totalCount,
- };
-}
-
export function getDiscoverabilityRequirements({
partner,
programEnrollments,
@@ -85,7 +45,11 @@ export function getDiscoverabilityRequirements({
EnrolledPartnerProps,
"programId" | "status" | "totalCommissions"
>[];
-}): DiscoverabilityRequirement[] {
+}): {
+ label: string;
+ href?: string;
+ completed: boolean;
+}[] {
return [
{
label: "Upload your logo",
@@ -94,7 +58,7 @@ export function getDiscoverabilityRequirements({
},
{
label: "Verify at least 2 social accounts/website",
- href: "#sites",
+ href: "#platforms",
completed:
PARTNER_PLATFORM_FIELDS.filter(
(field) => field.data(partner.platforms).verified,
diff --git a/apps/web/lib/network/get-partner-profile-checklist-progress.ts b/apps/web/lib/network/get-partner-profile-checklist-progress.ts
new file mode 100644
index 0000000000..392faf3649
--- /dev/null
+++ b/apps/web/lib/network/get-partner-profile-checklist-progress.ts
@@ -0,0 +1,36 @@
+import { EnrolledPartnerProps, PartnerProps } from "../types";
+import { getDiscoverabilityRequirements } from "./get-discoverability-requirements";
+
+export function getPartnerProfileChecklistProgress({
+ partner,
+ programEnrollments,
+}: {
+ partner: Pick<
+ PartnerProps,
+ | "image"
+ | "description"
+ | "monthlyTraffic"
+ | "preferredEarningStructures"
+ | "salesChannels"
+ | "platforms"
+ >;
+ programEnrollments: Pick<
+ EnrolledPartnerProps,
+ "programId" | "status" | "totalCommissions"
+ >[];
+}) {
+ const tasks = getDiscoverabilityRequirements({
+ partner,
+ programEnrollments,
+ });
+
+ const completedCount = tasks.filter(({ completed }) => completed).length;
+ const totalCount = tasks.length;
+
+ return {
+ tasks,
+ completedCount,
+ totalCount,
+ isComplete: completedCount === totalCount,
+ };
+}
diff --git a/apps/web/tests/misc/partner-profile-checklist-progress.test.ts b/apps/web/tests/misc/partner-profile-checklist-progress.test.ts
deleted file mode 100644
index 9b0f1ff56a..0000000000
--- a/apps/web/tests/misc/partner-profile-checklist-progress.test.ts
+++ /dev/null
@@ -1,93 +0,0 @@
-import {
- EXCLUDED_PROGRAM_IDS,
- PARTNER_NETWORK_MIN_COMMISSIONS_CENTS,
-} from "@/lib/constants/partner-profile";
-import { getPartnerProfileChecklistProgress } from "@/lib/network/get-discoverability-requirements";
-import { describe, expect, it } from "vitest";
-
-type ChecklistInput = Parameters<typeof getPartnerProfileChecklistProgress>[0];
-
-const basePartner: ChecklistInput["partner"] = {
- image: null,
- description: null,
- monthlyTraffic: null,
- preferredEarningStructures: [],
- salesChannels: [],
- platforms: [],
-};
-
-const completedPartner: ChecklistInput["partner"] = {
- ...basePartner,
- image: "https://example.com/logo.png",
- description: "Creator profile",
- monthlyTraffic: "OneHundredThousandPlus",
- preferredEarningStructures: ["Per_Sale"],
- salesChannels: ["Blogs"],
- platforms: [
- {
- type: "website",
- identifier: "https://example.com",
- verifiedAt: new Date(),
- platformId: null,
- subscribers: BigInt(0),
- posts: BigInt(0),
- views: BigInt(0),
- },
- {
- type: "youtube",
- identifier: "UC1234567890",
- verifiedAt: new Date(),
- platformId: null,
- subscribers: BigInt(0),
- posts: BigInt(0),
- views: BigInt(0),
- },
- ],
-};
-
-describe("getPartnerProfileChecklistProgress", () => {
- it("returns incomplete progress for an incomplete profile", () => {
- const result = getPartnerProfileChecklistProgress({
- partner: basePartner,
- programEnrollments: [],
- });
-
- expect(result.isComplete).toBe(false);
- expect(result.completedCount).toBeLessThan(result.totalCount);
- });
-
- it("returns complete progress when all checklist tasks are complete", () => {
- const result = getPartnerProfileChecklistProgress({
- partner: completedPartner,
- programEnrollments: [
- {
- programId: "prog_non_excluded",
- status: "approved",
- totalCommissions: PARTNER_NETWORK_MIN_COMMISSIONS_CENTS,
- },
- ],
- });
-
- expect(result.isComplete).toBe(true);
- expect(result.completedCount).toBe(result.totalCount);
- expect(result.completedCount).toBe(8);
- });
-
- it("handles the excluded-program edge case consistently", () => {
- expect(EXCLUDED_PROGRAM_IDS.length).toBeGreaterThan(0);
-
- const result = getPartnerProfileChecklistProgress({
- partner: completedPartner,
- programEnrollments: [
- {
- programId: EXCLUDED_PROGRAM_IDS[0],
- status: "approved",
- totalCommissions: PARTNER_NETWORK_MIN_COMMISSIONS_CENTS,
- },
- ],
- });
-
- expect(result.isComplete).toBe(false);
- expect(result.completedCount).toBe(7);
- });
-});