import React, { PropTypes } from 'react'; import PureComponent from 'react-pure-render/component'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { Button, ButtonGroup } from 'react-bootstrap'; import { FrontEndForm, BackEndForm } from './Forms.jsx'; import { submitChallenge, openBugModal } from '../../redux/actions'; import { challengeSelector } from '../../redux/selectors'; import { simpleProject, frontEndProject } from '../../../../utils/challengeTypes'; const propTypes = { isSignedIn: PropTypes.bool, isSimple: PropTypes.bool, isFrontEnd: PropTypes.bool, isSubmitting: PropTypes.bool, helpChatRoom: PropTypes.string.isRequired, openBugModal: PropTypes.func.isRequired, submitChallenge: PropTypes.func.isRequired }; const mapDispatchToProps = { submitChallenge, openBugModal }; const mapStateToProps = createSelector( challengeSelector, state => state.app.isSignedIn, state => state.challengesApp.isSubmitting, state => state.challengesApp.helpChatRoom, ( { challenge: { challengeType = simpleProject } }, isSignedIn, isSubmitting, helpChatRoom, ) => ({ isSignedIn, isSubmitting, helpChatRoom, isSimple: challengeType === simpleProject, isFrontEnd: challengeType === frontEndProject }) ); export class ToolPanel extends PureComponent { renderSubmitButton(isSignedIn, submitChallenge) { const buttonCopy = isSignedIn ? 'Submit and go to my next challenge' : "I've completed this challenge"; return ( ); } render() { const { isFrontEnd, isSimple, isSignedIn, isSubmitting, helpChatRoom, submitChallenge, openBugModal } = this.props; const FormElement = isFrontEnd ? FrontEndForm : BackEndForm; return (