diff --git a/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx b/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx index ed46268fae..4804f1b64e 100644 --- a/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx +++ b/apps/web/components/settings/platform/pricing/platform-pricing/index.tsx @@ -1,6 +1,7 @@ import { useRouter } from "next/navigation"; import { usePathname } from "next/navigation"; import type { ReactNode } from "react"; +import { useState } from "react"; import { ErrorCode } from "@calcom/lib/errorCodes"; import { showToast } from "@calcom/ui/components/toast"; @@ -17,6 +18,8 @@ export const PlatformPricing = ({ teamId, teamPlan, heading }: PlatformPricingPr const pathname = usePathname(); const currentPage = pathname?.split("/").pop(); const router = useRouter(); + const [loadingPlan, setLoadingPlan] = useState(null); + const { mutateAsync: createTeamSubscription, isPending: isCreateTeamSubscriptionLoading } = useSubscribeTeamToStripe({ onSuccess: (redirectUrl: string) => { @@ -24,6 +27,7 @@ export const PlatformPricing = ({ teamId, teamPlan, heading }: PlatformPricingPr }, onError: () => { showToast(ErrorCode.UnableToSubscribeToThePlatform, "error"); + setLoadingPlan(null); }, teamId, }); @@ -35,6 +39,7 @@ export const PlatformPricing = ({ teamId, teamPlan, heading }: PlatformPricingPr }, onError: () => { showToast(ErrorCode.UnableToSubscribeToThePlatform, "error"); + setLoadingPlan(null); }, teamId, }); @@ -44,6 +49,8 @@ export const PlatformPricing = ({ teamId, teamPlan, heading }: PlatformPricingPr return router.push("https://go.cal.com/quote"); } + setLoadingPlan(plan); + if (currentPage === "platform") { createTeamSubscription({ plan: plan.toLocaleUpperCase() }); } else { @@ -68,7 +75,10 @@ export const PlatformPricing = ({ teamId, teamPlan, heading }: PlatformPricingPr description={plan.description} pricing={plan.pricing} includes={plan.includes} - isLoading={isCreateTeamSubscriptionLoading || isUpgradeTeamSubscriptionLoading} + isLoading={ + loadingPlan === plan.plan && + (isCreateTeamSubscriptionLoading || isUpgradeTeamSubscriptionLoading) + } currentPlan={plan.plan.toLocaleLowerCase() === teamPlan} handleSubscribe={() => handleStripeSubscription(plan.plan)} />