The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix deleting partner referral rewards
Pedro Ladeiraaa8bb2d48ed3
diff --git a/apps/web/lib/actions/partners/delete-reward.ts b/apps/web/lib/actions/partners/delete-reward.tsindex 629abe7c11..d8eb7f904e 100644--- a/apps/web/lib/actions/partners/delete-reward.ts+++ b/apps/web/lib/actions/partners/delete-reward.ts@@ -61,14 +61,18 @@ export const deleteRewardAction = authActionClient},});- await tx.linkReward.updateMany({- where: {- [rewardIdColumn]: reward.id,- },- data: {- [rewardIdColumn]: null,- },- });+ // Referral and custom rewards live on the group and enrollment, not on LinkReward.+ const linkLevelRewardEvents = new Set(["click", "lead", "sale"]);+ if (linkLevelRewardEvents.has(reward.event)) {+ await tx.linkReward.updateMany({+ where: {+ [rewardIdColumn]: reward.id,+ },+ data: {+ [rewardIdColumn]: null,+ },+ });+ }// soft delete reward, we will hard delete it in the cron jobawait tx.reward.update({