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.

some fixes after testing

Kiran Kbce917a02bea
diff --git a/apps/web/app/(ee)/api/cron/discounts/enqueue-coupon-code-create-jobs/route.ts b/apps/web/app/(ee)/api/cron/discounts/enqueue-coupon-code-create-jobs/route.ts
index e704e968de..aae4ec9709 100644
--- a/apps/web/app/(ee)/api/cron/discounts/enqueue-coupon-code-create-jobs/route.ts
+++ b/apps/web/app/(ee)/api/cron/discounts/enqueue-coupon-code-create-jobs/route.ts
@@ -64,7 +64,7 @@ export async function POST(req: Request) {
where: {
groupId: group.id,
...(cursor && {
- createdAt: {
+ id: {
gt: cursor,
},
}),
@@ -81,7 +81,7 @@ export async function POST(req: Request) {
},
take: PAGE_SIZE,
orderBy: {
- createdAt: "asc",
+ id: "asc",
},
});
diff --git a/apps/web/app/(ee)/api/cron/discounts/enqueue-coupon-code-delete-jobs/route.ts b/apps/web/app/(ee)/api/cron/discounts/enqueue-coupon-code-delete-jobs/route.ts
index 05ff639f14..69ca6ebc3d 100644
--- a/apps/web/app/(ee)/api/cron/discounts/enqueue-coupon-code-delete-jobs/route.ts
+++ b/apps/web/app/(ee)/api/cron/discounts/enqueue-coupon-code-delete-jobs/route.ts
@@ -47,7 +47,7 @@ export async function POST(req: Request) {
where: {
groupId: group.id,
...(cursor && {
- createdAt: {
+ id: {
gt: cursor,
},
}),
@@ -63,7 +63,7 @@ export async function POST(req: Request) {
},
take: PAGE_SIZE,
orderBy: {
- createdAt: "asc",
+ id: "asc",
},
});
@@ -83,7 +83,6 @@ export async function POST(req: Request) {
for (const linkChunk of linkChunks) {
await enqueueCouponCodeDeleteJobs(linkChunk);
-
await new Promise((resolve) => setTimeout(resolve, 2000));
}
}
diff --git a/apps/web/lib/api/partners/get-partners.ts b/apps/web/lib/api/partners/get-partners.ts
index cffd102bcc..aa90748a9b 100644
--- a/apps/web/lib/api/partners/get-partners.ts
+++ b/apps/web/lib/api/partners/get-partners.ts
@@ -92,6 +92,7 @@ export async function getPartners(filters: PartnerFilters) {
'domain', l.domain,
'key', l.\`key\`,
'shortLink', l.shortLink,
+ 'couponCode', l.couponCode,
'url', l.url,
'clicks', CAST(l.clicks AS SIGNED),
'leads', CAST(l.leads AS SIGNED),
diff --git a/apps/web/lib/stripe/create-stripe-coupon.ts b/apps/web/lib/stripe/create-stripe-coupon.ts
index 015f0eb34e..d944af69de 100644
--- a/apps/web/lib/stripe/create-stripe-coupon.ts
+++ b/apps/web/lib/stripe/create-stripe-coupon.ts
@@ -59,10 +59,13 @@ export async function createStripeCoupon({
return stripeCoupon;
} catch (error) {
- console.log(`Failed create Stripe coupon for workspace ${workspace.id}.`, {
- error,
- discount,
- });
+ console.error(
+ `Failed create Stripe coupon for workspace ${workspace.id}.`,
+ {
+ error,
+ discount,
+ },
+ );
return null;
}
diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.ts
index cd64e2d166..595948b105 100644
--- a/apps/web/lib/zod/schemas/links.ts
+++ b/apps/web/lib/zod/schemas/links.ts
@@ -544,6 +544,10 @@ export const LinkSchema = z
.string()
.nullable()
.describe("The ID of the partner the short link is associated with."),
+ couponCode: z
+ .string()
+ .nullable()
+ .describe("The coupon code associated with the short link."),
archived: z
.boolean()
.default(false)
diff --git a/apps/web/lib/zod/schemas/programs.ts b/apps/web/lib/zod/schemas/programs.ts
index 88625c992f..0116ed9df9 100644
--- a/apps/web/lib/zod/schemas/programs.ts
+++ b/apps/web/lib/zod/schemas/programs.ts
@@ -87,8 +87,7 @@ export const ProgramPartnerLinkSchema = LinkSchema.pick({
leads: true,
sales: true,
saleAmount: true,
-}).extend({
- couponCode: z.string().nullable(),
+ couponCode: true,
});
export const ProgramEnrollmentSchema = z.object({
diff --git a/apps/web/ui/partners/groups/reward-discount-partners-card.tsx b/apps/web/ui/partners/groups/reward-discount-partners-card.tsx
index cc7aae2c0c..3fa1e1a138 100644
--- a/apps/web/ui/partners/groups/reward-discount-partners-card.tsx
+++ b/apps/web/ui/partners/groups/reward-discount-partners-card.tsx
@@ -22,6 +22,7 @@ export function RewardDiscountPartnersCard({ groupId }: { groupId: string }) {
},
});
+
return (
<div className="border-border-subtle rounded-xl border bg-white text-sm shadow-sm">
<button