mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-18 03:01:07 -05:00
dfc33805cb
Move "Primary" badge under the email address in settings GitOrigin-RevId: ecb11047d9db6feb3bc0128f4a1d490836be7ab5
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import { UserEmailData } from '../../../../../../types/user-email'
|
|
import ResendConfirmationEmailButton from './resend-confirmation-email-button'
|
|
import { ssoAvailableForInstitution } from '../../utils/sso'
|
|
|
|
type EmailProps = {
|
|
userEmailData: UserEmailData
|
|
}
|
|
|
|
function Email({ userEmailData }: EmailProps) {
|
|
const { t } = useTranslation()
|
|
|
|
const ssoAvailable = ssoAvailableForInstitution(
|
|
userEmailData.affiliation?.institution || null
|
|
)
|
|
|
|
const isPrimary = userEmailData.default
|
|
const isProfessional =
|
|
userEmailData.confirmedAt &&
|
|
userEmailData.affiliation?.institution.confirmed &&
|
|
userEmailData.affiliation.licence !== 'free'
|
|
const hasBadges = isPrimary || isProfessional
|
|
|
|
return (
|
|
<>
|
|
{userEmailData.email}
|
|
{!userEmailData.confirmedAt && (
|
|
<div className="small">
|
|
<strong>
|
|
{t('unconfirmed')}.
|
|
{!ssoAvailable && <span> {t('please_check_your_inbox')}.</span>}
|
|
</strong>
|
|
<br />
|
|
{!ssoAvailable && (
|
|
<ResendConfirmationEmailButton email={userEmailData.email} />
|
|
)}
|
|
</div>
|
|
)}
|
|
{hasBadges && (
|
|
<div className="small">
|
|
{isPrimary && (
|
|
<>
|
|
<span className="label label-info">Primary</span>{' '}
|
|
</>
|
|
)}
|
|
{isProfessional && (
|
|
<span className="label label-primary">{t('professional')}</span>
|
|
)}
|
|
</div>
|
|
)}
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default Email
|