/*
 *
 * MastersOfUmdaarCharacter
 *
 */

import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import Helmet from 'react-helmet'
import { FormattedMessage } from 'react-intl'
import { createStructuredSelector } from 'reselect'
import makeSelectMastersOfUmdaarCharacter from './selectors'
import messages from './messages'
import {setCharacter} from './actions'
import buildCharacter from '../../utils/buildCharacter'
import {get} from 'lodash'

export class MastersOfUmdaarCharacter extends React.Component { // eslint-disable-line react/prefer-stateless-function
  componentDidMount () {
    this.generateCharacter()
  }

  generateCharacter () {
    const character = buildCharacter()
    const action = setCharacter(character)
    this.props.dispatch(action)
  }

  handleClick () {
    this.generateCharacter()
  }
  render () {
    const bioform = get(this, 'props.MastersOfUmdaarCharacter.character.bioform') || {}

    return (
      <div>
        <button onClick={this.handleClick.bind(this)}>
          Click to Fire Up the Recombinator
        </button>

        <div>
          {bioform.type}
        </div>
        <div>
          {(bioform.animals && bioform.animals.length) ? 'Animals: ' + bioform.animals.join(' | ') : undefined}
        </div>
        <div>
          {'Approaches: ' + (bioform.approaches && bioform.approaches.join(' | '))}
        </div>
      </div>
    )
  }
}

MastersOfUmdaarCharacter.propTypes = {
  dispatch: PropTypes.func.isRequired,
  character: PropTypes.object
}

const mapStateToProps = createStructuredSelector({
  MastersOfUmdaarCharacter: makeSelectMastersOfUmdaarCharacter()
})

function mapDispatchToProps (dispatch) {
  return {
    dispatch
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(MastersOfUmdaarCharacter)

@@ -1304,18 +1304,26 @@
        %7B
-'A
+(bioform.a
 pproache
@@ -1327,15 +1327,12 @@
 ches
-: ' + (
+ && 
 biof
@@ -1337,35 +1337,59 @@
 oform.approaches
- &&
+.length) ? 'Approaches: ' +
  bioform.approac
@@ -1403,17 +1403,28 @@
 n(' %7C ')
-)
+ : undefined
 %7D%0A      

Update index.js