2016-05-22 22:55:38 +05:30
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
|
|
|
|
2016-05-26 03:07:18 +05:30
|
|
|
import { Input, TextArea, Button, Form, FormModel, Dropdown } from 'components/ui/form';
|
2016-05-22 22:55:38 +05:30
|
|
|
import site from 'services/api/site';
|
|
|
|
import icons from 'components/ui/icons.scss';
|
2016-05-28 04:06:01 +05:30
|
|
|
import popupStyles from 'components/ui/popup/popup.scss';
|
2016-05-22 22:55:38 +05:30
|
|
|
|
|
|
|
import styles from './contactForm.scss';
|
|
|
|
import messages from './contactForm.intl.json';
|
|
|
|
|
2016-05-28 04:44:28 +05:30
|
|
|
const CONTACT_CATEGORIES = ['Foo', 'Bar', 'Baz'];
|
|
|
|
|
2016-05-22 22:55:38 +05:30
|
|
|
export default class ContactForm extends Component {
|
|
|
|
static displayName = 'ContactForm';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
onClose: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
form = new FormModel();
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {onClose} = this.props;
|
|
|
|
const {form} = this;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.contactForm}>
|
2016-05-26 03:07:18 +05:30
|
|
|
<div className={popupStyles.header}>
|
|
|
|
<h2 className={popupStyles.headerTitle}>
|
2016-05-22 22:55:38 +05:30
|
|
|
<Message {...messages.title} />
|
|
|
|
</h2>
|
2016-06-03 00:00:46 +05:30
|
|
|
<span className={classNames(icons.close, popupStyles.close)} onClick={onClose} />
|
2016-05-22 22:55:38 +05:30
|
|
|
</div>
|
|
|
|
|
|
|
|
<Form form={form} onSubmit={this.onSubmit}>
|
2016-05-26 03:07:18 +05:30
|
|
|
<div className={popupStyles.body}>
|
|
|
|
<div className={styles.philosophicalThought}>
|
|
|
|
<Message {...messages.philosophicalThought} />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.formDisclaimer}>
|
|
|
|
<Message {...messages.disclaimer} /><br />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.pairInputRow}>
|
|
|
|
<div className={styles.pairInput}>
|
|
|
|
<Input
|
|
|
|
{...form.bindField('subject')}
|
|
|
|
required
|
|
|
|
label={messages.subject}
|
|
|
|
skin="light"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.pairInput}>
|
|
|
|
<Input
|
|
|
|
{...form.bindField('email')}
|
|
|
|
required
|
|
|
|
label={messages.email}
|
|
|
|
type="email"
|
|
|
|
skin="light"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.formMargin}>
|
2016-05-28 04:44:28 +05:30
|
|
|
<Dropdown label={messages.whichQuestion} items={CONTACT_CATEGORIES} block />
|
2016-05-26 03:07:18 +05:30
|
|
|
</div>
|
|
|
|
|
|
|
|
<TextArea
|
|
|
|
{...form.bindField('message')}
|
|
|
|
required
|
|
|
|
label={messages.message}
|
|
|
|
skin="light"
|
|
|
|
/>
|
|
|
|
</div>
|
2016-05-22 22:55:38 +05:30
|
|
|
|
|
|
|
<div className={styles.footer}>
|
|
|
|
<Button label={messages.send} block />
|
|
|
|
</div>
|
|
|
|
</Form>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
onSubmit = () => {
|
|
|
|
site.contact(this.form.serialize())
|
|
|
|
.then(this.props.onClose)
|
|
|
|
.catch((resp) => {
|
|
|
|
if (resp.errors) {
|
|
|
|
this.form.setErrors(resp.errors);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.reject(resp);
|
|
|
|
})
|
|
|
|
;
|
|
|
|
};
|
|
|
|
}
|