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.

fix generate referral link

Steven Tey8b901279d17b
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/referrals/generate-button.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/referrals/generate-button.tsx
index 88047e6915..cc3c746ead 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/referrals/generate-button.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/referrals/generate-button.tsx
@@ -15,8 +15,8 @@ export function GenerateButton() {
generateReferralLink,
{
onSuccess: () => {
- toast.success("Referral link generated.");
router.refresh();
+ toast.success("Referral link generated.");
},
onError: ({ error }) => {
toast.error(error.serverError?.serverError);
diff --git a/apps/web/lib/actions/generate-referral-link.ts b/apps/web/lib/actions/generate-referral-link.ts
index 71a64b3821..a3ea8afa85 100644
--- a/apps/web/lib/actions/generate-referral-link.ts
+++ b/apps/web/lib/actions/generate-referral-link.ts
@@ -3,6 +3,7 @@
import { linkConstructor } from "@dub/utils";
import { z } from "zod";
import { dub } from "../dub";
+import { prisma } from "../prisma";
import { authActionClient } from "./safe-action";
// Generate a new client secret for an integration
@@ -25,6 +26,15 @@ export const generateReferralLink = authActionClient
trackConversion: true,
});
+ await prisma.project.update({
+ where: {
+ id: workspace.id,
+ },
+ data: {
+ referralLinkId: createdLink.id,
+ },
+ });
+
return {
url: linkConstructor({
domain: createdLink.domain,
diff --git a/apps/web/lib/actions/get-referral-link.ts b/apps/web/lib/actions/get-referral-link.ts
index e3874bfcb4..4522cda702 100644
--- a/apps/web/lib/actions/get-referral-link.ts
+++ b/apps/web/lib/actions/get-referral-link.ts
@@ -1,8 +1,7 @@
import { dub } from "@/lib/dub";
import { prisma } from "@/lib/prisma";
-import { unstable_cache } from "next/cache";
-export const getReferralLink = unstable_cache(async (slug: string) => {
+export const getReferralLink = async (slug: string) => {
const workspace = await prisma.project.findUnique({
where: {
slug,
@@ -14,4 +13,4 @@ export const getReferralLink = unstable_cache(async (slug: string) => {
return await dub.links.get({
linkId: workspace.referralLinkId,
});
-});
+};