import React from 'react'; import PropTypes from 'prop-types'; import { compose } from 'redux'; import { connect } from 'react-redux'; import { FormattedMessage, injectIntl, intlShape } from 'react-intl'; import { propTypes } from '../../util/types'; import { isPasswordRecoveryEmailNotFoundError, isPasswordRecoveryEmailNotVerifiedError, } from '../../util/errors'; import { isScrollingDisabled } from '../../ducks/UI.duck'; import { Page, InlineTextButton, IconKeys, LayoutSingleColumn, LayoutWrapperMain, LayoutWrapperTopbar, LayoutWrapperFooter, Footer, } from '../../components'; import { PasswordRecoveryForm } from '../../forms'; import { TopbarContainer } from '../../containers'; import { recoverPassword, retypePasswordRecoveryEmail, clearPasswordRecoveryError, } from './PasswordRecoveryPage.duck'; import DoorIcon from './DoorIcon'; import css from './PasswordRecoveryPage.css'; export const PasswordRecoveryPageComponent = props => { const { scrollingDisabled, initialEmail, submittedEmail, recoveryError, recoveryInProgress, passwordRequested, onChange, onSubmitEmail, onRetypeEmail, intl, } = props; const title = intl.formatMessage({ id: 'PasswordRecoveryPage.title', }); const resendEmailLink = ( onSubmitEmail(submittedEmail)}> ); const fixEmailLink = ( ); const submitEmailContent = (

onSubmitEmail(values.email)} initialValues={{ email: initialEmail }} recoveryError={recoveryError} />
); const submittedEmailText = passwordRequested ? ( {initialEmail} ) : ( {submittedEmail} ); const emailSubmittedContent = (

{recoveryInProgress ? ( ) : ( )}

); const initialEmailText = {initialEmail}; const emailNotVerifiedContent = (

); const genericErrorContent = (

); let content; if (isPasswordRecoveryEmailNotVerifiedError(recoveryError)) { content = emailNotVerifiedContent; } else if (isPasswordRecoveryEmailNotFoundError(recoveryError)) { content = submitEmailContent; } else if (recoveryError) { content = genericErrorContent; } else if (submittedEmail || passwordRequested) { content = emailSubmittedContent; } else { content = submitEmailContent; } return (
{content}