import GroupSettingsButton from '@/features/subscription/components/dashboard/group-settings-button'
import getMeta from '@/utils/meta'
import { Trans, useTranslation } from 'react-i18next'
import { useSubscriptionDashboardContext } from '../../context/subscription-dashboard-context'
import { RowLink } from './row-link'
import { ManagedGroupSubscription } from '../../../../../../types/subscription/dashboard/subscription'
function ManagedGroupAdministrator({
subscription,
}: {
subscription: ManagedGroupSubscription
}) {
const usersEmail = getMeta('ol-usersEmail')
const values = {
planName: subscription.planLevelName,
groupName: subscription.teamName || '',
adminEmail: subscription.admin_id.email,
}
const isAdmin = usersEmail === subscription.admin_id.email
if (subscription.userIsGroupMember && !isAdmin) {
return (
,
// eslint-disable-next-line react/jsx-key
,
]}
values={values}
shouldUnescape
tOptions={{ interpolation: { escapeValue: true } }}
/>
)
} else if (subscription.userIsGroupMember && isAdmin) {
return (
,
// eslint-disable-next-line react/jsx-key
,
]}
values={values}
shouldUnescape
tOptions={{ interpolation: { escapeValue: true } }}
/>
)
} else if (isAdmin) {
return (
,
// eslint-disable-next-line react/jsx-key
,
]}
values={values}
shouldUnescape
tOptions={{ interpolation: { escapeValue: true } }}
/>
)
}
return (
,
// eslint-disable-next-line react/jsx-key
,
]}
values={values}
shouldUnescape
tOptions={{ interpolation: { escapeValue: true } }}
/>
)
}
export default function ManagedGroupSubscriptions() {
const { t } = useTranslation()
const { managedGroupSubscriptions } = useSubscriptionDashboardContext()
if (!managedGroupSubscriptions) {
return null
}
const groupSettingsEnabledFor = getMeta('ol-groupSettingsEnabledFor') || []
return (
<>
{managedGroupSubscriptions.map(subscription => {
return (
{groupSettingsEnabledFor?.includes(subscription._id) && (
)}
)
})}
>
)
}