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 get-reward-or-throw.ts

Kiran K9e6a3b416db6
diff --git a/apps/web/lib/api/partners/get-reward-or-throw.ts b/apps/web/lib/api/partners/get-reward-or-throw.ts
index d44cd3a64e..68cf91439d 100644
--- a/apps/web/lib/api/partners/get-reward-or-throw.ts
+++ b/apps/web/lib/api/partners/get-reward-or-throw.ts
@@ -1,34 +1,19 @@
import { RewardSchema } from "@/lib/zod/schemas/rewards";
import { prisma } from "@dub/prisma";
-import { Reward } from "@prisma/client";
import { DubApiError } from "../errors";
-export async function getRewardOrThrow(
- {
- rewardId,
- programId,
- }: {
- rewardId: string;
- programId: string;
- },
- {
- includePartnersCount = false,
- }: {
- includePartnersCount?: boolean;
- } = {},
-) {
- const reward = (await prisma.reward.findUnique({
+export async function getRewardOrThrow({
+ rewardId,
+ programId,
+}: {
+ rewardId: string;
+ programId: string;
+}) {
+ const reward = await prisma.reward.findUnique({
where: {
id: rewardId,
},
- ...(includePartnersCount && {
- include: {
- _count: {
- select: { partners: true },
- },
- },
- }),
- })) as Reward & { _count?: { partners: number } };
+ });
if (!reward) {
throw new DubApiError({
@@ -44,10 +29,5 @@ export async function getRewardOrThrow(
});
}
- return RewardSchema.parse({
- ...reward,
- ...(includePartnersCount && {
- partnersCount: reward._count?.partners,
- }),
- });
+ return RewardSchema.parse(reward);
}