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.

improve getPayoutEligibilityFilter to use programEnrollment relation

Steven Teydc337acf0f9d
diff --git a/apps/web/lib/api/payouts/payout-eligibility-filter.ts b/apps/web/lib/api/payouts/payout-eligibility-filter.ts
index 66f881028f..5623dcd1e2 100644
--- a/apps/web/lib/api/payouts/payout-eligibility-filter.ts
+++ b/apps/web/lib/api/payouts/payout-eligibility-filter.ts
@@ -43,14 +43,9 @@ export function getPayoutEligibilityFilter({
case "external":
return {
...commonWhere,
- partner: {
- programs: {
- some: {
- programId: program.id,
- tenantId: {
- not: null,
- },
- },
+ programEnrollment: {
+ tenantId: {
+ not: null,
},
},
};
@@ -59,26 +54,22 @@ export function getPayoutEligibilityFilter({
case "hybrid":
return {
...commonWhere,
- partner: {
- OR: [
- {
+ OR: [
+ {
+ partner: {
payoutsEnabledAt: {
not: null,
},
},
- {
- payoutsEnabledAt: null,
- programs: {
- some: {
- programId: program.id,
- tenantId: {
- not: null,
- },
- },
+ },
+ {
+ programEnrollment: {
+ tenantId: {
+ not: null,
},
},
- ],
- },
+ },
+ ],
};
default:
diff --git a/apps/web/lib/constants/program.ts b/apps/web/lib/constants/program.ts
index 7dc3372398..e303669667 100644
--- a/apps/web/lib/constants/program.ts
+++ b/apps/web/lib/constants/program.ts
@@ -1,3 +1,5 @@
+import { ACME_PROGRAM_ID } from "@dub/utils";
+
export const PROGRAM_ONBOARDING_PARTNERS_LIMIT = 5;
export const MAX_PARTNERS_INVITES_PER_REQUEST = 50;
@@ -40,3 +42,8 @@ export const PROGRAM_APPLICATION_IMAGE_ALLOWED_TYPES = [
] as const;
export const PROGRAM_APPLICATION_IMAGE_ALLOWED_TYPES_LABEL = "JPG, PNG, WebP";
+
+export const EXTERNAL_PAYOUTS_PROGRAM_IDS = [
+ ACME_PROGRAM_ID, // Acme
+ "prog_1JWVR53QX1NM7NDEK62E3J19H", // Polymarket
+];
diff --git a/apps/web/ui/webhooks/add-edit-webhook-form.tsx b/apps/web/ui/webhooks/add-edit-webhook-form.tsx
index 649706baba..262289658b 100644
--- a/apps/web/ui/webhooks/add-edit-webhook-form.tsx
+++ b/apps/web/ui/webhooks/add-edit-webhook-form.tsx
@@ -1,6 +1,7 @@
"use client";
import { clientAccessCheck } from "@/lib/client-access-check";
+import { EXTERNAL_PAYOUTS_PROGRAM_IDS } from "@/lib/constants/program";
import useProgram from "@/lib/swr/use-program";
import useWorkspace from "@/lib/swr/use-workspace";
import { NewWebhook, WebhookProps } from "@/lib/types";
@@ -128,11 +129,11 @@ export default function AddEditWebhookForm({
? PROGRAM_LEVEL_WEBHOOK_TRIGGERS.filter(
(trigger) =>
trigger !== "payout.confirmed" ||
- program?.payoutMode !== "internal",
+ EXTERNAL_PAYOUTS_PROGRAM_IDS.includes(defaultProgramId),
)
: []),
],
- [defaultProgramId, program?.payoutMode],
+ [defaultProgramId],
);
return (