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.

more cleanup

Kiran K93181afb5c08
diff --git a/apps/web/app/api/embed/referrals/links/route.ts b/apps/web/app/api/embed/referrals/links/route.ts
index 6ac62b815d..a163fc0036 100644
--- a/apps/web/app/api/embed/referrals/links/route.ts
+++ b/apps/web/app/api/embed/referrals/links/route.ts
@@ -1,7 +1,7 @@
import { DubApiError, ErrorCodes } from "@/lib/api/errors";
import { createLink, processLink } from "@/lib/api/links";
-import { PARTNER_LINKS_LIMIT } from "@/lib/api/partners/constants";
import { parseRequestBody } from "@/lib/api/utils";
+import { PARTNER_LINKS_LIMIT } from "@/lib/embed/constants";
import { withReferralsEmbedToken } from "@/lib/embed/referrals/auth";
import { createPartnerLinkSchema } from "@/lib/zod/schemas/partners";
import { ReferralsEmbedLinkSchema } from "@/lib/zod/schemas/referrals-embed";
diff --git a/apps/web/app/api/partner-profile/programs/[programId]/links/route.ts b/apps/web/app/api/partner-profile/programs/[programId]/links/route.ts
index e738224425..45b0865ad1 100644
--- a/apps/web/app/api/partner-profile/programs/[programId]/links/route.ts
+++ b/apps/web/app/api/partner-profile/programs/[programId]/links/route.ts
@@ -1,9 +1,9 @@
import { DubApiError, ErrorCodes } from "@/lib/api/errors";
import { createLink, processLink } from "@/lib/api/links";
-import { PARTNER_LINKS_LIMIT } from "@/lib/api/partners/constants";
import { getProgramEnrollmentOrThrow } from "@/lib/api/programs/get-program-enrollment-or-throw";
import { parseRequestBody } from "@/lib/api/utils";
import { withPartnerProfile } from "@/lib/auth/partner";
+import { PARTNER_LINKS_LIMIT } from "@/lib/embed/constants";
import { PartnerProfileLinkSchema } from "@/lib/zod/schemas/partner-profile";
import { createPartnerLinkSchema } from "@/lib/zod/schemas/partners";
import { getApexDomain } from "@dub/utils";
diff --git a/apps/web/app/app.dub.co/embed/referrals/links-list.tsx b/apps/web/app/app.dub.co/embed/referrals/links-list.tsx
index 9a720ea7cc..7deb380523 100644
--- a/apps/web/app/app.dub.co/embed/referrals/links-list.tsx
+++ b/apps/web/app/app.dub.co/embed/referrals/links-list.tsx
@@ -1,3 +1,4 @@
+import { PARTNER_LINKS_LIMIT } from "@/lib/embed/constants";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
import { Button, CopyButton, Table, Users, useTable } from "@dub/ui";
import { Pen2, Plus2 } from "@dub/ui/icons";
@@ -16,6 +17,8 @@ export function ReferralsEmbedLinksList({
onCreateLink,
onEditLink,
}: Props) {
+ const linksLimitReached = links.length >= PARTNER_LINKS_LIMIT;
+
const { table, ...tableProps } = useTable({
data: links,
columns: [
@@ -63,6 +66,8 @@ export function ReferralsEmbedLinksList({
className="h-7 w-7 p-1.5"
icon={<Plus2 className="text-white" />}
onClick={onCreateLink}
+ disabled={linksLimitReached}
+ disabledTooltip={`You have reached the limit of ${PARTNER_LINKS_LIMIT} referral links.`}
/>
),
minSize: 60,
diff --git a/apps/web/lib/api/partners/constants.ts b/apps/web/lib/api/partners/constants.ts
deleted file mode 100644
index 0438d6d8f3..0000000000
--- a/apps/web/lib/api/partners/constants.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const PARTNER_LINKS_LIMIT = 5;
diff --git a/apps/web/lib/embed/constants.ts b/apps/web/lib/embed/constants.ts
index 0f29254cb9..213880c52f 100644
--- a/apps/web/lib/embed/constants.ts
+++ b/apps/web/lib/embed/constants.ts
@@ -9,3 +9,5 @@ export const REFERRALS_EMBED_PUBLIC_TOKEN_COOKIE_NAME =
// Analytics embed token
export const ANALYTICS_EMBED_PUBLIC_TOKEN_COOKIE_NAME =
"dub_analytics_embed_token";
+
+export const PARTNER_LINKS_LIMIT = 5;