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 coupon deletion

Kiran K2edcffa90b0a
diff --git a/apps/web/app/(ee)/api/cron/links/delete-promotion-codes/route.ts b/apps/web/app/(ee)/api/cron/links/delete-promotion-codes/route.ts
index e5825fd9a4..63564d7264 100644
--- a/apps/web/app/(ee)/api/cron/links/delete-promotion-codes/route.ts
+++ b/apps/web/app/(ee)/api/cron/links/delete-promotion-codes/route.ts
@@ -116,10 +116,7 @@ export async function POST(req: Request) {
const results = await Promise.allSettled(
linksChunk.map((link) =>
disableStripePromotionCode({
- workspace: {
- id: workspace.id,
- stripeConnectId: workspace.stripeConnectId,
- },
+ workspace,
promotionCode: link.couponCode,
}),
),
diff --git a/apps/web/lib/api/links/bulk-delete-links.ts b/apps/web/lib/api/links/bulk-delete-links.ts
index efe2142872..55b9ef9da2 100644
--- a/apps/web/lib/api/links/bulk-delete-links.ts
+++ b/apps/web/lib/api/links/bulk-delete-links.ts
@@ -45,18 +45,11 @@ export async function bulkDeleteLinks({
},
}),
- workspace.stripeConnectId
- ? links
- .filter((link) => link.couponCode)
- .map((link) =>
- disableStripePromotionCode({
- workspace: {
- id: workspace.id,
- stripeConnectId: workspace.stripeConnectId,
- },
- promotionCode: link.couponCode,
- }),
- )
- : [],
+ ...links.map((link) =>
+ disableStripePromotionCode({
+ workspace,
+ promotionCode: link.couponCode,
+ }),
+ ),
]);
}
diff --git a/apps/web/lib/api/links/delete-link.ts b/apps/web/lib/api/links/delete-link.ts
index 7cc3e75485..1f2b59936c 100644
--- a/apps/web/lib/api/links/delete-link.ts
+++ b/apps/web/lib/api/links/delete-link.ts
@@ -54,10 +54,7 @@ export async function deleteLink(linkId: string) {
workspace &&
disableStripePromotionCode({
- workspace: {
- id: workspace.id,
- stripeConnectId: workspace.stripeConnectId,
- },
+ workspace,
promotionCode: link.couponCode,
}),
]),
diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.ts
index db07a6a1f1..4c082a3f4b 100644
--- a/apps/web/lib/zod/schemas/links.ts
+++ b/apps/web/lib/zod/schemas/links.ts
@@ -695,12 +695,6 @@ export const LinkSchema = z
.number()
.default(0)
.describe("The number of leads that converted to paying customers."),
- couponCode: z
- .string()
- .nullable()
- .describe(
- "The Stripe coupon code linked to this partner link, used for coupon code-based tracking.",
- ),
sales: z
.number()
.default(0)
diff --git a/apps/web/lib/zod/schemas/partner-profile.ts b/apps/web/lib/zod/schemas/partner-profile.ts
index 0c5d1ea0b7..d584590e55 100644
--- a/apps/web/lib/zod/schemas/partner-profile.ts
+++ b/apps/web/lib/zod/schemas/partner-profile.ts
@@ -82,9 +82,9 @@ export const PartnerProfileLinkSchema = LinkSchema.pick({
sales: true,
saleAmount: true,
comments: true,
- couponCode: true,
}).extend({
createdAt: z.string().or(z.date()),
+ couponCode: z.string().nullable(),
});
export const PartnerProfileCustomerSchema = CustomerEnrichedSchema.pick({