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.

Filter `GET /partners` by email

Steven Tey6529d7284be1
diff --git a/apps/web/lib/api/partners/get-partners.ts b/apps/web/lib/api/partners/get-partners.ts
index 7bf31da15f..bcbd738c0e 100644
--- a/apps/web/lib/api/partners/get-partners.ts
+++ b/apps/web/lib/api/partners/get-partners.ts
@@ -35,6 +35,7 @@ export async function getPartners(filters: PartnerFilters) {
status,
country,
search,
+ email,
tenantId,
partnerIds,
page,
@@ -133,7 +134,7 @@ export async function getPartners(filters: PartnerFilters) {
WHERE
pe.programId = ${programId}
${status ? Prisma.sql`AND pe.status = ${status}` : Prisma.sql`AND pe.status IN ('approved', 'invited')`}
- ${tenantId ? Prisma.sql`AND pe.tenantId = ${tenantId}` : Prisma.sql``}
+ ${tenantId ? Prisma.sql`AND pe.tenantId = ${tenantId}` : email ? Prisma.sql`AND p.email = ${email}` : Prisma.sql``}
${country ? Prisma.sql`AND p.country = ${country}` : Prisma.sql``}
${
search
diff --git a/apps/web/lib/zod/schemas/partners.ts b/apps/web/lib/zod/schemas/partners.ts
index 23c4216650..2aeadbe604 100644
--- a/apps/web/lib/zod/schemas/partners.ts
+++ b/apps/web/lib/zod/schemas/partners.ts
@@ -134,11 +134,18 @@ export const getPartnersQuerySchema = z
.default("desc")
.describe("The sort order. The default is `desc`.")
.openapi({ example: "desc" }),
+ email: z
+ .string()
+ .optional()
+ .describe(
+ "Filter the partner list based on the partner's `email`. The value must be a string. Takes precedence over `search`.",
+ )
+ .openapi({ example: "[email protected]" }),
tenantId: z
.string()
.optional()
.describe(
- "A case-sensitive filter on the list based on the partner's `tenantId` field. The value must be a string. Takes precedence over `search`.",
+ "Filter the partner list based on the partner's `tenantId`. The value must be a string. Takes precedence over `email` and `search`.",
)
.openapi({ example: "1K0NM7HCN944PEMZ3CQPH43H8" }),
includeExpandedFields: booleanQuerySchema