var React = require('react/addons') var ReactRouter = require('react-router') var Catalyst = require('../Mixins/Catalyst') var PlanetStore = require('../Stores/PlanetStore') var SnippetForm = require('./SnippetForm') var BlueprintForm = require('./BlueprintForm') var LaunchModal = React.createClass({ mixins: [Catalyst.LinkedStateMixin, ReactRouter.State], propTypes: { submit: React.PropTypes.func, close: React.PropTypes.func }, getInitialState: function () { return { currentTab: 'snippet' } }, componentDidMount: function () { this.unsubscribe = PlanetStore.listen(this.onListen) }, componentWillUnmount: function () { this.unsubscribe() }, onListen: function (res) { switch (res.status) { case 'articleCreated': this.props.close() break } }, stopPropagation: function (e) { e.stopPropagation() }, selectSnippetTab: function () { this.setState({currentTab: 'snippet'}) }, selectBlueprintTab: function () { this.setState({currentTab: 'blueprint'}) }, submit: function () { if (this.state.currentTab === 'snippet') { console.log(this.state.snippet) } else { console.log(this.state.blueprint) } }, handleKeyDown: function (e) { if (e.keyCode === 37 && e.metaKey) { this.selectSnippetTab() } if (e.keyCode === 39 && e.metaKey) { this.selectBlueprintTab() } }, render: function () { var modalBody if (this.state.currentTab === 'snippet') { modalBody = ( ) } else { modalBody = ( ) } return (
{modalBody}
) } }) module.exports = LaunchModal