Ver código fonte

[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
M Fahru 1 ano atrás
pai
commit
e042233dd9

+ 1 - 3
services/web/types/subscription/payment-context-value.tsx

@@ -30,9 +30,6 @@ export type PaymentContextValue = {
   >
   >
   plan: Plan
   plan: Plan
   planCode: string
   planCode: string
-  setPlanCode: React.Dispatch<
-    React.SetStateAction<PaymentContextValue['planCode']>
-  >
   planName: string
   planName: string
   planOffersFreeTrial: boolean
   planOffersFreeTrial: boolean
   pricing: React.MutableRefObject<SubscriptionPricingInstanceCustom | undefined>
   pricing: React.MutableRefObject<SubscriptionPricingInstanceCustom | undefined>
@@ -73,4 +70,5 @@ export type PaymentContextValue = {
   setStudentConfirmationChecked: React.Dispatch<
   setStudentConfirmationChecked: React.Dispatch<
     React.SetStateAction<PaymentContextValue['studentConfirmationChecked']>
     React.SetStateAction<PaymentContextValue['studentConfirmationChecked']>
   >
   >
+  updatePlan: (newPlanCode: string) => void
 }
 }