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.

standardize discount to programEnrollment only

Steven Teyc359eeaf8065
diff --git a/apps/web/app/app.dub.co/embed/utils.ts b/apps/web/app/app.dub.co/embed/utils.ts
index b554a7787c..55210bda10 100644
--- a/apps/web/app/app.dub.co/embed/utils.ts
+++ b/apps/web/app/app.dub.co/embed/utils.ts
@@ -15,11 +15,7 @@ export const getEmbedData = async (token: string) => {
id: linkId,
},
include: {
- program: {
- include: {
- discounts: true,
- },
- },
+ program: true,
programEnrollment: {
select: {
discount: true,
@@ -41,9 +37,9 @@ export const getEmbedData = async (token: string) => {
return {
program,
link,
- discount: DiscountSchema.parse(
- programEnrollment?.discount || program.discounts?.[0],
- ),
+ discount: programEnrollment?.discount
+ ? DiscountSchema.parse(programEnrollment?.discount)
+ : null,
earnings:
(program.commissionType === "percentage" ? link.saleAmount : link.sales) *
(program.commissionAmount / 100),
diff --git a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/page-client.tsx b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/page-client.tsx
index 3ddbd1a3b7..04adb27bc9 100644
--- a/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/page-client.tsx
+++ b/apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/page-client.tsx
@@ -71,7 +71,7 @@ export default function ProgramPageClient() {
{program ? (
<ProgramCommissionDescription
program={program}
- discount={programEnrollment?.discount || program.discounts?.[0]}
+ discount={programEnrollment?.discount}
/>
) : (
<div className="h-7 w-5/6 animate-pulse rounded-md bg-neutral-200" />
diff --git a/apps/web/lib/api/programs/get-program-enrollment-or-throw.ts b/apps/web/lib/api/programs/get-program-enrollment-or-throw.ts
index 3fa7340923..f6ddb2e868 100644
--- a/apps/web/lib/api/programs/get-program-enrollment-or-throw.ts
+++ b/apps/web/lib/api/programs/get-program-enrollment-or-throw.ts
@@ -10,11 +10,7 @@ export async function getProgramEnrollmentOrThrow({
programId: string;
}) {
const include: Prisma.ProgramEnrollmentInclude = {
- program: {
- include: {
- discounts: true,
- },
- },
+ program: true,
link: true,
discount: true,
};
diff --git a/apps/web/lib/zod/schemas/discount.ts b/apps/web/lib/zod/schemas/discount.ts
index 36d98e108d..e4f98df9d0 100644
--- a/apps/web/lib/zod/schemas/discount.ts
+++ b/apps/web/lib/zod/schemas/discount.ts
@@ -2,7 +2,8 @@ import { CommissionInterval, CommissionType } from "@dub/prisma/client";
import { z } from "zod";
export const DiscountSchema = z.object({
- id: z.string(),
+ couponId: z.string().nullable(),
+ couponTestId: z.string().nullable(),
amount: z.number(),
type: z.nativeEnum(CommissionType),
duration: z.number().nullable(),