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 nullable customer

Steven Teye47d209c50f1
diff --git a/apps/web/app/api/partner-profile/programs/[programId]/earnings/route.ts b/apps/web/app/api/partner-profile/programs/[programId]/earnings/route.ts
index 6f660f0a0d..940ead6071 100644
--- a/apps/web/app/api/partner-profile/programs/[programId]/earnings/route.ts
+++ b/apps/web/app/api/partner-profile/programs/[programId]/earnings/route.ts
@@ -79,11 +79,14 @@ export const GET = withPartnerProfile(
const data = z.array(PartnerEarningsSchema).parse(
earnings.map((e) => ({
...e,
- customer: {
- ...e.customer,
- // fallback to a random name if the customer doesn't have an email
- email: e.customer?.email ?? e.customer?.name ?? generateRandomName(),
- },
+ customer: e.customer
+ ? {
+ ...e.customer,
+ // fallback to a random name if the customer doesn't have an email
+ email:
+ e.customer.email ?? e.customer.name ?? generateRandomName(),
+ }
+ : null,
})),
);