|
@@ -9,6 +9,7 @@ import {
|
|
|
} from 'react'
|
|
} from 'react'
|
|
|
import {
|
|
import {
|
|
|
ManagedGroupSubscription,
|
|
ManagedGroupSubscription,
|
|
|
|
|
+ MemberGroupSubscription,
|
|
|
Subscription,
|
|
Subscription,
|
|
|
} from '../../../../../types/subscription/dashboard/subscription'
|
|
} from '../../../../../types/subscription/dashboard/subscription'
|
|
|
import {
|
|
import {
|
|
@@ -40,6 +41,7 @@ type SubscriptionDashboardContextValue = {
|
|
|
hasDisplayedSubscription: boolean
|
|
hasDisplayedSubscription: boolean
|
|
|
institutionMemberships?: Institution[]
|
|
institutionMemberships?: Institution[]
|
|
|
managedGroupSubscriptions: ManagedGroupSubscription[]
|
|
managedGroupSubscriptions: ManagedGroupSubscription[]
|
|
|
|
|
+ memberGroupSubscriptions: MemberGroupSubscription[]
|
|
|
managedInstitutions: ManagedInstitution[]
|
|
managedInstitutions: ManagedInstitution[]
|
|
|
managedPublishers: ManagedPublisher[]
|
|
managedPublishers: ManagedPublisher[]
|
|
|
updateManagedInstitution: (institution: ManagedInstitution) => void
|
|
updateManagedInstitution: (institution: ManagedInstitution) => void
|
|
@@ -64,6 +66,8 @@ type SubscriptionDashboardContextValue = {
|
|
|
setShowCancellation: React.Dispatch<React.SetStateAction<boolean>>
|
|
setShowCancellation: React.Dispatch<React.SetStateAction<boolean>>
|
|
|
showChangePersonalPlan: boolean
|
|
showChangePersonalPlan: boolean
|
|
|
setShowChangePersonalPlan: React.Dispatch<React.SetStateAction<boolean>>
|
|
setShowChangePersonalPlan: React.Dispatch<React.SetStateAction<boolean>>
|
|
|
|
|
+ leavingGroupId?: string
|
|
|
|
|
+ setLeavingGroupId: React.Dispatch<React.SetStateAction<string | undefined>>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export const SubscriptionDashboardContext = createContext<
|
|
export const SubscriptionDashboardContext = createContext<
|
|
@@ -100,23 +104,33 @@ export function SubscriptionDashboardProvider({
|
|
|
useState<PriceForDisplayData>()
|
|
useState<PriceForDisplayData>()
|
|
|
const [groupPlanToChangeToPriceError, setGroupPlanToChangeToPriceError] =
|
|
const [groupPlanToChangeToPriceError, setGroupPlanToChangeToPriceError] =
|
|
|
useState(false)
|
|
useState(false)
|
|
|
|
|
+ const [leavingGroupId, setLeavingGroupId] = useState<string | undefined>()
|
|
|
|
|
|
|
|
const plansWithoutDisplayPrice = getMeta('ol-plans')
|
|
const plansWithoutDisplayPrice = getMeta('ol-plans')
|
|
|
- const institutionMemberships = getMeta('ol-currentInstitutionsWithLicence')
|
|
|
|
|
- const personalSubscription = getMeta('ol-subscription')
|
|
|
|
|
- const managedGroupSubscriptions = getMeta('ol-managedGroupSubscriptions')
|
|
|
|
|
|
|
+ const institutionMemberships: Institution[] = getMeta(
|
|
|
|
|
+ 'ol-currentInstitutionsWithLicence'
|
|
|
|
|
+ )
|
|
|
|
|
+ const personalSubscription: Subscription = getMeta('ol-subscription')
|
|
|
|
|
+ const managedGroupSubscriptions: ManagedGroupSubscription[] = getMeta(
|
|
|
|
|
+ 'ol-managedGroupSubscriptions'
|
|
|
|
|
+ )
|
|
|
|
|
+ const memberGroupSubscriptions: MemberGroupSubscription[] = getMeta(
|
|
|
|
|
+ 'ol-memberGroupSubscriptions'
|
|
|
|
|
+ )
|
|
|
const [managedInstitutions, setManagedInstitutions] = useState<
|
|
const [managedInstitutions, setManagedInstitutions] = useState<
|
|
|
ManagedInstitution[]
|
|
ManagedInstitution[]
|
|
|
>(getMeta('ol-managedInstitutions'))
|
|
>(getMeta('ol-managedInstitutions'))
|
|
|
const managedPublishers = getMeta('ol-managedPublishers')
|
|
const managedPublishers = getMeta('ol-managedPublishers')
|
|
|
const recurlyApiKey = getMeta('ol-recurlyApiKey')
|
|
const recurlyApiKey = getMeta('ol-recurlyApiKey')
|
|
|
|
|
|
|
|
- const hasDisplayedSubscription =
|
|
|
|
|
|
|
+ const hasDisplayedSubscription = Boolean(
|
|
|
institutionMemberships?.length > 0 ||
|
|
institutionMemberships?.length > 0 ||
|
|
|
- personalSubscription ||
|
|
|
|
|
- managedGroupSubscriptions?.length > 0 ||
|
|
|
|
|
- managedInstitutions?.length > 0 ||
|
|
|
|
|
- managedPublishers?.length > 0
|
|
|
|
|
|
|
+ personalSubscription ||
|
|
|
|
|
+ memberGroupSubscriptions?.length > 0 ||
|
|
|
|
|
+ managedGroupSubscriptions?.length > 0 ||
|
|
|
|
|
+ managedInstitutions?.length > 0 ||
|
|
|
|
|
+ managedPublishers?.length > 0
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (!isRecurlyLoaded()) {
|
|
if (!isRecurlyLoaded()) {
|
|
@@ -227,6 +241,7 @@ export function SubscriptionDashboardProvider({
|
|
|
hasDisplayedSubscription,
|
|
hasDisplayedSubscription,
|
|
|
institutionMemberships,
|
|
institutionMemberships,
|
|
|
managedGroupSubscriptions,
|
|
managedGroupSubscriptions,
|
|
|
|
|
+ memberGroupSubscriptions,
|
|
|
managedInstitutions,
|
|
managedInstitutions,
|
|
|
managedPublishers,
|
|
managedPublishers,
|
|
|
updateManagedInstitution,
|
|
updateManagedInstitution,
|
|
@@ -247,6 +262,8 @@ export function SubscriptionDashboardProvider({
|
|
|
setShowCancellation,
|
|
setShowCancellation,
|
|
|
showChangePersonalPlan,
|
|
showChangePersonalPlan,
|
|
|
setShowChangePersonalPlan,
|
|
setShowChangePersonalPlan,
|
|
|
|
|
+ leavingGroupId,
|
|
|
|
|
+ setLeavingGroupId,
|
|
|
}),
|
|
}),
|
|
|
[
|
|
[
|
|
|
groupPlanToChangeToCode,
|
|
groupPlanToChangeToCode,
|
|
@@ -259,6 +276,7 @@ export function SubscriptionDashboardProvider({
|
|
|
hasDisplayedSubscription,
|
|
hasDisplayedSubscription,
|
|
|
institutionMemberships,
|
|
institutionMemberships,
|
|
|
managedGroupSubscriptions,
|
|
managedGroupSubscriptions,
|
|
|
|
|
+ memberGroupSubscriptions,
|
|
|
managedInstitutions,
|
|
managedInstitutions,
|
|
|
managedPublishers,
|
|
managedPublishers,
|
|
|
updateManagedInstitution,
|
|
updateManagedInstitution,
|
|
@@ -279,6 +297,8 @@ export function SubscriptionDashboardProvider({
|
|
|
setShowCancellation,
|
|
setShowCancellation,
|
|
|
showChangePersonalPlan,
|
|
showChangePersonalPlan,
|
|
|
setShowChangePersonalPlan,
|
|
setShowChangePersonalPlan,
|
|
|
|
|
+ leavingGroupId,
|
|
|
|
|
+ setLeavingGroupId,
|
|
|
]
|
|
]
|
|
|
)
|
|
)
|
|
|
|
|
|