Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
♻️ Perform server side redirect when changing seat count
Luke Vella8a4832e5e8df
diff --git a/apps/web/src/app/[locale]/(space)/settings/billing/components/manage-seats-dialog.tsx b/apps/web/src/app/[locale]/(space)/settings/billing/components/manage-seats-dialog.tsxindex 92d60851d..9d08b2e60 100644--- a/apps/web/src/app/[locale]/(space)/settings/billing/components/manage-seats-dialog.tsx+++ b/apps/web/src/app/[locale]/(space)/settings/billing/components/manage-seats-dialog.tsx@@ -135,11 +135,7 @@ export function ManageSeatsDialog({const canRemoveSeats = newSeatCount >= usedSeats;const hasChanges = seatDelta !== 0;- const { execute: updateSeats, isPending } = useSafeAction(updateSeatsAction, {- onSuccess: ({ data }) => {- window.location.href = data.portalSessionUrl;- },- });+ const { execute: updateSeats, isPending } = useSafeAction(updateSeatsAction);const handleUpdate = async () => {updateSeats({ seatDelta });diff --git a/apps/web/src/features/billing/actions.ts b/apps/web/src/features/billing/actions.tsindex b7e7ad862..aa1fcdcf6 100644--- a/apps/web/src/features/billing/actions.ts+++ b/apps/web/src/features/billing/actions.ts@@ -1,5 +1,6 @@"use server";+import { redirect } from "next/navigation";import { z } from "zod";import { getSpaceSubscription } from "@/features/billing/data";import { createStripeSubscriptionUpdateConfirmation } from "@/features/billing/utils";@@ -65,24 +66,24 @@ export const updateSeatsAction = spaceActionClient});}- try {- const portalSessionUrl = await createStripeSubscriptionUpdateConfirmation(- {- customerId: ctx.user.customerId,- newSeatCount,- subscriptionId: subscription.id,- subscriptionItemId: subscription.subscriptionItemId,- },- );+ let portalSessionUrl: string | undefined;- return {- portalSessionUrl,- };+ try {+ portalSessionUrl = await createStripeSubscriptionUpdateConfirmation({+ customerId: ctx.user.customerId,+ newSeatCount,+ subscriptionId: subscription.id,+ subscriptionItemId: subscription.subscriptionItemId,+ });} catch (error) {throw new AppError({code: "INTERNAL_SERVER_ERROR",message: "Failed to create billing portal session",cause: error,});+ } finally {+ if (portalSessionUrl) {+ redirect(portalSessionUrl);+ }}});diff --git a/turbo.json b/turbo.jsonindex 2e3b8697c..2fd69e940 100644--- a/turbo.json+++ b/turbo.json@@ -116,10 +116,8 @@"SMTP_SECURE","SMTP_TLS_ENABLED","SMTP_USER",- "STRIPE_MONTHLY_PRICE","STRIPE_SECRET_KEY","STRIPE_SIGNING_SECRET",- "STRIPE_YEARLY_PRICE","SUPPORT_EMAIL"]}