|
|
@@ -6,8 +6,6 @@ import ReconfirmationInfoPromptText from './reconfirmation-info/reconfirmation-i
|
|
|
import OLRow from '@/features/ui/components/ol/ol-row'
|
|
|
import OLCol from '@/features/ui/components/ol/ol-col'
|
|
|
import OLNotification from '@/features/ui/components/ol/ol-notification'
|
|
|
-import { isBootstrap5 } from '@/features/utils/bootstrap-5'
|
|
|
-import Icon from '@/shared/components/icon'
|
|
|
import { useUserEmailsContext } from '@/features/settings/context/user-email-context'
|
|
|
import { FetchError, postJSON } from '@/infrastructure/fetch-json'
|
|
|
import { debugConsole } from '@/utils/debugging'
|
|
|
@@ -16,14 +14,13 @@ import { Trans, useTranslation } from 'react-i18next'
|
|
|
import useAsync from '@/shared/hooks/use-async'
|
|
|
import { useLocation } from '@/shared/hooks/use-location'
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
|
|
-import classnames from 'classnames'
|
|
|
+import LoadingSpinner from '@/shared/components/loading-spinner'
|
|
|
|
|
|
type ReconfirmationInfoProps = {
|
|
|
userEmailData: UserEmailData
|
|
|
}
|
|
|
|
|
|
function ReconfirmationInfo({ userEmailData }: ReconfirmationInfoProps) {
|
|
|
- const reconfirmationRemoveEmail = getMeta('ol-reconfirmationRemoveEmail')
|
|
|
const reconfirmedViaSAML = getMeta('ol-reconfirmedViaSAML')
|
|
|
|
|
|
const { t } = useTranslation()
|
|
|
@@ -86,7 +83,6 @@ function ReconfirmationInfo({ userEmailData }: ReconfirmationInfoProps) {
|
|
|
institution={userEmailData.affiliation.institution}
|
|
|
/>
|
|
|
}
|
|
|
- bs3Props={{ className: 'settings-reconfirm-info small' }}
|
|
|
/>
|
|
|
</OLCol>
|
|
|
</OLRow>
|
|
|
@@ -97,88 +93,11 @@ function ReconfirmationInfo({ userEmailData }: ReconfirmationInfoProps) {
|
|
|
return (
|
|
|
<OLRow>
|
|
|
<OLCol lg={12}>
|
|
|
- {isBootstrap5() ? (
|
|
|
- <OLNotification
|
|
|
- type="info"
|
|
|
- content={
|
|
|
- <>
|
|
|
- {hasSent ? (
|
|
|
- <Trans
|
|
|
- i18nKey="please_check_your_inbox_to_confirm"
|
|
|
- values={{
|
|
|
- institutionName:
|
|
|
- userEmailData.affiliation.institution.name,
|
|
|
- }}
|
|
|
- shouldUnescape
|
|
|
- tOptions={{ interpolation: { escapeValue: true } }}
|
|
|
- components={
|
|
|
- /* eslint-disable-next-line jsx-a11y/anchor-has-content, react/jsx-key */
|
|
|
- [<strong />]
|
|
|
- }
|
|
|
- />
|
|
|
- ) : (
|
|
|
- <ReconfirmationInfoPromptText
|
|
|
- institutionName={
|
|
|
- userEmailData.affiliation.institution.name
|
|
|
- }
|
|
|
- primary={userEmailData.default}
|
|
|
- />
|
|
|
- )}
|
|
|
- <br />
|
|
|
- {isError && (
|
|
|
- <div className="text-danger">
|
|
|
- {rateLimited
|
|
|
- ? t('too_many_requests')
|
|
|
- : t('generic_something_went_wrong')}
|
|
|
- </div>
|
|
|
- )}
|
|
|
- </>
|
|
|
- }
|
|
|
- action={
|
|
|
- hasSent ? (
|
|
|
- <>
|
|
|
- {isLoading ? (
|
|
|
- <>
|
|
|
- <Icon type="refresh" spin fw /> {t('sending')}...
|
|
|
- </>
|
|
|
- ) : (
|
|
|
- <OLButton
|
|
|
- variant="link"
|
|
|
- disabled={state.isLoading}
|
|
|
- onClick={handleRequestReconfirmation}
|
|
|
- className="btn-inline-link"
|
|
|
- >
|
|
|
- {t('resend_confirmation_email')}
|
|
|
- </OLButton>
|
|
|
- )}
|
|
|
- </>
|
|
|
- ) : (
|
|
|
- <OLButton
|
|
|
- variant="secondary"
|
|
|
- disabled={isPending}
|
|
|
- isLoading={isLoading}
|
|
|
- onClick={handleRequestReconfirmation}
|
|
|
- >
|
|
|
- {isLoading ? (
|
|
|
- <>
|
|
|
- <Icon type="refresh" spin fw /> {t('sending')}...
|
|
|
- </>
|
|
|
- ) : (
|
|
|
- t('confirm_affiliation')
|
|
|
- )}
|
|
|
- </OLButton>
|
|
|
- )
|
|
|
- }
|
|
|
- />
|
|
|
- ) : (
|
|
|
- <div
|
|
|
- className={classnames('settings-reconfirm-info', 'small', {
|
|
|
- 'alert alert-info':
|
|
|
- reconfirmationRemoveEmail === userEmailData.email,
|
|
|
- })}
|
|
|
- >
|
|
|
- {hasSent ? (
|
|
|
- <div>
|
|
|
+ <OLNotification
|
|
|
+ type="info"
|
|
|
+ content={
|
|
|
+ <>
|
|
|
+ {hasSent ? (
|
|
|
<Trans
|
|
|
i18nKey="please_check_your_inbox_to_confirm"
|
|
|
values={{
|
|
|
@@ -191,10 +110,29 @@ function ReconfirmationInfo({ userEmailData }: ReconfirmationInfoProps) {
|
|
|
/* eslint-disable-next-line jsx-a11y/anchor-has-content, react/jsx-key */
|
|
|
[<strong />]
|
|
|
}
|
|
|
- />{' '}
|
|
|
+ />
|
|
|
+ ) : (
|
|
|
+ <ReconfirmationInfoPromptText
|
|
|
+ institutionName={userEmailData.affiliation.institution.name}
|
|
|
+ primary={userEmailData.default}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ <br />
|
|
|
+ {isError && (
|
|
|
+ <div className="text-danger">
|
|
|
+ {rateLimited
|
|
|
+ ? t('too_many_requests')
|
|
|
+ : t('generic_something_went_wrong')}
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+ </>
|
|
|
+ }
|
|
|
+ action={
|
|
|
+ hasSent ? (
|
|
|
+ <>
|
|
|
{isLoading ? (
|
|
|
<>
|
|
|
- <Icon type="refresh" spin fw /> {t('sending')}...
|
|
|
+ <LoadingSpinner loadingText={`${t('sending')}…`} />
|
|
|
</>
|
|
|
) : (
|
|
|
<OLButton
|
|
|
@@ -206,55 +144,25 @@ function ReconfirmationInfo({ userEmailData }: ReconfirmationInfoProps) {
|
|
|
{t('resend_confirmation_email')}
|
|
|
</OLButton>
|
|
|
)}
|
|
|
- <br />
|
|
|
- {isError && (
|
|
|
- <div className="text-danger">
|
|
|
- {rateLimited
|
|
|
- ? t('too_many_requests')
|
|
|
- : t('generic_something_went_wrong')}
|
|
|
- </div>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- ) : (
|
|
|
- <>
|
|
|
- <div>
|
|
|
- <ReconfirmationInfoPromptText
|
|
|
- institutionName={
|
|
|
- userEmailData.affiliation.institution.name
|
|
|
- }
|
|
|
- primary={userEmailData.default}
|
|
|
- icon={
|
|
|
- <Icon type="warning" className="me-1 icon-warning" />
|
|
|
- }
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div className="setting-reconfirm-info-right">
|
|
|
- <OLButton
|
|
|
- variant="secondary"
|
|
|
- disabled={state.isLoading || isPending}
|
|
|
- onClick={handleRequestReconfirmation}
|
|
|
- >
|
|
|
- {isLoading ? (
|
|
|
- <>
|
|
|
- <Icon type="refresh" spin fw /> {t('sending')}...
|
|
|
- </>
|
|
|
- ) : (
|
|
|
- t('confirm_affiliation')
|
|
|
- )}
|
|
|
- </OLButton>
|
|
|
- <br />
|
|
|
- {isError && (
|
|
|
- <div className="text-danger">
|
|
|
- {rateLimited
|
|
|
- ? t('too_many_requests')
|
|
|
- : t('generic_something_went_wrong')}
|
|
|
- </div>
|
|
|
- )}
|
|
|
- </div>
|
|
|
</>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- )}
|
|
|
+ ) : (
|
|
|
+ <OLButton
|
|
|
+ variant="secondary"
|
|
|
+ disabled={isPending}
|
|
|
+ isLoading={isLoading}
|
|
|
+ onClick={handleRequestReconfirmation}
|
|
|
+ >
|
|
|
+ {isLoading ? (
|
|
|
+ <>
|
|
|
+ <LoadingSpinner loadingText={`${t('sending')}…`} />
|
|
|
+ </>
|
|
|
+ ) : (
|
|
|
+ t('confirm_affiliation')
|
|
|
+ )}
|
|
|
+ </OLButton>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ />
|
|
|
</OLCol>
|
|
|
</OLRow>
|
|
|
)
|