Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Follow Up for dub referrral embed (#20427)

Amit Sharmac654795a3ec1
diff --git a/apps/web/app/(use-page-wrapper)/refer/page.tsx b/apps/web/app/(use-page-wrapper)/refer/page.tsx
index 16c5ad8814a..dd2cd012c78 100644
--- a/apps/web/app/(use-page-wrapper)/refer/page.tsx
+++ b/apps/web/app/(use-page-wrapper)/refer/page.tsx
@@ -1,10 +1,16 @@
import { getTranslate } from "app/_utils";
+import type { Metadata } from "next";
import Shell from "@calcom/features/shell/Shell";
import { IS_DUB_REFERRALS_ENABLED } from "@calcom/lib/constants";
import { DubReferralsPage } from "./DubReferralsPage";
+export const metadata: Metadata = {
+ title: "Cal.com referral program - Earn money by sharing your link",
+ description: "Earn 20% recurring commissions for a full year by referring others to Cal.com, while giving your referrals 20% off for 12 months. Share your link and start earning today!",
+};
+
// Export the appropriate component based on the feature flag
export default async function ReferralsPage() {
const t = await getTranslate();
diff --git a/apps/web/app/api/generate-referral-link/route.ts b/apps/web/app/api/generate-referral-link/route.ts
deleted file mode 100644
index 1390060a393..00000000000
--- a/apps/web/app/api/generate-referral-link/route.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import { defaultResponderForAppDir } from "app/api/defaultResponderForAppDir";
-import { cookies, headers } from "next/headers";
-import { NextResponse } from "next/server";
-
-import { dub } from "@calcom/features/auth/lib/dub";
-import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
-import prisma from "@calcom/prisma";
-
-import { buildLegacyRequest } from "@lib/buildLegacyCtx";
-
-async function postHandler() {
- const headersList = await headers();
- const cookiesList = await cookies();
- const legacyReq = buildLegacyRequest(headersList, cookiesList);
-
- const session = await getServerSession({ req: legacyReq });
-
- if (!session?.user?.username) {
- return NextResponse.json({ message: "Unauthorized" }, { status: 401 });
- }
-
- try {
- const { shortLink } = await dub.links.get({
- externalId: `ext_${session.user.id.toString()}`,
- });
- return NextResponse.json({ shortLink });
- } catch (error) {
- console.log("Referral link not found, creating...");
- }
-
- const { id: referralLinkId, shortLink } = await dub.links.create({
- domain: "refer.cal.com",
- key: session.user.username,
- url: "https://cal.com",
- externalId: session.user.id.toString(), // @see https://d.to/externalId
- trackConversion: true, // enable conversion tracking @see https://d.to/conversions
- });
-
- /*
- Even though we are relying in externalId for retrieving the referral link,
- we still save the referralLinkId in the database for future reference.
- E.g. we can use this to tell how many users created a referral link.
- */
- await prisma.user.update({
- where: {
- id: session.user.id,
- },
- data: {
- referralLinkId,
- },
- });
-
- return NextResponse.json({ shortLink });
-}
-
-export const POST = defaultResponderForAppDir(postHandler);
diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json
index dfb4c49080d..b209949ce05 100644
--- a/apps/web/public/static/locales/en/common.json
+++ b/apps/web/public/static/locales/en/common.json
@@ -3028,8 +3028,8 @@
"inactive_team_plan": "Inactive team plan",
"inactive_team_plan_description": "Your team plan is inactive. Check your subcription or reach out to customer support",
"limited_access_trial_mode": "Limited access during trial. Feature available after trial ends.",
- "earn_20_percent_affiliate": "Earn 20% Affiliate",
"referral_program": "Referral Program",
+ "earn_twenty_percent_referral": "Earn 20% referral",
"dub_disabled_error_message": "You need a Dub API Key and Program Id to use this page.",
"uid": "UID",
"link": "Link",
diff --git a/packages/features/shell/useBottomNavItems.ts b/packages/features/shell/useBottomNavItems.ts
index 838c13c8ed1..2dab02c885c 100644
--- a/packages/features/shell/useBottomNavItems.ts
+++ b/packages/features/shell/useBottomNavItems.ts
@@ -38,7 +38,7 @@ export function useBottomNavItems({
},
IS_DUB_REFERRALS_ENABLED
? {
- name: "earn_20_percent_affiliate",
+ name: "earn_twenty_percent_referral",
href: "/refer",
icon: "gift",
}