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

Kiran Kbf3f2dcc1e54
diff --git a/apps/web/app/api/customers/route.ts b/apps/web/app/api/customers/route.ts
index 940845b76a..aec6bd721b 100644
--- a/apps/web/app/api/customers/route.ts
+++ b/apps/web/app/api/customers/route.ts
@@ -91,13 +91,9 @@ export const GET = withWorkspace(
distinct: ["customerId"],
});
- const firstPurchaseMap = new Map();
-
- firstPurchases.forEach((purchase) => {
- if (!firstPurchaseMap.has(purchase.customerId)) {
- firstPurchaseMap.set(purchase.customerId, purchase);
- }
- });
+ const firstPurchaseMap = new Map(
+ firstPurchases.map((purchase) => [purchase.customerId, purchase]),
+ );
customers.forEach((customer) => {
discounts.set(
diff --git a/apps/web/lib/api/customers/determine-customer-discount.ts b/apps/web/lib/api/customers/determine-customer-discount.ts
index 47191fe0b3..9d53859fa0 100644
--- a/apps/web/lib/api/customers/determine-customer-discount.ts
+++ b/apps/web/lib/api/customers/determine-customer-discount.ts
@@ -17,7 +17,7 @@ export const determineCustomerDiscount = ({
firstPurchase,
}: {
customerLink: CustomerWithLink["link"];
- firstPurchase: Pick<Commission, "createdAt"> | null;
+ firstPurchase?: Pick<Commission, "createdAt"> | null;
}) => {
// Use the partner discount or fallback to the program discount
const discount =