2023-10-19 08:51:33 -04:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2023-11-09 11:26:46 -05:00
|
|
|
import getMeta from '@/utils/meta'
|
2023-10-19 08:51:33 -04:00
|
|
|
import { User } from '../../../../../../types/group-management/user'
|
|
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
|
|
|
|
|
|
type SSOStatusProps = {
|
|
|
|
user: User
|
|
|
|
}
|
2023-11-09 11:26:46 -05:00
|
|
|
|
2023-10-19 08:51:33 -04:00
|
|
|
export default function SSOStatus({ user }: SSOStatusProps) {
|
2023-11-09 11:26:46 -05:00
|
|
|
const groupId = getMeta('ol-groupId')
|
|
|
|
|
|
|
|
if (user.invite) {
|
|
|
|
return <PendingInvite />
|
|
|
|
}
|
|
|
|
|
|
|
|
const linkedSSO = user.enrollment?.sso?.some(sso => sso.groupId === groupId)
|
|
|
|
|
|
|
|
return linkedSSO ? <SSOLinked /> : <SSOUnlinked />
|
|
|
|
}
|
|
|
|
|
|
|
|
function PendingInvite() {
|
2023-10-19 08:51:33 -04:00
|
|
|
const { t } = useTranslation()
|
2023-11-09 11:26:46 -05:00
|
|
|
return (
|
2023-10-25 07:10:25 -04:00
|
|
|
<span className="security-state-invite-pending">
|
2024-02-15 04:43:16 -05:00
|
|
|
<MaterialIcon type="schedule" accessibilityLabel={t('pending_invite')} />
|
2023-10-25 07:10:25 -04:00
|
|
|
{t('sso')}
|
2023-10-19 08:51:33 -04:00
|
|
|
</span>
|
|
|
|
)
|
2023-11-09 11:26:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function SSOLinked() {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
return (
|
2023-10-25 07:10:25 -04:00
|
|
|
<span className="security-state-managed">
|
2023-10-27 09:11:34 -04:00
|
|
|
<MaterialIcon type="check" accessibilityLabel={t('sso_active')} />
|
2023-10-25 07:10:25 -04:00
|
|
|
{t('sso')}
|
|
|
|
</span>
|
|
|
|
)
|
2023-11-09 11:26:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function SSOUnlinked() {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
return (
|
2023-10-25 07:10:25 -04:00
|
|
|
<span className="security-state-not-managed">
|
2023-10-27 09:11:34 -04:00
|
|
|
<MaterialIcon type="close" accessibilityLabel={t('sso_not_active')} />
|
2023-10-25 07:10:25 -04:00
|
|
|
{t('sso')}
|
|
|
|
</span>
|
|
|
|
)
|
2023-10-19 08:51:33 -04:00
|
|
|
}
|