Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(seats): update thirdPartyStripeSubscriptionId to remaining org on revoke
Richie McIlroy65547e611980
diff --git a/apps/web/actions/organization/toggle-pro-seat.ts b/apps/web/actions/organization/toggle-pro-seat.tsindex 1b2a12cc7..bd60b93d0 100644--- a/apps/web/actions/organization/toggle-pro-seat.ts+++ b/apps/web/actions/organization/toggle-pro-seat.ts@@ -121,6 +121,31 @@ export async function toggleProSeat(.update(users).set({ thirdPartyStripeSubscriptionId: null }).where(eq(users.id, member.userId));+ } else {+ const [remainingOrg] = await tx+ .select({ stripeSubscriptionId: users.stripeSubscriptionId })+ .from(organizationMembers)+ .innerJoin(+ organizations,+ eq(organizationMembers.organizationId, organizations.id),+ )+ .innerJoin(users, eq(organizations.ownerId, users.id))+ .where(+ and(+ eq(organizationMembers.userId, member.userId),+ eq(organizationMembers.hasProSeat, true),+ ),+ )+ .limit(1);++ if (remainingOrg?.stripeSubscriptionId) {+ await tx+ .update(users)+ .set({+ thirdPartyStripeSubscriptionId: remainingOrg.stripeSubscriptionId,+ })+ .where(eq(users.id, member.userId));+ }}}});