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.

fix Sale events validation incorrectly blocks lead commission creation

Kiran K3bd0ed5ca2e3
diff --git a/apps/web/lib/actions/partners/create-manual-commission.ts b/apps/web/lib/actions/partners/create-manual-commission.ts
index 7442f10c5f..2398531829 100644
--- a/apps/web/lib/actions/partners/create-manual-commission.ts
+++ b/apps/web/lib/actions/partners/create-manual-commission.ts
@@ -222,13 +222,13 @@ export const createManualCommissionAction = authActionClient
const recordSaleEvents =
commissionType === "sale" && existingSaleEvents.length > 0;
- if (existingSaleEvents.length > 5) {
- throw new Error(
- `You can only backfill up to 5 sale events. Found ${existingSaleEvents.length} existing sale events.`,
- );
- }
-
if (recordSaleEvents) {
+ if (existingSaleEvents.length > 5) {
+ throw new Error(
+ `You can only backfill up to 5 sale events. Found ${existingSaleEvents.length} existing sale events.`,
+ );
+ }
+
const saleEventsData = existingSaleEvents.map((existingSaleEvent) =>
saleEventSchemaTBWithTimestamp.parse({
...clickEventData,