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.

update workspace referralLinkId

Steven Teyfbf509cf7a14
diff --git a/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page.tsx b/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page.tsx
index 31fcdf52ce..dd55a0a991 100644
--- a/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page.tsx
@@ -13,7 +13,7 @@ export const dynamic = "auto";
export default async function ReferralsPage() {
const session = await getSession();
- const referralLinkId = session?.user["referralLinkId"];
+ const referralLinkId = session?.user.referralLinkId;
if (!referralLinkId)
return (
diff --git a/apps/web/lib/api/workspaces.ts b/apps/web/lib/api/workspaces.ts
index 26f64a70b3..8c3b5c39a4 100644
--- a/apps/web/lib/api/workspaces.ts
+++ b/apps/web/lib/api/workspaces.ts
@@ -1,5 +1,4 @@
import { deleteDomainAndLinks } from "@/lib/api/domains";
-import { dub } from "@/lib/dub";
import { prisma } from "@/lib/prisma";
import { storage } from "@/lib/storage";
import { cancelSubscription } from "@/lib/stripe";
@@ -15,10 +14,7 @@ import {
import { waitUntil } from "@vercel/functions";
export async function deleteWorkspace(
- workspace: Pick<
- WorkspaceProps,
- "id" | "slug" | "logo" | "stripeId" | "referralLinkId"
- >,
+ workspace: Pick<WorkspaceProps, "id" | "slug" | "logo" | "stripeId">,
) {
const [customDomains, defaultDomainLinks] = await Promise.all([
prisma.domain.findMany({
@@ -113,13 +109,6 @@ export async function deleteWorkspace(
storage.delete(workspace.logo.replace(`${R2_URL}/`, "")),
// if they have a Stripe subscription, cancel it
workspace.stripeId && cancelSubscription(workspace.stripeId),
- // set the referral link to `/deleted/[slug]`
- workspace.referralLinkId &&
- dub.links.update(workspace.referralLinkId, {
- key: `/deleted/${workspace.slug}-${workspace.id}`,
- archived: true,
- identifier: `/deleted/${workspace.slug}-${workspace.id}`,
- }),
// delete the workspace
prisma.project.delete({
where: {
@@ -142,10 +131,7 @@ export async function deleteWorkspace(
}
export async function deleteWorkspaceAdmin(
- workspace: Pick<
- WorkspaceProps,
- "id" | "slug" | "logo" | "stripeId" | "referralLinkId"
- >,
+ workspace: Pick<WorkspaceProps, "id" | "slug" | "logo" | "stripeId">,
) {
const [customDomains, defaultDomainLinks] = await Promise.all([
prisma.domain.findMany({
@@ -205,13 +191,6 @@ export async function deleteWorkspaceAdmin(
storage.delete(workspace.logo.replace(`${R2_URL}/`, "")),
// if they have a Stripe subscription, cancel it
workspace.stripeId && cancelSubscription(workspace.stripeId),
- // set the referral link to `/deleted/[slug]`
- workspace.referralLinkId &&
- dub.links.update(workspace.referralLinkId, {
- key: `/deleted/${workspace.slug}-${workspace.id}`,
- archived: true,
- identifier: `/deleted/${workspace.slug}-${workspace.id}`,
- }),
// delete the workspace
prisma.project.delete({
where: {
diff --git a/apps/web/lib/fetchers/index.ts b/apps/web/lib/fetchers/index.ts
index d34a1a0c79..503bef0c8d 100644
--- a/apps/web/lib/fetchers/index.ts
+++ b/apps/web/lib/fetchers/index.ts
@@ -37,7 +37,6 @@ export const getWorkspace = cache(async ({ slug }: { slug: string }) => {
logo: true,
usage: true,
usageLimit: true,
- referralLinkId: true,
plan: true,
stripeId: true,
billingCycleStart: true,
diff --git a/apps/web/lib/zod/schemas/workspaces.ts b/apps/web/lib/zod/schemas/workspaces.ts
index 4a9646d2db..da4f385469 100644
--- a/apps/web/lib/zod/schemas/workspaces.ts
+++ b/apps/web/lib/zod/schemas/workspaces.ts
@@ -65,11 +65,6 @@ export const WorkspaceSchema = z
aiUsage: z.number().describe("The AI usage of the workspace."),
aiLimit: z.number().describe("The AI limit of the workspace."),
- referralLinkId: z
- .string()
- .nullable()
- .describe("The ID of the referral link of the workspace."),
-
conversionEnabled: z
.boolean()
.describe(
diff --git a/apps/web/tests/utils/schema.ts b/apps/web/tests/utils/schema.ts
index 61b3d78eba..1974fe6f0c 100644
--- a/apps/web/tests/utils/schema.ts
+++ b/apps/web/tests/utils/schema.ts
@@ -75,7 +75,5 @@ export const expectedWorkspace: Partial<Project> = {
tagsLimit: expect.any(Number),
usersLimit: expect.any(Number),
- referralLinkId: expect.any(String),
-
createdAt: expect.any(String),
};
diff --git a/apps/web/ui/layout/sidebar/refer-button-rsc.tsx b/apps/web/ui/layout/sidebar/refer-button-rsc.tsx
index 6a0c165446..845823b1ce 100644
--- a/apps/web/ui/layout/sidebar/refer-button-rsc.tsx
+++ b/apps/web/ui/layout/sidebar/refer-button-rsc.tsx
@@ -4,7 +4,7 @@ import { ReferButton } from "./refer-button";
export async function ReferButtonRSC() {
const session = await getSession();
- const referralLinkId = session?.user["referralLinkId"];
+ const referralLinkId = session?.user.referralLinkId;
if (!referralLinkId) return null;