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.

Update route.ts

Kiran K0d3dd23f44e7
diff --git a/apps/web/app/(ee)/api/partner-profile/payouts/count/route.ts b/apps/web/app/(ee)/api/partner-profile/payouts/count/route.ts
index fea09ab733..e4090cf0a1 100644
--- a/apps/web/app/(ee)/api/partner-profile/payouts/count/route.ts
+++ b/apps/web/app/(ee)/api/partner-profile/payouts/count/route.ts
@@ -5,52 +5,50 @@ import { PayoutStatus, Prisma } from "@dub/prisma/client";
import { NextResponse } from "next/server";
// GET /api/partner-profile/payouts/count – get payouts count for a partner
-export const GET = withPartnerProfile(
- async ({ partner, searchParams, partnerUser }) => {
- const { programId, groupBy, status } =
- payoutsCountQuerySchema.parse(searchParams);
-
- const where: Prisma.PayoutWhereInput = {
- partnerId: partner.id,
- ...(programId && { programId }),
- };
-
- if (groupBy === "status") {
- const payouts = await prisma.payout.groupBy({
- by: ["status"],
- where: where,
- _count: true,
- _sum: {
- amount: true,
- },
- });
-
- const counts = payouts.map((p) => ({
- status: p.status,
- count: p._count,
- amount: p._sum.amount,
- }));
-
- Object.values(PayoutStatus).forEach((status) => {
- if (!counts.find((p) => p.status === status)) {
- counts.push({
- status,
- count: 0,
- amount: 0,
- });
- }
- });
-
- return NextResponse.json(counts);
- }
-
- const count = await prisma.payout.count({
- where: {
- ...where,
- status,
+export const GET = withPartnerProfile(async ({ partner, searchParams }) => {
+ const { programId, groupBy, status } =
+ payoutsCountQuerySchema.parse(searchParams);
+
+ const where: Prisma.PayoutWhereInput = {
+ partnerId: partner.id,
+ ...(programId && { programId }),
+ };
+
+ if (groupBy === "status") {
+ const payouts = await prisma.payout.groupBy({
+ by: ["status"],
+ where: where,
+ _count: true,
+ _sum: {
+ amount: true,
},
});
- return NextResponse.json(count);
- },
-);
+ const counts = payouts.map((p) => ({
+ status: p.status,
+ count: p._count,
+ amount: p._sum.amount,
+ }));
+
+ Object.values(PayoutStatus).forEach((status) => {
+ if (!counts.find((p) => p.status === status)) {
+ counts.push({
+ status,
+ count: 0,
+ amount: 0,
+ });
+ }
+ });
+
+ return NextResponse.json(counts);
+ }
+
+ const count = await prisma.payout.count({
+ where: {
+ ...where,
+ status,
+ },
+ });
+
+ return NextResponse.json(count);
+});