[web] Fix bug where VAT value isn't retained properly when changing plan without reloading (#23211)

Fix VAT info is not properly updated when changing plan without reloading.

I removed `setPlan` and created a new function: `updatePlan`. In the new function, I call the recurly function directly and the tracking code. This way, we can be sure that changing plan won't call useLayoutEffect.

Also, remove unused `useState` on the `planCode`

GitOrigin-RevId: 0d6d9fac32c15dcf13e35cf9cd9161aa07581938
This commit is contained in:
M Fahru
2025-01-31 09:05:36 +00:00
committed by Copybot
parent 369aa961bb
commit 61d05467b8
@@ -30,9 +30,6 @@ export type PaymentContextValue = {
>
plan: Plan
planCode: string
setPlanCode: React.Dispatch<
React.SetStateAction<PaymentContextValue['planCode']>
>
planName: string
planOffersFreeTrial: boolean
pricing: React.MutableRefObject<SubscriptionPricingInstanceCustom | undefined>
@@ -73,4 +70,5 @@ export type PaymentContextValue = {
setStudentConfirmationChecked: React.Dispatch<
React.SetStateAction<PaymentContextValue['studentConfirmationChecked']>
>
updatePlan: (newPlanCode: string) => void
}