mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
#145: add success state for feedback form
This commit is contained in:
@ -33,8 +33,8 @@ class ContactForm extends Component {
|
|||||||
form = new FormModel();
|
form = new FormModel();
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {onClose, user} = this.props;
|
const {isSuccessfullySent = false} = this.state || {};
|
||||||
const {form} = this;
|
const {onClose} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.contactForm}>
|
<div className={styles.contactForm}>
|
||||||
@ -46,6 +46,20 @@ class ContactForm extends Component {
|
|||||||
<span className={classNames(icons.close, popupStyles.close)} onClick={onClose} />
|
<span className={classNames(icons.close, popupStyles.close)} onClick={onClose} />
|
||||||
</div>
|
</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}>
|
<Form form={form} onSubmit={this.onSubmit}>
|
||||||
<div className={popupStyles.body}>
|
<div className={popupStyles.body}>
|
||||||
<div className={styles.philosophicalThought}>
|
<div className={styles.philosophicalThought}>
|
||||||
@ -94,14 +108,12 @@ class ContactForm extends Component {
|
|||||||
<Button label={messages.send} block />
|
<Button label={messages.send} block />
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit = () => {
|
onSubmit = () => {
|
||||||
feedback(this.form.serialize())
|
feedback(this.form.serialize())
|
||||||
.then(this.props.onClose)
|
.then(() => this.setState({isSuccessfullySent: true}))
|
||||||
.catch((resp) => {
|
.catch((resp) => {
|
||||||
if (resp.errors) {
|
if (resp.errors) {
|
||||||
this.form.setErrors(resp.errors);
|
this.form.setErrors(resp.errors);
|
||||||
|
Reference in New Issue
Block a user