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.

fill in missing statuses with 0

Steven Tey04802d7a2a4b
diff --git a/apps/web/app/api/programs/[programId]/partners/count/route.ts b/apps/web/app/api/programs/[programId]/partners/count/route.ts
index 70bc258b39..9776802b4e 100644
--- a/apps/web/app/api/programs/[programId]/partners/count/route.ts
+++ b/apps/web/app/api/programs/[programId]/partners/count/route.ts
@@ -35,6 +35,13 @@ export const GET = withWorkspace(async ({ workspace, params }) => {
{} as Record<ProgramEnrollmentStatus | "all", number>,
);
+ // fill in missing statuses with 0
+ Object.values(ProgramEnrollmentStatus).forEach((status) => {
+ if (!(status in counts)) {
+ counts[status] = 0;
+ }
+ });
+
counts.all = programEnrollments.reduce((acc, p) => acc + p._count, 0);
return NextResponse.json(counts);
diff --git a/apps/web/app/api/programs/[programId]/payouts/count/route.ts b/apps/web/app/api/programs/[programId]/payouts/count/route.ts
index 14ebc5fd0a..985b1221f8 100644
--- a/apps/web/app/api/programs/[programId]/payouts/count/route.ts
+++ b/apps/web/app/api/programs/[programId]/payouts/count/route.ts
@@ -42,6 +42,13 @@ export const GET = withWorkspace(
{} as Record<PayoutStatus | "all", number>,
);
+ // fill in missing statuses with 0
+ Object.values(PayoutStatus).forEach((status) => {
+ if (!(status in counts)) {
+ counts[status] = 0;
+ }
+ });
+
counts.all = payouts.reduce((acc, p) => acc + p._count, 0);
return NextResponse.json(counts);