fix: Follow Up for dub referrral embed (#20427)
* fix: Follow Up for dub referrral embed * fix meta title and description
This commit is contained in:
1 parent
a7b1981cf1
commit
c654795a3e
4 files changed
+8
-58
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user