import React from 'react'; import { FormattedMessage as Message } from 'react-intl'; import { Input, Captcha } from 'components/ui/form'; import { getLogin } from 'components/auth/reducer'; import { PanelIcon } from 'components/ui/Panel'; import BaseAuthBody from 'components/auth/BaseAuthBody'; import styles from './forgotPassword.scss'; import messages from './ForgotPassword.intl.json'; export default class ForgotPasswordBody extends BaseAuthBody { static displayName = 'ForgotPasswordBody'; static panelId = 'forgotPassword'; static hasGoBack = true; state = { isLoginEdit: !this.getLogin() }; autoFocusField = this.state.isLoginEdit ? 'login' : null; render() { const login = this.getLogin(); const isLoginEditShown = this.state.isLoginEdit; return (
{this.renderErrors()} {isLoginEditShown ? (

) : (
{login}

)}
); } serialize() { const data = super.serialize(); if (!data.login) { data.login = this.getLogin(); } return data; } getLogin() { const login = getLogin(this.context); const { user } = this.context; return login || user.username || user.email || ''; } onClickEdit = () => { this.setState({ isLoginEdit: true }); this.context.requestRedraw() .then(() => this.form.focus('login')); }; }