The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
final changes
Steven Tey9408769048c2
diff --git a/apps/web/lib/actions/partners/delete-reward.ts b/apps/web/lib/actions/partners/delete-reward.tsindex 3aeb0da3ce..6c36bffac2 100644--- a/apps/web/lib/actions/partners/delete-reward.ts+++ b/apps/web/lib/actions/partners/delete-reward.ts@@ -29,30 +29,31 @@ export const deleteRewardAction = authActionClientthrow new Error(`Default ${reward.event} reward cannot be deleted.`);}- const defaultReward = await prisma.reward.findFirst({- where: {- programId,- event: reward.event,- default: true,- },- });-const rewardIdColumn = REWARD_EVENT_COLUMN_MAPPING[reward.event];await prisma.$transaction(async (tx) => {- // 1. Update current associations+ // 1. Find the default reward for the same event (if it exists)+ const defaultReward = await tx.reward.findFirst({+ where: {+ programId,+ event: reward.event,+ default: true,+ },+ });++ // 2. Update current associationsawait tx.programEnrollment.updateMany({where: {programId,[rewardIdColumn]: reward.id,},data: {- // Replace the reward with the default reward if it exists+ // Replace the current reward with the default reward for the same event if it exists[rewardIdColumn]: defaultReward ? defaultReward.id : null,},});- // 2. Finally, delete the reward+ // 3. Finally, delete the current rewardawait tx.reward.delete({where: {id: reward.id,diff --git a/apps/web/lib/actions/partners/update-reward.ts b/apps/web/lib/actions/partners/update-reward.tsindex 04fd97b174..e1091176ce 100644--- a/apps/web/lib/actions/partners/update-reward.ts+++ b/apps/web/lib/actions/partners/update-reward.ts@@ -19,7 +19,7 @@ export const updateRewardAction = authActionClientamount,maxDuration,type,- maxAmount,+ // maxAmount, // TODO: Temporarily disabling maxAmount for now – until more users ask for itincludedPartnerIds,excludedPartnerIds,} = parsedInput;@@ -29,13 +29,14 @@ export const updateRewardAction = authActionClientconst programId = getDefaultProgramIdOrThrow(workspace);- if (maxAmount && maxAmount < amount) {- throw new Error(- "Max reward amount cannot be less than the reward amount.",- );- }+ // TODO: Temporarily disabling maxAmount for now – until more users ask for it+ // if (maxAmount && maxAmount < amount) {+ // throw new Error(+ // "Max reward amount cannot be less than the reward amount.",+ // );+ // }- const reward = await getRewardOrThrow({+ await getRewardOrThrow({rewardId,programId,});@@ -58,7 +59,7 @@ export const updateRewardAction = authActionClientif (invalidPartnerIds.length > 0) {throw new Error(- `Invalid partner IDs provided: ${invalidPartnerIds.join(", ")}`,+ `Invalid partner IDs provided (partners must be enrolled in the program): ${invalidPartnerIds.join(", ")}`,);}}@@ -71,7 +72,7 @@ export const updateRewardAction = authActionClienttype,amount,maxDuration,- maxAmount,+ // maxAmount, // TODO: Temporarily disabling maxAmount for now – until more users ask for it},});diff --git a/apps/web/ui/partners/add-edit-reward-sheet.tsx b/apps/web/ui/partners/add-edit-reward-sheet.tsxindex 6391950298..f07531936a 100644--- a/apps/web/ui/partners/add-edit-reward-sheet.tsx+++ b/apps/web/ui/partners/add-edit-reward-sheet.tsx@@ -514,7 +514,7 @@ function RewardSheetContent({);}-// Temporarily hiding this in the UI for now – until more users ask for it+// TODO: Temporarily disabling maxAmount for now – until more users ask for itfunction RewardLimitSection({event,register,