overleaf/services/web/frontend/js/features/settings/components/emails/email.tsx
Timothée Alby 20d5291308 Merge pull request #8199 from overleaf/ii-settings-ts-fixes
[web] Fix TS errors in settings area

GitOrigin-RevId: 48f3695570bd794b4865bd45a29aa6fc9bf57502
2022-05-31 08:04:26 +00:00

44 lines
1.3 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
)
return (
<>
{userEmailData.email}
{userEmailData.default ? ' (primary)' : ''}
{!userEmailData.confirmedAt && (
<div className="small">
<strong>
{t('unconfirmed')}.
{!ssoAvailable && <span> {t('please_check_your_inbox')}.</span>}
</strong>
<br />
{!ssoAvailable && (
<ResendConfirmationEmailButton email={userEmailData.email} />
)}
</div>
)}
{userEmailData.confirmedAt &&
userEmailData.affiliation?.institution.confirmed &&
userEmailData.affiliation.licence !== 'free' && (
<div className="small">
<span className="label label-primary">{t('professional')}</span>
</div>
)}
</>
)
}
export default Email