|
@@ -30,7 +30,7 @@ import {
|
|
|
import { isRecurlyLoaded } from '../util/is-recurly-loaded'
|
|
import { isRecurlyLoaded } from '../util/is-recurly-loaded'
|
|
|
import { SubscriptionDashModalIds } from '../../../../../types/subscription/dashboard/modal-ids'
|
|
import { SubscriptionDashModalIds } from '../../../../../types/subscription/dashboard/modal-ids'
|
|
|
import { debugConsole } from '@/utils/debugging'
|
|
import { debugConsole } from '@/utils/debugging'
|
|
|
-import { getSplitTestVariant } from '@/utils/splitTestUtils'
|
|
|
|
|
|
|
+import { useFeatureFlag } from '@/shared/context/split-test-context'
|
|
|
import { formatCurrencyLocalized } from '@/shared/utils/currency'
|
|
import { formatCurrencyLocalized } from '@/shared/utils/currency'
|
|
|
|
|
|
|
|
type SubscriptionDashboardContextValue = {
|
|
type SubscriptionDashboardContextValue = {
|
|
@@ -80,11 +80,6 @@ export const SubscriptionDashboardContext = createContext<
|
|
|
SubscriptionDashboardContextValue | undefined
|
|
SubscriptionDashboardContextValue | undefined
|
|
|
>(undefined)
|
|
>(undefined)
|
|
|
|
|
|
|
|
-const getFormatCurrencies = () =>
|
|
|
|
|
- getSplitTestVariant('local-ccy-format-v2') === 'enabled'
|
|
|
|
|
- ? formatCurrencyLocalized
|
|
|
|
|
- : formatCurrencyDefault
|
|
|
|
|
-
|
|
|
|
|
export function SubscriptionDashboardProvider({
|
|
export function SubscriptionDashboardProvider({
|
|
|
children,
|
|
children,
|
|
|
}: {
|
|
}: {
|
|
@@ -150,6 +145,10 @@ export function SubscriptionDashboardProvider({
|
|
|
memberGroupSubscriptions?.length > 0
|
|
memberGroupSubscriptions?.length > 0
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ const formatCurrency = useFeatureFlag('local-ccy-format-v2')
|
|
|
|
|
+ ? formatCurrencyLocalized
|
|
|
|
|
+ : formatCurrencyDefault
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (!isRecurlyLoaded()) {
|
|
if (!isRecurlyLoaded()) {
|
|
|
setRecurlyLoadError(true)
|
|
setRecurlyLoadError(true)
|
|
@@ -164,7 +163,6 @@ export function SubscriptionDashboardProvider({
|
|
|
plansWithoutDisplayPrice &&
|
|
plansWithoutDisplayPrice &&
|
|
|
personalSubscription?.recurly
|
|
personalSubscription?.recurly
|
|
|
) {
|
|
) {
|
|
|
- const formatCurrency = getFormatCurrencies()
|
|
|
|
|
const { currency, taxRate } = personalSubscription.recurly
|
|
const { currency, taxRate } = personalSubscription.recurly
|
|
|
const fetchPlansDisplayPrices = async () => {
|
|
const fetchPlansDisplayPrices = async () => {
|
|
|
for (const plan of plansWithoutDisplayPrice) {
|
|
for (const plan of plansWithoutDisplayPrice) {
|
|
@@ -192,7 +190,12 @@ export function SubscriptionDashboardProvider({
|
|
|
}
|
|
}
|
|
|
fetchPlansDisplayPrices().catch(debugConsole.error)
|
|
fetchPlansDisplayPrices().catch(debugConsole.error)
|
|
|
}
|
|
}
|
|
|
- }, [personalSubscription, plansWithoutDisplayPrice, i18n.language])
|
|
|
|
|
|
|
+ }, [
|
|
|
|
|
+ personalSubscription,
|
|
|
|
|
+ plansWithoutDisplayPrice,
|
|
|
|
|
+ i18n.language,
|
|
|
|
|
+ formatCurrency,
|
|
|
|
|
+ ])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (
|
|
if (
|
|
@@ -209,7 +212,6 @@ export function SubscriptionDashboardProvider({
|
|
|
setGroupPlanToChangeToPriceError(false)
|
|
setGroupPlanToChangeToPriceError(false)
|
|
|
let priceData
|
|
let priceData
|
|
|
try {
|
|
try {
|
|
|
- const formatCurrency = getFormatCurrencies()
|
|
|
|
|
priceData = await loadGroupDisplayPriceWithTaxPromise(
|
|
priceData = await loadGroupDisplayPriceWithTaxPromise(
|
|
|
groupPlanToChangeToCode,
|
|
groupPlanToChangeToCode,
|
|
|
currency,
|
|
currency,
|
|
@@ -233,6 +235,7 @@ export function SubscriptionDashboardProvider({
|
|
|
groupPlanToChangeToSize,
|
|
groupPlanToChangeToSize,
|
|
|
personalSubscription,
|
|
personalSubscription,
|
|
|
groupPlanToChangeToCode,
|
|
groupPlanToChangeToCode,
|
|
|
|
|
+ formatCurrency,
|
|
|
i18n.language,
|
|
i18n.language,
|
|
|
])
|
|
])
|
|
|
|
|
|