2023-02-22 07:10:02 -05:00
|
|
|
import { Trans, useTranslation } from 'react-i18next'
|
|
|
|
import { MemberGroupSubscription } from '../../../../../../types/subscription/dashboard/subscription'
|
|
|
|
import { useSubscriptionDashboardContext } from '../../context/subscription-dashboard-context'
|
|
|
|
import { LEAVE_GROUP_MODAL_ID } from './leave-group-modal'
|
2023-09-28 11:32:24 -04:00
|
|
|
import getMeta from '../../../../utils/meta'
|
2024-09-30 05:49:18 -04:00
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
2023-02-22 07:10:02 -05:00
|
|
|
|
|
|
|
type GroupSubscriptionMembershipProps = {
|
|
|
|
subscription: MemberGroupSubscription
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function GroupSubscriptionMembership({
|
|
|
|
subscription,
|
|
|
|
}: GroupSubscriptionMembershipProps) {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const { handleOpenModal, setLeavingGroupId } =
|
|
|
|
useSubscriptionDashboardContext()
|
|
|
|
|
|
|
|
const leaveGroup = () => {
|
|
|
|
handleOpenModal(LEAVE_GROUP_MODAL_ID)
|
|
|
|
setLeavingGroupId(subscription._id)
|
|
|
|
}
|
|
|
|
|
2023-07-20 06:14:21 -04:00
|
|
|
// Hide leave group button for managed users
|
2024-06-18 06:01:37 -04:00
|
|
|
const hideLeaveButton = getMeta('ol-cannot-leave-group-subscription')
|
2023-07-20 06:14:21 -04:00
|
|
|
|
2023-02-22 07:10:02 -05:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<p>
|
|
|
|
<Trans
|
|
|
|
i18nKey="you_are_on_x_plan_as_member_of_group_subscription_y_administered_by_z"
|
|
|
|
components={[<a href="/user/subscription/plans" />, <strong />]} // eslint-disable-line react/jsx-key, jsx-a11y/anchor-has-content
|
|
|
|
values={{
|
|
|
|
planName: subscription.planLevelName,
|
|
|
|
groupName: subscription.teamName || '',
|
|
|
|
adminEmail: subscription.admin_id.email,
|
|
|
|
}}
|
2023-10-19 04:27:45 -04:00
|
|
|
shouldUnescape
|
|
|
|
tOptions={{ interpolation: { escapeValue: true } }}
|
2023-02-22 07:10:02 -05:00
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
{subscription.teamNotice && (
|
|
|
|
<p>
|
|
|
|
{/* Team notice is sanitized in SubscriptionViewModelBuilder */}
|
|
|
|
<em>{subscription.teamNotice}</em>
|
|
|
|
</p>
|
|
|
|
)}
|
2023-07-20 06:14:21 -04:00
|
|
|
{hideLeaveButton ? (
|
|
|
|
<span>
|
|
|
|
{' '}
|
|
|
|
{t('need_to_leave')} {t('contact_group_admin')}{' '}
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
<span>
|
2024-09-30 05:49:18 -04:00
|
|
|
<OLButton variant="danger" onClick={leaveGroup}>
|
2023-07-20 06:14:21 -04:00
|
|
|
{t('leave_group')}
|
2024-09-30 05:49:18 -04:00
|
|
|
</OLButton>
|
2023-07-20 06:14:21 -04:00
|
|
|
</span>
|
|
|
|
)}
|
2023-02-22 07:10:02 -05:00
|
|
|
<hr />
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|