mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-15 15:00:58 -05:00
6cb956b1ff
[web] Add Stylelint formatting to the CI GitOrigin-RevId: f31139f9f6f70aa96214b59db37ad1f79cd1e733
96 lines
2.8 KiB
TypeScript
96 lines
2.8 KiB
TypeScript
import { Fragment } from 'react'
|
|
import { useTranslation, Trans } from 'react-i18next'
|
|
import getMeta from '../../../utils/meta'
|
|
import {
|
|
UserEmailsProvider,
|
|
useUserEmailsContext,
|
|
} from '../context/user-email-context'
|
|
import EmailsHeader from './emails/header'
|
|
import EmailsRow from './emails/row'
|
|
import AddEmail from './emails/add-email'
|
|
import Icon from '../../../shared/components/icon'
|
|
import OLNotification from '@/features/ui/components/ol/ol-notification'
|
|
import { LeaversSurveyAlert } from './leavers-survey-alert'
|
|
|
|
function EmailsSectionContent() {
|
|
const { t } = useTranslation()
|
|
const {
|
|
state: { data: userEmailsData },
|
|
isInitializing,
|
|
isInitializingError,
|
|
isInitializingSuccess,
|
|
} = useUserEmailsContext()
|
|
const userEmails = Object.values(userEmailsData.byId)
|
|
|
|
// Only show the "add email" button if the user has permission to add a secondary email
|
|
const hideAddSecondaryEmail = getMeta('ol-cannot-add-secondary-email')
|
|
|
|
return (
|
|
<>
|
|
<h3>{t('emails_and_affiliations_title')}</h3>
|
|
<p className="small">{t('emails_and_affiliations_explanation')}</p>
|
|
<p className="small">
|
|
<Trans
|
|
i18nKey="change_primary_email_address_instructions"
|
|
components={[
|
|
// eslint-disable-next-line react/jsx-key
|
|
<strong />,
|
|
// eslint-disable-next-line jsx-a11y/anchor-has-content, react/jsx-key
|
|
<a
|
|
href="/learn/how-to/Managing_your_Overleaf_emails"
|
|
target="_blank"
|
|
/>,
|
|
]}
|
|
/>
|
|
</p>
|
|
<>
|
|
<EmailsHeader />
|
|
{isInitializing ? (
|
|
<div className="affiliations-table-row-highlighted">
|
|
<div className="affiliations-table-cell text-center">
|
|
<Icon type="refresh" fw spin /> {t('loading')}...
|
|
</div>
|
|
</div>
|
|
) : (
|
|
<>
|
|
{userEmails?.map(userEmail => (
|
|
<Fragment key={userEmail.email}>
|
|
<EmailsRow userEmailData={userEmail} />
|
|
<div className="horizontal-divider" />
|
|
</Fragment>
|
|
))}
|
|
</>
|
|
)}
|
|
{isInitializingSuccess && <LeaversSurveyAlert />}
|
|
{isInitializingSuccess && !hideAddSecondaryEmail && <AddEmail />}
|
|
{isInitializingError && (
|
|
<OLNotification
|
|
type="error"
|
|
content={t('error_performing_request')}
|
|
bs3Props={{
|
|
icon: <Icon type="exclamation-triangle" fw />,
|
|
className: 'text-center',
|
|
}}
|
|
/>
|
|
)}
|
|
</>
|
|
</>
|
|
)
|
|
}
|
|
|
|
function EmailsSection() {
|
|
const { hasAffiliationsFeature } = getMeta('ol-ExposedSettings')
|
|
if (!hasAffiliationsFeature) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<UserEmailsProvider>
|
|
<EmailsSectionContent />
|
|
</UserEmailsProvider>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default EmailsSection
|