move loading state for add user back to the submit button

This change is necessary, because the old loading behaviour forces the form to rerender, which in turn causes a lost of the input. Now the loading state is back to the submit button.
This commit is contained in:
Sebastian Sdorra
2018-07-27 10:54:49 +02:00
parent c7171dd540
commit e34904afce
2 changed files with 7 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ import * as validator from "./userValidation";
type Props = { type Props = {
submitForm: User => void, submitForm: User => void,
user?: User, user?: User,
loading?: boolean,
t: string => string t: string => string
}; };
@@ -80,7 +81,7 @@ class UserForm extends React.Component<Props, State> {
}; };
render() { render() {
const { t } = this.props; const { loading, t } = this.props;
const user = this.state.user; const user = this.state.user;
let nameField = null; let nameField = null;
@@ -140,6 +141,7 @@ class UserForm extends React.Component<Props, State> {
/> />
<SubmitButton <SubmitButton
disabled={!this.isValid()} disabled={!this.isValid()}
loading={loading}
label={t("user-form.submit")} label={t("user-form.submit")}
/> />
</form> </form>

View File

@@ -38,10 +38,12 @@ class AddUser extends React.Component<Props> {
<Page <Page
title={t("add-user.title")} title={t("add-user.title")}
subtitle={t("add-user.subtitle")} subtitle={t("add-user.subtitle")}
loading={loading}
error={error} error={error}
> >
<UserForm submitForm={user => this.createUser(user)} /> <UserForm
submitForm={user => this.createUser(user)}
loading={loading}
/>
</Page> </Page>
); );
} }