mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
prevent for submit with invalid values
This commit is contained in:
@@ -49,22 +49,30 @@ class UserForm extends React.Component<Props, State> {
|
|||||||
this.setState({ user: { ...this.props.user } });
|
this.setState({ user: { ...this.props.user } });
|
||||||
}
|
}
|
||||||
|
|
||||||
submit = (event: Event) => {
|
isValid = () => {
|
||||||
event.preventDefault();
|
|
||||||
this.props.submitForm(this.state.user);
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { t } = this.props;
|
|
||||||
const user = this.state.user;
|
const user = this.state.user;
|
||||||
const ButtonClickable =
|
return !(
|
||||||
this.state.validatePasswordError ||
|
this.state.validatePasswordError ||
|
||||||
this.state.nameValidationError ||
|
this.state.nameValidationError ||
|
||||||
this.state.mailValidationError ||
|
this.state.mailValidationError ||
|
||||||
this.state.validatePasswordError ||
|
this.state.validatePasswordError ||
|
||||||
this.state.displayNameValidationError ||
|
this.state.displayNameValidationError ||
|
||||||
user.name === undefined ||
|
user.name === undefined ||
|
||||||
user.displayName === undefined;
|
user.displayName === undefined
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
submit = (event: Event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
if (this.isValid()) {
|
||||||
|
this.props.submitForm(this.state.user);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { t } = this.props;
|
||||||
|
const user = this.state.user;
|
||||||
|
|
||||||
let nameField = null;
|
let nameField = null;
|
||||||
if (!this.props.user) {
|
if (!this.props.user) {
|
||||||
nameField = (
|
nameField = (
|
||||||
@@ -121,7 +129,7 @@ class UserForm extends React.Component<Props, State> {
|
|||||||
checked={user ? user.active : false}
|
checked={user ? user.active : false}
|
||||||
/>
|
/>
|
||||||
<SubmitButton
|
<SubmitButton
|
||||||
disabled={ButtonClickable}
|
disabled={!this.isValid()}
|
||||||
label={t("user-form.submit")}
|
label={t("user-form.submit")}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user