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.

Add tenantId filter to commissions API and schema

Kiran Kbf5641f744fb
diff --git a/apps/web/app/(ee)/api/commissions/route.ts b/apps/web/app/(ee)/api/commissions/route.ts
index d33eec7552..cffcc2a151 100644
--- a/apps/web/app/(ee)/api/commissions/route.ts
+++ b/apps/web/app/(ee)/api/commissions/route.ts
@@ -20,6 +20,7 @@ export const GET = withWorkspace(async ({ workspace, searchParams }) => {
customerId,
payoutId,
partnerId,
+ tenantId,
invoiceId,
groupId,
page,
@@ -67,6 +68,17 @@ export const GET = withWorkspace(async ({ workspace, searchParams }) => {
},
},
}),
+ ...(tenantId &&
+ !partnerId && {
+ partner: {
+ programs: {
+ some: {
+ tenantId,
+ programId,
+ },
+ },
+ },
+ }),
},
include: {
customer: true,
diff --git a/apps/web/lib/zod/schemas/commissions.ts b/apps/web/lib/zod/schemas/commissions.ts
index 46bdfbbd2c..a2e3affe27 100644
--- a/apps/web/lib/zod/schemas/commissions.ts
+++ b/apps/web/lib/zod/schemas/commissions.ts
@@ -64,6 +64,12 @@ export const getCommissionsQuerySchema = z
.string()
.optional()
.describe("Filter the list of commissions by the associated partner."),
+ tenantId: z
+ .string()
+ .optional()
+ .describe(
+ "Filter the list of commissions by the associated partner tenantId.",
+ ),
groupId: z
.string()
.optional()