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 create-and-enroll-partner.ts

Kiran K61117ec02b55
diff --git a/apps/web/lib/api/partners/create-and-enroll-partner.ts b/apps/web/lib/api/partners/create-and-enroll-partner.ts
index 00ff7e77ff..a51054e2f9 100644
--- a/apps/web/lib/api/partners/create-and-enroll-partner.ts
+++ b/apps/web/lib/api/partners/create-and-enroll-partner.ts
@@ -54,7 +54,7 @@ export const createAndEnrollPartner = async ({
// Check if the tenantId is already enrolled in the program
if (partner.tenantId && !programEnrollment) {
- programEnrollment = await prisma.programEnrollment.findUnique({
+ const tenantEnrollment = await prisma.programEnrollment.findUnique({
where: {
tenantId_programId: {
tenantId: partner.tenantId,
@@ -62,6 +62,13 @@ export const createAndEnrollPartner = async ({
},
},
});
+
+ if (tenantEnrollment) {
+ throw new DubApiError({
+ message: `Partner with tenantId '${partner.tenantId}' already enrolled in this program.`,
+ code: "conflict",
+ });
+ }
}
if (programEnrollment) {