mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-01-30 23:39:48 +05:30
#145: add success state for feedback form
This commit is contained in:
parent
187d4f12f4
commit
3f77144a53
@ -33,8 +33,8 @@ class ContactForm extends Component {
|
||||
form = new FormModel();
|
||||
|
||||
render() {
|
||||
const {onClose, user} = this.props;
|
||||
const {form} = this;
|
||||
const {isSuccessfullySent = false} = this.state || {};
|
||||
const {onClose} = this.props;
|
||||
|
||||
return (
|
||||
<div className={styles.contactForm}>
|
||||
@ -46,6 +46,20 @@ class ContactForm extends Component {
|
||||
<span className={classNames(icons.close, popupStyles.close)} onClick={onClose} />
|
||||
</div>
|
||||
|
||||
{isSuccessfullySent
|
||||
? (<div>Hello world<Button onClick={onClose} label="Close" /></div>)
|
||||
: this.renderForm()
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderForm() {
|
||||
const {form} = this;
|
||||
const {user} = this.props;
|
||||
|
||||
return (
|
||||
<Form form={form} onSubmit={this.onSubmit}>
|
||||
<div className={popupStyles.body}>
|
||||
<div className={styles.philosophicalThought}>
|
||||
@ -94,14 +108,12 @@ class ContactForm extends Component {
|
||||
<Button label={messages.send} block />
|
||||
</div>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
onSubmit = () => {
|
||||
feedback(this.form.serialize())
|
||||
.then(this.props.onClose)
|
||||
.then(() => this.setState({isSuccessfullySent: true}))
|
||||
.catch((resp) => {
|
||||
if (resp.errors) {
|
||||
this.form.setErrors(resp.errors);
|
||||
|
Loading…
x
Reference in New Issue
Block a user