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 build

Kiran K4694a4d356e7
diff --git a/apps/web/lib/actions/partners/start-tolt-import.ts b/apps/web/lib/actions/partners/start-tolt-import.ts
index 05358084c7..22b79594fc 100644
--- a/apps/web/lib/actions/partners/start-tolt-import.ts
+++ b/apps/web/lib/actions/partners/start-tolt-import.ts
@@ -8,12 +8,14 @@ import { authActionClient } from "../safe-action";
const schema = z.object({
workspaceId: z.string(),
+ toltProgramId: z.string().trim().min(1),
});
export const startToltImportAction = authActionClient
.schema(schema)
- .action(async ({ ctx }) => {
- const { workspace } = ctx;
+ .action(async ({ ctx, parsedInput }) => {
+ const { workspace, user } = ctx;
+ const { toltProgramId } = parsedInput;
const programId = getDefaultProgramIdOrThrow(workspace);
@@ -39,7 +41,9 @@ export const startToltImportAction = authActionClient
}
await toltImporter.queue({
- action: "import-affiliates",
- programId,
+ userId: user.id,
+ programId: program.id,
+ toltProgramId,
+ action: "import-partners",
});
});
diff --git a/apps/web/lib/tolt/update-stripe-customers.ts b/apps/web/lib/tolt/update-stripe-customers.ts
index 5a41c99c75..b8af2cbc9e 100644
--- a/apps/web/lib/tolt/update-stripe-customers.ts
+++ b/apps/web/lib/tolt/update-stripe-customers.ts
@@ -3,6 +3,7 @@ import { Customer, Project } from "@dub/prisma/client";
import Stripe from "stripe";
import { stripeAppClient } from "../stripe";
import { MAX_BATCHES, toltImporter } from "./importer";
+import { ToltImportPayload } from "./types";
const CUSTOMERS_PER_BATCH = 20;
@@ -12,13 +13,9 @@ const stripe = stripeAppClient({
// Tolt API doesn't return the Stripe customer ID,
// so we'll search for Stripe customers by email and update the customer record with the Stripe customer ID, if found.
-export async function updateStripeCustomers({
- programId,
- startingAfter,
-}: {
- programId: string;
- startingAfter?: string;
-}) {
+export async function updateStripeCustomers(payload: ToltImportPayload) {
+ let { programId, startingAfter } = payload;
+
const { workspace } = await prisma.program.findUniqueOrThrow({
where: {
id: programId,
@@ -87,8 +84,10 @@ export async function updateStripeCustomers({
startingAfter = customers[customers.length - 1].id;
}
+ delete payload?.startingAfter;
+
await toltImporter.queue({
- programId,
+ ...payload,
action: hasMore ? "update-stripe-customers" : "cleanup-partners",
...(hasMore && { startingAfter }),
});
diff --git a/apps/web/ui/modals/import-tolt-modal.tsx b/apps/web/ui/modals/import-tolt-modal.tsx
index fca49c9013..f2b1614336 100644
--- a/apps/web/ui/modals/import-tolt-modal.tsx
+++ b/apps/web/ui/modals/import-tolt-modal.tsx
@@ -242,6 +242,7 @@ function ProgramInfo({
await executeAsync({
workspaceId,
+ toltProgramId: toltProgram.id,
});
};