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.

Sync scheduled commissions

Kiran K9bacbae295be
diff --git a/apps/web/lib/partnerstack/import-commissions.ts b/apps/web/lib/partnerstack/import-commissions.ts
index edb39ba01e..d2d8fed388 100644
--- a/apps/web/lib/partnerstack/import-commissions.ts
+++ b/apps/web/lib/partnerstack/import-commissions.ts
@@ -26,6 +26,7 @@ const toDubStatus: Record<
approved: "processed",
declined: "canceled",
paid: "paid",
+ scheduled: "pending",
};
export async function importCommissions(payload: PartnerStackImportPayload) {
@@ -53,9 +54,20 @@ export async function importCommissions(payload: PartnerStackImportPayload) {
let currentStartingAfter = startingAfter;
while (hasMore && processedBatches < MAX_BATCHES) {
- const commissions = await partnerStackApi.listCommissions({
- startingAfter: currentStartingAfter,
- });
+ // Fetch both regular commissions and scheduled commissions
+ const [regularCommissions, scheduledCommissions] = await Promise.all([
+ partnerStackApi.listCommissions({
+ startingAfter: currentStartingAfter,
+ }),
+
+ partnerStackApi.listCommissions({
+ startingAfter: currentStartingAfter,
+ status: "scheduled",
+ }),
+ ]);
+
+ // Combine both sets of commissions
+ const commissions = [...regularCommissions, ...scheduledCommissions];
if (commissions.length === 0) {
hasMore = false;
diff --git a/apps/web/lib/partnerstack/schemas.ts b/apps/web/lib/partnerstack/schemas.ts
index aa9c9aece0..a9c6195068 100644
--- a/apps/web/lib/partnerstack/schemas.ts
+++ b/apps/web/lib/partnerstack/schemas.ts
@@ -94,7 +94,14 @@ export const partnerStackCommission = z.object({
currency: z.string(),
})
.nullable(),
- reward_status: z.enum(["hold", "pending", "approved", "declined", "paid"]),
+ reward_status: z.enum([
+ "hold",
+ "pending",
+ "approved",
+ "declined",
+ "paid",
+ "scheduled",
+ ]),
partnership: z.object({
email: z.string(),
}),