2023-01-18 09:38:35 -05:00
|
|
|
import { Trans } from 'react-i18next'
|
|
|
|
import { Institution } from '../../../../../../types/institution'
|
2023-02-07 10:38:04 -05:00
|
|
|
import { useSubscriptionDashboardContext } from '../../context/subscription-dashboard-context'
|
2024-09-30 05:49:18 -04:00
|
|
|
import OLNotification from '@/features/ui/components/ol/ol-notification'
|
2023-01-18 09:38:35 -05:00
|
|
|
|
2023-02-07 10:38:04 -05:00
|
|
|
function InstitutionMemberships() {
|
|
|
|
const { institutionMemberships } = useSubscriptionDashboardContext()
|
2023-01-18 09:38:35 -05:00
|
|
|
|
|
|
|
// memberships is undefined when data failed to load. If user has no memberships, then an empty array is returned
|
|
|
|
|
2023-02-07 10:38:04 -05:00
|
|
|
if (!institutionMemberships) {
|
2023-01-18 09:38:35 -05:00
|
|
|
return (
|
2024-09-30 05:49:18 -04:00
|
|
|
<OLNotification
|
|
|
|
type="warning"
|
|
|
|
content={
|
|
|
|
<p>
|
|
|
|
Sorry, something went wrong. Subscription information related to
|
|
|
|
institutional affiliations may not be displayed. Please try again
|
|
|
|
later.
|
|
|
|
</p>
|
|
|
|
}
|
|
|
|
/>
|
2023-01-18 09:38:35 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-02-28 04:15:33 -05:00
|
|
|
if (!institutionMemberships.length) return null
|
|
|
|
|
2023-01-18 09:38:35 -05:00
|
|
|
return (
|
2023-02-28 04:15:33 -05:00
|
|
|
<div>
|
|
|
|
{institutionMemberships.map((institution: Institution) => (
|
|
|
|
<div key={`${institution.id}`}>
|
|
|
|
<Trans
|
|
|
|
i18nKey="you_are_on_x_plan_as_a_confirmed_member_of_institution_y"
|
|
|
|
values={{
|
|
|
|
planName: 'Professional',
|
|
|
|
institutionName: institution.name || '',
|
|
|
|
}}
|
2023-10-19 04:27:45 -04:00
|
|
|
shouldUnescape
|
|
|
|
tOptions={{ interpolation: { escapeValue: true } }}
|
2023-02-28 04:15:33 -05:00
|
|
|
components={[
|
|
|
|
// eslint-disable-next-line react/jsx-key, jsx-a11y/anchor-has-content
|
|
|
|
<a href="/user/subscription/plans" rel="noopener" />,
|
|
|
|
// eslint-disable-next-line react/jsx-key
|
|
|
|
<strong />,
|
|
|
|
// eslint-disable-next-line react/jsx-key
|
|
|
|
<strong />,
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
<hr />
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
2023-01-18 09:38:35 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default InstitutionMemberships
|