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-commission.ts

Kiran Kbde9cd5ba453
diff --git a/apps/web/lib/actions/partners/create-commission.ts b/apps/web/lib/actions/partners/create-commission.ts
index fd86e640da..5922033263 100644
--- a/apps/web/lib/actions/partners/create-commission.ts
+++ b/apps/web/lib/actions/partners/create-commission.ts
@@ -31,8 +31,6 @@ export const createCommissionAction = authActionClient
leadEventName,
} = parsedInput;
- const finalLeadEventDate = leadEventDate ?? saleEventDate ?? new Date();
-
const [programEnrollment, customer] = await Promise.all([
getProgramEnrollmentOrThrow({
programId,
@@ -92,6 +90,7 @@ export const createCommissionAction = authActionClient
const existingLeadEvent = await getLeadEvent({
customerId,
});
+
if (existingLeadEvent && existingLeadEvent.data.length > 0) {
// if there is an existing lead event, we can use that for the clickEvent details
clickEvent = clickEventSchemaTB.parse(existingLeadEvent.data[0]);
@@ -107,6 +106,8 @@ export const createCommissionAction = authActionClient
}),
});
+ const finalLeadEventDate = leadEventDate ?? saleEventDate ?? new Date();
+
const clickData = await recordClick({
req: dummyRequest,
linkId,