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 { ExposedSettings } from '../../../../../types/exposed-settings' 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' ) as boolean return ( <>

{t('emails_and_affiliations_title')}

{t('emails_and_affiliations_explanation')}

, // eslint-disable-next-line jsx-a11y/anchor-has-content, react/jsx-key , ]} />

<> {isInitializing ? (
{t('loading')}...
) : ( <> {userEmails?.map(userEmail => (
))} )} {isInitializingSuccess && } {isInitializingSuccess && !hideAddSecondaryEmail && } {isInitializingError && ( , className: 'text-center', }} /> )} ) } function EmailsSection() { const { hasAffiliationsFeature } = getMeta( 'ol-ExposedSettings' ) as ExposedSettings if (!hasAffiliationsFeature) { return null } return ( <> ) } export default EmailsSection