Migrate auth components to new Context api

This commit is contained in:
SleepWalker
2019-12-13 09:26:29 +02:00
parent 08a2158042
commit 59debce051
8 changed files with 212 additions and 211 deletions

View File

@@ -16,14 +16,16 @@ export default class ForgotPasswordBody extends BaseAuthBody {
static hasGoBack = true;
state = {
isLoginEdit: !this.getLogin(),
isLoginEdit: false,
};
autoFocusField = this.state.isLoginEdit ? 'login' : null;
autoFocusField = 'login';
render() {
const { isLoginEdit } = this.state;
const login = this.getLogin();
const isLoginEditShown = this.state.isLoginEdit;
const isLoginEditShown = isLoginEdit || !login;
return (
<div>
@@ -79,11 +81,13 @@ export default class ForgotPasswordBody extends BaseAuthBody {
return login || user.username || user.email || '';
}
onClickEdit = () => {
onClickEdit = async () => {
this.setState({
isLoginEdit: true,
});
this.context.requestRedraw().then(() => this.form.focus('login'));
await this.context.requestRedraw();
this.form.focus('login');
};
}