Skip to content

Commit 9840dd5

Browse files
committed
simplify if else logic + PartnerReactivated email
1 parent 28eb1b4 commit 9840dd5

2 files changed

Lines changed: 17 additions & 18 deletions

File tree

apps/web/app/(ee)/api/stripe/webhook/utils/update-workspace-plan.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -173,33 +173,31 @@ export async function updateWorkspacePlan({
173173
wouldLosePartnerAccess({
174174
currentPlan: workspace.plan,
175175
newPlan: newPlanName,
176-
})
176+
}) &&
177+
workspace.defaultProgramId
177178
) {
178-
if (workspace.defaultProgramId) {
179-
await deactivateProgram(workspace.defaultProgramId);
180-
}
179+
await deactivateProgram(workspace.defaultProgramId);
181180
}
182181

183182
// Reactivate all partners if the workspace gains partner access (Pro/Free -> Business/Enterprise)
184183
if (
185184
wouldGainPartnerAccess({
186185
currentPlan: workspace.plan,
187186
newPlan: newPlanName,
188-
})
187+
}) &&
188+
workspace.defaultProgramId
189189
) {
190-
if (workspace.defaultProgramId) {
191-
const response = await qstash.publishJSON({
192-
url: `${APP_DOMAIN_WITH_NGROK}/api/cron/partners/reactivate`,
193-
body: {
194-
programId: workspace.defaultProgramId,
195-
},
196-
deduplicationId: `reactivate-program-${workspace.defaultProgramId}`,
197-
});
190+
const response = await qstash.publishJSON({
191+
url: `${APP_DOMAIN_WITH_NGROK}/api/cron/partners/reactivate`,
192+
body: {
193+
programId: workspace.defaultProgramId,
194+
},
195+
deduplicationId: `reactivate-program-${workspace.defaultProgramId}`,
196+
});
198197

199-
console.log("Reactivation job enqueued.", {
200-
response,
201-
});
202-
}
198+
console.log("Reactivation job enqueued.", {
199+
response,
200+
});
203201
}
204202

205203
if (

packages/email/src/templates/partner-reactivated.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export default function PartnerReactivated({
5656

5757
<Text className="text-sm leading-6 text-neutral-600">
5858
Your referral links are now active again and will resume
59-
generating commissions. No action is needed on your end.
59+
generating commissions. Feel free to start sharing them with your
60+
audience again.
6061
</Text>
6162

6263
<Text className="text-sm leading-6 text-neutral-600">

0 commit comments

Comments
 (0)