|
@@ -8,9 +8,10 @@ import {
|
|
|
useState,
|
|
useState,
|
|
|
} from 'react'
|
|
} from 'react'
|
|
|
import {
|
|
import {
|
|
|
|
|
+ CustomSubscription,
|
|
|
ManagedGroupSubscription,
|
|
ManagedGroupSubscription,
|
|
|
MemberGroupSubscription,
|
|
MemberGroupSubscription,
|
|
|
- Subscription,
|
|
|
|
|
|
|
+ RecurlySubscription,
|
|
|
} from '../../../../../types/subscription/dashboard/subscription'
|
|
} from '../../../../../types/subscription/dashboard/subscription'
|
|
|
import {
|
|
import {
|
|
|
Plan,
|
|
Plan,
|
|
@@ -46,7 +47,7 @@ type SubscriptionDashboardContextValue = {
|
|
|
managedPublishers: ManagedPublisher[]
|
|
managedPublishers: ManagedPublisher[]
|
|
|
updateManagedInstitution: (institution: ManagedInstitution) => void
|
|
updateManagedInstitution: (institution: ManagedInstitution) => void
|
|
|
modalIdShown?: SubscriptionDashModalIds
|
|
modalIdShown?: SubscriptionDashModalIds
|
|
|
- personalSubscription?: Subscription
|
|
|
|
|
|
|
+ personalSubscription?: RecurlySubscription | CustomSubscription
|
|
|
hasSubscription: boolean
|
|
hasSubscription: boolean
|
|
|
plans: Plan[]
|
|
plans: Plan[]
|
|
|
planCodeToChangeTo?: string
|
|
planCodeToChangeTo?: string
|
|
@@ -111,7 +112,7 @@ export function SubscriptionDashboardProvider({
|
|
|
const institutionMemberships: Institution[] = getMeta(
|
|
const institutionMemberships: Institution[] = getMeta(
|
|
|
'ol-currentInstitutionsWithLicence'
|
|
'ol-currentInstitutionsWithLicence'
|
|
|
)
|
|
)
|
|
|
- const personalSubscription: Subscription = getMeta('ol-subscription')
|
|
|
|
|
|
|
+ const personalSubscription = getMeta('ol-subscription')
|
|
|
const managedGroupSubscriptions: ManagedGroupSubscription[] = getMeta(
|
|
const managedGroupSubscriptions: ManagedGroupSubscription[] = getMeta(
|
|
|
'ol-managedGroupSubscriptions'
|
|
'ol-managedGroupSubscriptions'
|
|
|
)
|
|
)
|
|
@@ -143,7 +144,11 @@ export function SubscriptionDashboardProvider({
|
|
|
}, [recurlyApiKey, setRecurlyLoadError])
|
|
}, [recurlyApiKey, setRecurlyLoadError])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- if (isRecurlyLoaded() && plansWithoutDisplayPrice && personalSubscription) {
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ isRecurlyLoaded() &&
|
|
|
|
|
+ plansWithoutDisplayPrice &&
|
|
|
|
|
+ personalSubscription?.recurly
|
|
|
|
|
+ ) {
|
|
|
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) {
|
|
@@ -173,7 +178,7 @@ export function SubscriptionDashboardProvider({
|
|
|
groupPlanToChangeToCode &&
|
|
groupPlanToChangeToCode &&
|
|
|
groupPlanToChangeToSize &&
|
|
groupPlanToChangeToSize &&
|
|
|
groupPlanToChangeToUsage &&
|
|
groupPlanToChangeToUsage &&
|
|
|
- personalSubscription
|
|
|
|
|
|
|
+ personalSubscription?.recurly
|
|
|
) {
|
|
) {
|
|
|
setQueryingGroupPlanToChangeToPrice(true)
|
|
setQueryingGroupPlanToChangeToPrice(true)
|
|
|
|
|
|