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.

Merge branch 'main' into discounts

Kiran K30b13ad33bec
diff --cc apps/web/app/app.dub.co/embed/referrals/utils.ts
index db77124e50,38560cb362..c5ffb04589
--- a/apps/web/app/app.dub.co/embed/referrals/utils.ts
+++ b/apps/web/app/app.dub.co/embed/referrals/utils.ts
@@@ -1,6 -1,6 +1,6 @@@
- import { embedToken } from "@/lib/embed/embed-token";
+ import { referralsEmbedToken } from "@/lib/embed/referrals/token-class";
+import { determinePartnerDiscount } from "@/lib/partners/determine-partner-discount";
import { determinePartnerReward } from "@/lib/partners/determine-partner-reward";
-import { DiscountSchema } from "@/lib/zod/schemas/discount";
import { prisma } from "@dub/prisma";
import { notFound } from "next/navigation";
@@@ -28,17 -29,23 +28,28 @@@ export const getReferralsEmbedData = as
notFound();
}
- const [reward, discount] = await Promise.all([
- const [reward, payouts] = await Promise.all([
++ const [reward, discount, payouts] = await Promise.all([
determinePartnerReward({
programId,
partnerId,
event: "sale",
}),
+ determinePartnerDiscount({
+ programId,
+ partnerId,
+ }),
++
+ prisma.payout.groupBy({
+ by: ["status"],
+ _sum: {
+ amount: true,
+ },
+ where: {
+ programId,
+ partnerId,
+ },
+ }),
]);
const { program, links } = programEnrollment;
diff --cc packages/prisma/schema/program.prisma
index 030ee4bf39,78e2726cf0..1bfc976a2f
--- a/packages/prisma/schema/program.prisma
+++ b/packages/prisma/schema/program.prisma
@@@ -38,9 -38,10 +38,11 @@@ model Program
type ProgramType @default(affiliate)
cookieLength Int @default(90)
holdingPeriodDays Int @default(0) // number of days to wait before earnings are added to a payout
- defaultRewardId String? // default reward for the program
+ defaultRewardId String? @unique // default reward for the program
+ defaultDiscountId String? @unique // default discount for the program
landerData Json? @db.Json
+ termsUrl String? @db.LongText
+ ageVerification Int?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt