overleaf/services/web/frontend/js/features/group-management/components/members-table/managed-user-status.tsx
Alexandre Bourdin 665f5e37c4 Merge pull request #15348 from overleaf/ab-decoupling-refactor-members-table
[web] Modular members management table refactoring

GitOrigin-RevId: 9a3a00a32970e78e5b43b3a68621a627c490c728
2023-10-30 09:04:43 +00:00

46 lines
1.2 KiB
TypeScript

import { useTranslation } from 'react-i18next'
import { User } from '../../../../../../types/group-management/user'
import MaterialIcon from '@/shared/components/material-icon'
type ManagedUserStatusProps = {
user: User
}
export default function ManagedUserStatus({ user }: ManagedUserStatusProps) {
const { t } = useTranslation()
const managedUserInvite = (
<span className="security-state-invite-pending">
<MaterialIcon
type="schedule"
category="outlined"
accessibilityLabel={t('pending_invite')}
/>
&nbsp;
{t('managed')}
</span>
)
const managedUserAccepted = (
<span className="security-state-managed">
<MaterialIcon type="check" accessibilityLabel={t('managed')} />
&nbsp;
{t('managed')}
</span>
)
const managedUserNotAccepted = (
<span className="security-state-not-managed">
<MaterialIcon type="close" accessibilityLabel={t('not_managed')} />
&nbsp;
{t('managed')}
</span>
)
if (user.isEntityAdmin) {
return <span className="security-state-group-admin" />
}
if (user.invite) {
return managedUserInvite
}
return user.enrollment?.managedBy
? managedUserAccepted
: managedUserNotAccepted
}