diff --git a/src/components/auth/PanelTransition.jsx b/src/components/auth/PanelTransition.jsx index 027fdd1..a72faf4 100644 --- a/src/components/auth/PanelTransition.jsx +++ b/src/components/auth/PanelTransition.jsx @@ -184,8 +184,8 @@ class PanelTransition extends Component { this.body.onFormSubmit(); }; - onFormInvalid = (errorMessage) => { - this.props.setError(errorMessage); + onFormInvalid = (errors) => { + this.props.setError(Object.values(errors).shift()); }; willEnter = (config) => this.getTransitionStyles(config); diff --git a/src/components/profile/changePassword/ChangePassword.jsx b/src/components/profile/changePassword/ChangePassword.jsx index e188a10..37ad250 100644 --- a/src/components/profile/changePassword/ChangePassword.jsx +++ b/src/components/profile/changePassword/ChangePassword.jsx @@ -14,16 +14,23 @@ export default class ChangePassword extends Component { static displayName = 'ChangePassword'; static propTypes = { + form: PropTypes.instanceOf(FormModel).isRequired, onSubmit: PropTypes.func.isRequired }; - form = new FormModel(); + static get defaultProps() { + return { + form: new FormModel() + }; + } render() { - const {form} = this; + const {form} = this.props; return ( -
+
@@ -89,6 +96,6 @@ export default class ChangePassword extends Component { } onFormSubmit = () => { - this.props.onSubmit(this.form.serialize()); + this.props.onSubmit(this.props.form); }; } diff --git a/src/components/profile/passwordRequestForm/PasswordRequestForm.jsx b/src/components/profile/passwordRequestForm/PasswordRequestForm.jsx index 6219d8f..efa42b5 100644 --- a/src/components/profile/passwordRequestForm/PasswordRequestForm.jsx +++ b/src/components/profile/passwordRequestForm/PasswordRequestForm.jsx @@ -11,19 +11,22 @@ export default class PasswordRequestForm extends Component { static displayName = 'PasswordRequestForm'; static propTypes = { + form: PropTypes.instanceOf(FormModel).isRequired, onSubmit: PropTypes.func.isRequired }; - form = new FormModel(); - render() { + const {form} = this.props; + return ( - +

- { - this.props.onSubmit(this.form.value('password')); + this.props.onSubmit(this.props.form); }; } diff --git a/src/components/ui/form/Button.jsx b/src/components/ui/form/Button.jsx index e838139..40d44a3 100644 --- a/src/components/ui/form/Button.jsx +++ b/src/components/ui/form/Button.jsx @@ -1,11 +1,12 @@ -import React, { Component, PropTypes } from 'react'; +import React, { PropTypes } from 'react'; import classNames from 'classnames'; -import { intlShape } from 'react-intl'; import buttons from 'components/ui/buttons.scss'; -export default class Button extends Component { +import FormComponent from './FormComponent'; + +export default class Button extends FormComponent { static displayName = 'Button'; static propTypes = { @@ -19,10 +20,6 @@ export default class Button extends Component { color: PropTypes.oneOf(['green', 'blue', 'red', 'lightViolet', 'darkBlue']) }; - static contextTypes = { - intl: intlShape.isRequired - }; - render() { const { color = 'green', block } = this.props; @@ -30,9 +27,7 @@ export default class Button extends Component { ...this.props }; - if (props.label.id) { - props.label = this.context.intl.formatMessage(props.label); - } + props.label = this.formatMessage(props.label); return (