2024-05-08 09:43:25 -04:00
|
|
|
import useWaitForI18n from '@/shared/hooks/use-wait-for-i18n'
|
|
|
|
import getMeta from '@/utils/meta'
|
|
|
|
import HasIndividualRecurlySubscription from './has-individual-recurly-subscription'
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
import { useTranslation, Trans } from 'react-i18next'
|
|
|
|
import ManagedUserCannotJoin from './managed-user-cannot-join'
|
|
|
|
import Notification from '@/shared/components/notification'
|
|
|
|
import JoinGroup from './join-group'
|
|
|
|
import AcceptedInvite from './accepted-invite'
|
2024-09-30 05:48:56 -04:00
|
|
|
import OLRow from '@/features/ui/components/ol/ol-row'
|
|
|
|
import OLCol from '@/features/ui/components/ol/ol-col'
|
|
|
|
import OLCard from '@/features/ui/components/ol/ol-card'
|
2024-05-08 09:43:25 -04:00
|
|
|
|
|
|
|
export type InviteViewTypes =
|
|
|
|
| 'invite'
|
|
|
|
| 'invite-accepted'
|
|
|
|
| 'cancel-personal-subscription'
|
|
|
|
| 'managed-user-cannot-join'
|
|
|
|
| undefined
|
|
|
|
|
|
|
|
function GroupInviteViews() {
|
|
|
|
const hasIndividualRecurlySubscription = getMeta(
|
|
|
|
'ol-hasIndividualRecurlySubscription'
|
2024-06-18 06:01:37 -04:00
|
|
|
)
|
|
|
|
const cannotJoinSubscription = getMeta('ol-cannot-join-subscription')
|
2024-05-08 09:43:25 -04:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (cannotJoinSubscription) {
|
|
|
|
setView('managed-user-cannot-join')
|
|
|
|
} else if (hasIndividualRecurlySubscription) {
|
|
|
|
setView('cancel-personal-subscription')
|
|
|
|
} else {
|
|
|
|
setView('invite')
|
|
|
|
}
|
|
|
|
}, [cannotJoinSubscription, hasIndividualRecurlySubscription])
|
|
|
|
const [view, setView] = useState<InviteViewTypes>(undefined)
|
|
|
|
|
|
|
|
if (!view) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
if (view === 'managed-user-cannot-join') {
|
|
|
|
return <ManagedUserCannotJoin />
|
|
|
|
} else if (view === 'cancel-personal-subscription') {
|
|
|
|
return <HasIndividualRecurlySubscription setView={setView} />
|
|
|
|
} else if (view === 'invite') {
|
|
|
|
return <JoinGroup setView={setView} />
|
|
|
|
} else if (view === 'invite-accepted') {
|
|
|
|
return <AcceptedInvite />
|
|
|
|
}
|
|
|
|
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function GroupInvite() {
|
2024-06-18 06:01:37 -04:00
|
|
|
const inviterName = getMeta('ol-inviterName')
|
|
|
|
const expired = getMeta('ol-expired')
|
2024-05-08 09:43:25 -04:00
|
|
|
const { isReady } = useWaitForI18n()
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
if (!isReady) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="container" id="main-content">
|
|
|
|
{expired && (
|
2024-09-30 05:48:56 -04:00
|
|
|
<OLRow>
|
|
|
|
<OLCol lg={{ span: 8, offset: 2 }}>
|
2024-05-08 09:43:25 -04:00
|
|
|
<Notification type="error" content={t('email_link_expired')} />
|
2024-09-30 05:48:56 -04:00
|
|
|
</OLCol>
|
|
|
|
</OLRow>
|
2024-05-08 09:43:25 -04:00
|
|
|
)}
|
|
|
|
|
2024-09-30 05:48:56 -04:00
|
|
|
<OLRow className="row row-spaced">
|
|
|
|
<OLCol lg={{ span: 8, offset: 2 }}>
|
|
|
|
<OLCard>
|
2024-05-08 09:43:25 -04:00
|
|
|
<div className="page-header">
|
|
|
|
<h1 className="text-center">
|
|
|
|
<Trans
|
|
|
|
i18nKey="invited_to_group"
|
|
|
|
values={{ inviterName }}
|
|
|
|
shouldUnescape
|
|
|
|
tOptions={{ interpolation: { escapeValue: true } }}
|
|
|
|
components={
|
|
|
|
/* eslint-disable-next-line react/jsx-key */
|
|
|
|
[<span className="team-invite-name" />]
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</h1>
|
|
|
|
</div>
|
|
|
|
<GroupInviteViews />
|
2024-09-30 05:48:56 -04:00
|
|
|
</OLCard>
|
|
|
|
</OLCol>
|
|
|
|
</OLRow>
|
2024-05-08 09:43:25 -04:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|