2023-02-07 10:38:12 -05:00
|
|
|
import {
|
|
|
|
createContext,
|
|
|
|
ReactNode,
|
2023-02-14 05:21:25 -05:00
|
|
|
useCallback,
|
2023-02-07 10:38:12 -05:00
|
|
|
useContext,
|
|
|
|
useEffect,
|
|
|
|
useMemo,
|
|
|
|
useState,
|
|
|
|
} from 'react'
|
2024-04-18 04:13:51 -04:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2023-02-07 10:38:04 -05:00
|
|
|
import {
|
2023-02-22 07:33:17 -05:00
|
|
|
CustomSubscription,
|
2023-02-07 10:38:04 -05:00
|
|
|
ManagedGroupSubscription,
|
2023-02-22 07:10:02 -05:00
|
|
|
MemberGroupSubscription,
|
2023-02-22 07:33:17 -05:00
|
|
|
RecurlySubscription,
|
2023-02-07 10:38:04 -05:00
|
|
|
} from '../../../../../types/subscription/dashboard/subscription'
|
2023-02-21 10:24:49 -05:00
|
|
|
import {
|
|
|
|
Plan,
|
|
|
|
PriceForDisplayData,
|
|
|
|
} from '../../../../../types/subscription/plan'
|
2023-02-07 10:38:04 -05:00
|
|
|
import { Institution } from '../../../../../types/institution'
|
|
|
|
import getMeta from '../../../utils/meta'
|
2023-02-21 10:24:49 -05:00
|
|
|
import {
|
2024-04-18 04:13:51 -04:00
|
|
|
formatCurrencyDefault,
|
2023-02-21 10:24:49 -05:00
|
|
|
loadDisplayPriceWithTaxPromise,
|
|
|
|
loadGroupDisplayPriceWithTaxPromise,
|
|
|
|
} from '../util/recurly-pricing'
|
2023-02-07 10:38:30 -05:00
|
|
|
import { isRecurlyLoaded } from '../util/is-recurly-loaded'
|
2023-02-21 10:24:28 -05:00
|
|
|
import { SubscriptionDashModalIds } from '../../../../../types/subscription/dashboard/modal-ids'
|
2023-09-27 05:45:49 -04:00
|
|
|
import { debugConsole } from '@/utils/debugging'
|
2024-04-30 10:58:34 -04:00
|
|
|
import { useFeatureFlag } from '@/shared/context/split-test-context'
|
2024-04-18 04:13:51 -04:00
|
|
|
import { formatCurrencyLocalized } from '@/shared/utils/currency'
|
2024-06-18 06:01:37 -04:00
|
|
|
import { ManagedInstitution } from '../../../../../types/subscription/dashboard/managed-institution'
|
|
|
|
import { Publisher } from '../../../../../types/subscription/dashboard/publisher'
|
2023-01-26 11:48:30 -05:00
|
|
|
|
|
|
|
type SubscriptionDashboardContextValue = {
|
2023-02-21 10:24:57 -05:00
|
|
|
groupPlanToChangeToCode: string
|
2023-02-21 10:24:28 -05:00
|
|
|
groupPlanToChangeToSize: string
|
2023-02-21 10:24:57 -05:00
|
|
|
groupPlanToChangeToUsage: string
|
2023-02-21 10:24:49 -05:00
|
|
|
groupPlanToChangeToPrice?: PriceForDisplayData
|
|
|
|
groupPlanToChangeToPriceError?: boolean
|
2023-02-16 11:29:49 -05:00
|
|
|
handleCloseModal: () => void
|
2023-02-21 10:24:28 -05:00
|
|
|
handleOpenModal: (
|
|
|
|
modalIdToOpen: SubscriptionDashModalIds,
|
|
|
|
planCode?: string
|
|
|
|
) => void
|
2023-02-07 10:38:04 -05:00
|
|
|
hasDisplayedSubscription: boolean
|
2023-08-10 05:44:01 -04:00
|
|
|
hasValidActiveSubscription: boolean
|
2023-02-14 05:21:25 -05:00
|
|
|
institutionMemberships?: Institution[]
|
|
|
|
managedGroupSubscriptions: ManagedGroupSubscription[]
|
2023-02-22 07:10:02 -05:00
|
|
|
memberGroupSubscriptions: MemberGroupSubscription[]
|
2023-02-14 05:21:25 -05:00
|
|
|
managedInstitutions: ManagedInstitution[]
|
2024-06-18 06:01:37 -04:00
|
|
|
managedPublishers: Publisher[]
|
2023-02-14 05:21:25 -05:00
|
|
|
updateManagedInstitution: (institution: ManagedInstitution) => void
|
2023-02-21 10:24:28 -05:00
|
|
|
modalIdShown?: SubscriptionDashModalIds
|
2023-02-22 07:33:17 -05:00
|
|
|
personalSubscription?: RecurlySubscription | CustomSubscription
|
2023-02-22 07:18:01 -05:00
|
|
|
hasSubscription: boolean
|
2023-02-14 05:21:25 -05:00
|
|
|
plans: Plan[]
|
2023-02-16 11:29:49 -05:00
|
|
|
planCodeToChangeTo?: string
|
2023-02-21 10:24:49 -05:00
|
|
|
queryingGroupPlanToChangeToPrice: boolean
|
2023-02-07 10:38:30 -05:00
|
|
|
queryingIndividualPlansData: boolean
|
2023-01-26 12:01:54 -05:00
|
|
|
recurlyLoadError: boolean
|
2023-02-21 10:24:57 -05:00
|
|
|
setGroupPlanToChangeToCode: React.Dispatch<React.SetStateAction<string>>
|
2023-02-21 10:24:28 -05:00
|
|
|
setGroupPlanToChangeToSize: React.Dispatch<React.SetStateAction<string>>
|
|
|
|
setGroupPlanToChangeToUsage: React.Dispatch<React.SetStateAction<string>>
|
|
|
|
setModalIdShown: React.Dispatch<
|
|
|
|
React.SetStateAction<SubscriptionDashModalIds | undefined>
|
|
|
|
>
|
2023-02-16 11:29:49 -05:00
|
|
|
setPlanCodeToChangeTo: React.Dispatch<
|
|
|
|
React.SetStateAction<string | undefined>
|
|
|
|
>
|
2023-01-26 12:01:54 -05:00
|
|
|
setRecurlyLoadError: React.Dispatch<React.SetStateAction<boolean>>
|
|
|
|
showCancellation: boolean
|
|
|
|
setShowCancellation: React.Dispatch<React.SetStateAction<boolean>>
|
2023-02-22 07:10:02 -05:00
|
|
|
leavingGroupId?: string
|
|
|
|
setLeavingGroupId: React.Dispatch<React.SetStateAction<string | undefined>>
|
2024-08-07 11:30:55 -04:00
|
|
|
userCanExtendTrial: boolean
|
2023-01-26 11:48:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export const SubscriptionDashboardContext = createContext<
|
|
|
|
SubscriptionDashboardContextValue | undefined
|
|
|
|
>(undefined)
|
|
|
|
|
|
|
|
export function SubscriptionDashboardProvider({
|
|
|
|
children,
|
|
|
|
}: {
|
|
|
|
children: ReactNode
|
|
|
|
}) {
|
2024-04-18 04:13:51 -04:00
|
|
|
const { i18n } = useTranslation()
|
2023-02-21 10:24:28 -05:00
|
|
|
const [modalIdShown, setModalIdShown] = useState<
|
|
|
|
SubscriptionDashModalIds | undefined
|
|
|
|
>()
|
2023-01-26 12:01:54 -05:00
|
|
|
const [recurlyLoadError, setRecurlyLoadError] = useState(false)
|
|
|
|
const [showCancellation, setShowCancellation] = useState(false)
|
2024-06-18 06:01:37 -04:00
|
|
|
const [plans, setPlans] = useState<Plan[]>([])
|
2023-02-07 10:38:30 -05:00
|
|
|
const [queryingIndividualPlansData, setQueryingIndividualPlansData] =
|
|
|
|
useState(true)
|
2023-02-16 11:29:49 -05:00
|
|
|
const [planCodeToChangeTo, setPlanCodeToChangeTo] = useState<
|
|
|
|
string | undefined
|
|
|
|
>()
|
2023-02-21 10:24:28 -05:00
|
|
|
const [groupPlanToChangeToSize, setGroupPlanToChangeToSize] = useState('10')
|
2023-02-21 10:24:57 -05:00
|
|
|
const [groupPlanToChangeToCode, setGroupPlanToChangeToCode] =
|
|
|
|
useState('collaborator')
|
2023-02-21 10:24:28 -05:00
|
|
|
const [groupPlanToChangeToUsage, setGroupPlanToChangeToUsage] =
|
|
|
|
useState('enterprise')
|
2023-02-21 10:24:49 -05:00
|
|
|
const [
|
|
|
|
queryingGroupPlanToChangeToPrice,
|
|
|
|
setQueryingGroupPlanToChangeToPrice,
|
|
|
|
] = useState(false)
|
|
|
|
const [groupPlanToChangeToPrice, setGroupPlanToChangeToPrice] =
|
|
|
|
useState<PriceForDisplayData>()
|
|
|
|
const [groupPlanToChangeToPriceError, setGroupPlanToChangeToPriceError] =
|
|
|
|
useState(false)
|
2023-02-22 07:10:02 -05:00
|
|
|
const [leavingGroupId, setLeavingGroupId] = useState<string | undefined>()
|
2023-01-26 11:48:30 -05:00
|
|
|
|
2023-02-07 10:38:30 -05:00
|
|
|
const plansWithoutDisplayPrice = getMeta('ol-plans')
|
2024-06-18 06:01:37 -04:00
|
|
|
const institutionMemberships = getMeta('ol-currentInstitutionsWithLicence')
|
2023-02-22 07:33:17 -05:00
|
|
|
const personalSubscription = getMeta('ol-subscription')
|
2024-08-07 11:30:55 -04:00
|
|
|
const userCanExtendTrial = getMeta('ol-userCanExtendTrial')
|
2024-06-18 06:01:37 -04:00
|
|
|
const managedGroupSubscriptions = getMeta('ol-managedGroupSubscriptions')
|
|
|
|
const memberGroupSubscriptions = getMeta('ol-memberGroupSubscriptions')
|
|
|
|
const [managedInstitutions, setManagedInstitutions] = useState(
|
|
|
|
getMeta('ol-managedInstitutions')
|
2023-02-22 07:10:02 -05:00
|
|
|
)
|
2023-02-22 06:50:24 -05:00
|
|
|
const managedPublishers = getMeta('ol-managedPublishers')
|
2023-02-22 07:18:01 -05:00
|
|
|
const hasSubscription = getMeta('ol-hasSubscription')
|
2023-02-07 10:38:30 -05:00
|
|
|
const recurlyApiKey = getMeta('ol-recurlyApiKey')
|
2023-02-07 10:38:04 -05:00
|
|
|
|
2023-02-22 07:10:02 -05:00
|
|
|
const hasDisplayedSubscription = Boolean(
|
2023-02-07 10:38:04 -05:00
|
|
|
institutionMemberships?.length > 0 ||
|
2023-02-22 07:10:02 -05:00
|
|
|
personalSubscription ||
|
|
|
|
memberGroupSubscriptions?.length > 0 ||
|
|
|
|
managedGroupSubscriptions?.length > 0 ||
|
|
|
|
managedInstitutions?.length > 0 ||
|
|
|
|
managedPublishers?.length > 0
|
|
|
|
)
|
2023-02-07 10:38:04 -05:00
|
|
|
|
2023-08-10 05:44:01 -04:00
|
|
|
const hasValidActiveSubscription = Boolean(
|
|
|
|
['active', 'canceled'].includes(personalSubscription?.recurly?.state) ||
|
|
|
|
institutionMemberships?.length > 0 ||
|
|
|
|
memberGroupSubscriptions?.length > 0
|
|
|
|
)
|
|
|
|
|
2024-04-30 10:58:34 -04:00
|
|
|
const formatCurrency = useFeatureFlag('local-ccy-format-v2')
|
|
|
|
? formatCurrencyLocalized
|
|
|
|
: formatCurrencyDefault
|
|
|
|
|
2023-02-07 10:38:12 -05:00
|
|
|
useEffect(() => {
|
2023-02-07 10:38:30 -05:00
|
|
|
if (!isRecurlyLoaded()) {
|
2023-02-07 10:38:12 -05:00
|
|
|
setRecurlyLoadError(true)
|
2023-02-07 11:14:23 -05:00
|
|
|
} else if (recurlyApiKey) {
|
2023-02-07 10:38:30 -05:00
|
|
|
recurly.configure(recurlyApiKey)
|
2023-02-07 10:38:12 -05:00
|
|
|
}
|
2023-02-07 10:38:30 -05:00
|
|
|
}, [recurlyApiKey, setRecurlyLoadError])
|
|
|
|
|
|
|
|
useEffect(() => {
|
2023-02-22 07:33:17 -05:00
|
|
|
if (
|
|
|
|
isRecurlyLoaded() &&
|
|
|
|
plansWithoutDisplayPrice &&
|
|
|
|
personalSubscription?.recurly
|
|
|
|
) {
|
2023-02-07 10:38:30 -05:00
|
|
|
const { currency, taxRate } = personalSubscription.recurly
|
|
|
|
const fetchPlansDisplayPrices = async () => {
|
|
|
|
for (const plan of plansWithoutDisplayPrice) {
|
|
|
|
try {
|
|
|
|
const priceData = await loadDisplayPriceWithTaxPromise(
|
|
|
|
plan.planCode,
|
|
|
|
currency,
|
2024-04-18 04:13:51 -04:00
|
|
|
taxRate,
|
|
|
|
i18n.language,
|
|
|
|
formatCurrency
|
2023-02-07 10:38:30 -05:00
|
|
|
)
|
2024-04-18 04:13:51 -04:00
|
|
|
if (priceData?.totalAsNumber !== undefined) {
|
|
|
|
plan.displayPrice = formatCurrency(
|
|
|
|
priceData.totalAsNumber,
|
|
|
|
currency,
|
|
|
|
i18n.language
|
|
|
|
)
|
2023-02-07 10:38:30 -05:00
|
|
|
}
|
|
|
|
} catch (error) {
|
2023-09-27 05:45:49 -04:00
|
|
|
debugConsole.error(error)
|
2023-02-07 10:38:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
setPlans(plansWithoutDisplayPrice)
|
|
|
|
setQueryingIndividualPlansData(false)
|
|
|
|
}
|
2023-09-27 05:45:49 -04:00
|
|
|
fetchPlansDisplayPrices().catch(debugConsole.error)
|
2023-02-07 10:38:30 -05:00
|
|
|
}
|
2024-04-30 10:58:34 -04:00
|
|
|
}, [
|
|
|
|
personalSubscription,
|
|
|
|
plansWithoutDisplayPrice,
|
|
|
|
i18n.language,
|
|
|
|
formatCurrency,
|
|
|
|
])
|
2023-02-07 10:38:12 -05:00
|
|
|
|
2023-02-21 10:24:49 -05:00
|
|
|
useEffect(() => {
|
|
|
|
if (
|
|
|
|
isRecurlyLoaded() &&
|
|
|
|
groupPlanToChangeToCode &&
|
|
|
|
groupPlanToChangeToSize &&
|
|
|
|
groupPlanToChangeToUsage &&
|
2023-02-22 07:33:17 -05:00
|
|
|
personalSubscription?.recurly
|
2023-02-21 10:24:49 -05:00
|
|
|
) {
|
|
|
|
setQueryingGroupPlanToChangeToPrice(true)
|
|
|
|
|
|
|
|
const { currency, taxRate } = personalSubscription.recurly
|
|
|
|
const fetchGroupDisplayPrice = async () => {
|
|
|
|
setGroupPlanToChangeToPriceError(false)
|
|
|
|
let priceData
|
|
|
|
try {
|
|
|
|
priceData = await loadGroupDisplayPriceWithTaxPromise(
|
|
|
|
groupPlanToChangeToCode,
|
|
|
|
currency,
|
|
|
|
taxRate,
|
|
|
|
groupPlanToChangeToSize,
|
2024-04-18 04:13:51 -04:00
|
|
|
groupPlanToChangeToUsage,
|
|
|
|
i18n.language,
|
|
|
|
formatCurrency
|
2023-02-21 10:24:49 -05:00
|
|
|
)
|
|
|
|
} catch (e) {
|
2023-09-27 05:45:49 -04:00
|
|
|
debugConsole.error(e)
|
2023-02-21 10:24:49 -05:00
|
|
|
setGroupPlanToChangeToPriceError(true)
|
|
|
|
}
|
|
|
|
setQueryingGroupPlanToChangeToPrice(false)
|
|
|
|
setGroupPlanToChangeToPrice(priceData)
|
|
|
|
}
|
|
|
|
fetchGroupDisplayPrice()
|
|
|
|
}
|
|
|
|
}, [
|
|
|
|
groupPlanToChangeToUsage,
|
|
|
|
groupPlanToChangeToSize,
|
|
|
|
personalSubscription,
|
|
|
|
groupPlanToChangeToCode,
|
2024-04-30 10:58:34 -04:00
|
|
|
formatCurrency,
|
2024-04-18 04:13:51 -04:00
|
|
|
i18n.language,
|
2023-02-21 10:24:49 -05:00
|
|
|
])
|
|
|
|
|
2023-02-14 05:21:25 -05:00
|
|
|
const updateManagedInstitution = useCallback(
|
|
|
|
(institution: ManagedInstitution) => {
|
|
|
|
setManagedInstitutions(institutions => {
|
|
|
|
return [
|
|
|
|
...(institutions || []).map(i =>
|
|
|
|
i.v1Id === institution.v1Id ? institution : i
|
|
|
|
),
|
|
|
|
]
|
|
|
|
})
|
|
|
|
},
|
|
|
|
[]
|
|
|
|
)
|
2023-02-21 10:24:49 -05:00
|
|
|
|
2023-02-16 11:29:49 -05:00
|
|
|
const handleCloseModal = useCallback(() => {
|
2023-02-21 10:24:28 -05:00
|
|
|
setModalIdShown(undefined)
|
2023-02-16 11:29:49 -05:00
|
|
|
setPlanCodeToChangeTo(undefined)
|
|
|
|
}, [setModalIdShown, setPlanCodeToChangeTo])
|
|
|
|
|
|
|
|
const handleOpenModal = useCallback(
|
|
|
|
(id, planCode) => {
|
|
|
|
setModalIdShown(id)
|
|
|
|
setPlanCodeToChangeTo(planCode)
|
|
|
|
},
|
|
|
|
[setModalIdShown, setPlanCodeToChangeTo]
|
|
|
|
)
|
2023-02-14 05:21:25 -05:00
|
|
|
|
2023-01-26 11:48:30 -05:00
|
|
|
const value = useMemo<SubscriptionDashboardContextValue>(
|
|
|
|
() => ({
|
2023-02-21 10:24:28 -05:00
|
|
|
groupPlanToChangeToCode,
|
2023-02-21 10:24:49 -05:00
|
|
|
groupPlanToChangeToPrice,
|
|
|
|
groupPlanToChangeToPriceError,
|
2023-02-21 10:24:28 -05:00
|
|
|
groupPlanToChangeToSize,
|
|
|
|
groupPlanToChangeToUsage,
|
2023-02-16 11:29:49 -05:00
|
|
|
handleCloseModal,
|
|
|
|
handleOpenModal,
|
2023-02-07 10:38:04 -05:00
|
|
|
hasDisplayedSubscription,
|
2023-08-10 05:44:01 -04:00
|
|
|
hasValidActiveSubscription,
|
2023-02-07 10:38:04 -05:00
|
|
|
institutionMemberships,
|
|
|
|
managedGroupSubscriptions,
|
2023-02-22 07:10:02 -05:00
|
|
|
memberGroupSubscriptions,
|
2023-02-14 05:21:25 -05:00
|
|
|
managedInstitutions,
|
2023-02-22 06:50:24 -05:00
|
|
|
managedPublishers,
|
2023-02-14 05:21:25 -05:00
|
|
|
updateManagedInstitution,
|
2023-02-16 11:29:49 -05:00
|
|
|
modalIdShown,
|
2023-02-07 10:38:04 -05:00
|
|
|
personalSubscription,
|
2023-02-22 07:18:01 -05:00
|
|
|
hasSubscription,
|
2023-02-07 10:38:04 -05:00
|
|
|
plans,
|
2023-02-16 11:29:49 -05:00
|
|
|
planCodeToChangeTo,
|
2023-02-21 10:24:49 -05:00
|
|
|
queryingGroupPlanToChangeToPrice,
|
2023-02-07 10:38:30 -05:00
|
|
|
queryingIndividualPlansData,
|
2023-01-26 12:01:54 -05:00
|
|
|
recurlyLoadError,
|
2023-02-21 10:24:28 -05:00
|
|
|
setGroupPlanToChangeToCode,
|
|
|
|
setGroupPlanToChangeToSize,
|
|
|
|
setGroupPlanToChangeToUsage,
|
2023-02-16 11:29:49 -05:00
|
|
|
setModalIdShown,
|
|
|
|
setPlanCodeToChangeTo,
|
2023-01-26 12:01:54 -05:00
|
|
|
setRecurlyLoadError,
|
|
|
|
showCancellation,
|
|
|
|
setShowCancellation,
|
2023-02-22 07:10:02 -05:00
|
|
|
leavingGroupId,
|
|
|
|
setLeavingGroupId,
|
2024-08-07 11:30:55 -04:00
|
|
|
userCanExtendTrial,
|
2023-01-26 11:48:30 -05:00
|
|
|
}),
|
2023-01-26 12:01:54 -05:00
|
|
|
[
|
2023-02-21 10:24:28 -05:00
|
|
|
groupPlanToChangeToCode,
|
2023-02-21 10:24:49 -05:00
|
|
|
groupPlanToChangeToPrice,
|
|
|
|
groupPlanToChangeToPriceError,
|
2023-02-21 10:24:28 -05:00
|
|
|
groupPlanToChangeToSize,
|
|
|
|
groupPlanToChangeToUsage,
|
2023-02-16 11:29:49 -05:00
|
|
|
handleCloseModal,
|
|
|
|
handleOpenModal,
|
2023-02-07 10:38:04 -05:00
|
|
|
hasDisplayedSubscription,
|
2023-08-10 05:44:01 -04:00
|
|
|
hasValidActiveSubscription,
|
2023-02-07 10:38:04 -05:00
|
|
|
institutionMemberships,
|
|
|
|
managedGroupSubscriptions,
|
2023-02-22 07:10:02 -05:00
|
|
|
memberGroupSubscriptions,
|
2023-02-14 05:21:25 -05:00
|
|
|
managedInstitutions,
|
2023-02-22 06:50:24 -05:00
|
|
|
managedPublishers,
|
2023-02-14 05:21:25 -05:00
|
|
|
updateManagedInstitution,
|
2023-02-16 11:29:49 -05:00
|
|
|
modalIdShown,
|
2023-02-07 10:38:04 -05:00
|
|
|
personalSubscription,
|
2023-02-22 07:18:01 -05:00
|
|
|
hasSubscription,
|
2023-02-07 10:38:04 -05:00
|
|
|
plans,
|
2023-02-16 11:29:49 -05:00
|
|
|
planCodeToChangeTo,
|
2023-02-21 10:24:49 -05:00
|
|
|
queryingGroupPlanToChangeToPrice,
|
2023-02-07 10:38:30 -05:00
|
|
|
queryingIndividualPlansData,
|
2023-01-26 12:01:54 -05:00
|
|
|
recurlyLoadError,
|
2023-02-21 10:24:28 -05:00
|
|
|
setGroupPlanToChangeToCode,
|
|
|
|
setGroupPlanToChangeToSize,
|
|
|
|
setGroupPlanToChangeToUsage,
|
2023-02-16 11:29:49 -05:00
|
|
|
setModalIdShown,
|
|
|
|
setPlanCodeToChangeTo,
|
2023-01-26 12:01:54 -05:00
|
|
|
setRecurlyLoadError,
|
|
|
|
showCancellation,
|
|
|
|
setShowCancellation,
|
2023-02-22 07:10:02 -05:00
|
|
|
leavingGroupId,
|
|
|
|
setLeavingGroupId,
|
2024-08-07 11:30:55 -04:00
|
|
|
userCanExtendTrial,
|
2023-01-26 12:01:54 -05:00
|
|
|
]
|
2023-01-26 11:48:30 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SubscriptionDashboardContext.Provider value={value}>
|
|
|
|
{children}
|
|
|
|
</SubscriptionDashboardContext.Provider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useSubscriptionDashboardContext() {
|
|
|
|
const context = useContext(SubscriptionDashboardContext)
|
|
|
|
if (!context) {
|
|
|
|
throw new Error(
|
|
|
|
'SubscriptionDashboardContext is only available inside SubscriptionDashboardProvider'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return context
|
|
|
|
}
|