var React = require('react') var LinkedState = require('../Mixins/LinkedState') var KeyCaster = require('../Mixins/KeyCaster') var Hq = require('../Services/Hq') module.exports = React.createClass({ mixins: [LinkedState, KeyCaster('contactModal')], propTypes: { close: React.PropTypes.func }, getInitialState: function () { return { isSent: false, mail: { title: '', content: '' } } }, onKeyCast: function (e) { switch (e.status) { case 'closeModal': this.props.close() break case 'submitContactModal': if (this.state.isSent) { this.props.close() return } this.sendEmail() break } }, componentDidMount: function () { React.findDOMNode(this.refs.title).focus() }, sendEmail: function () { Hq.sendEmail(this.state.mail) .then(function (res) { this.setState({isSent: !this.state.isSent}) }.bind(this)) .catch(function (err) { console.error(err) }) }, render: function () { return (

Contact form

{!this.state.isSent ? (