The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update delete-reward.ts
Kiran K2f2c9f2f8b3e
diff --git a/apps/web/lib/actions/partners/delete-reward.ts b/apps/web/lib/actions/partners/delete-reward.tsindex 791151e163..a4705f53b9 100644--- a/apps/web/lib/actions/partners/delete-reward.ts+++ b/apps/web/lib/actions/partners/delete-reward.ts@@ -30,28 +30,25 @@ export const deleteRewardAction = authActionClientconst rewardIdColumn = REWARD_EVENT_COLUMN_MAPPING[reward.event];await prisma.$transaction(async (tx) => {- // 1. Find the default reward for the same event (if it exists)- const defaultReward = await tx.reward.findFirst({+ await tx.partnerGroup.update({+ // @ts-ignorewhere: {- programId,- event: reward.event,- default: true,+ [rewardIdColumn]: reward.id,+ },+ data: {+ [rewardIdColumn]: null,},});- // 2. Update current associationsawait tx.programEnrollment.updateMany({where: {- programId,[rewardIdColumn]: reward.id,},data: {- // Replace the current reward with the default reward for the same event if it exists- [rewardIdColumn]: defaultReward ? defaultReward.id : null,+ [rewardIdColumn]: null,},});- // 3. Finally, delete the current rewardawait tx.reward.delete({where: {id: reward.id,