import React, { PropTypes } from 'react'; import { Link } from 'react-router'; import { connect } from 'react-redux'; import FA from 'react-fontawesome'; import PureComponent from 'react-pure-render/component'; import { Panel } from 'react-bootstrap'; import classnames from 'classnames'; import { updateCurrentChallenge } from '../../redux/actions'; const dispatchActions = { updateCurrentChallenge }; export class Block extends PureComponent { static displayName = 'Block'; static propTypes = { title: PropTypes.string, dashedName: PropTypes.string, time: PropTypes.string, challenges: PropTypes.array, updateCurrentChallenge: PropTypes.func }; renderChallenges(blockName, challenges, updateCurrentChallenge) { if (!Array.isArray(challenges) || !challenges.length) { return
No Challenges Found
; } return challenges.map(challenge => { const { title, dashedName, isLocked, isRequired } = challenge; const challengeClassName = classnames({ 'text-primary': true, 'padded-ionic-icon': true, 'negative-15': true, 'challenge-title': true, 'ion-checkmark-circled': !isLocked, 'ion-locked': isLocked, disabled: isLocked }); if (isLocked) { return (

{ title } { isRequired ? * : '' }

); } return (

updateCurrentChallenge(challenge) } > { title } complete { isRequired ? * : '' }

); }); } render() { const { title, time, challenges, updateCurrentChallenge, dashedName } = this.props; return (

{ title }

({ time }) } id={ title } key={ title } > { this.renderChallenges(dashedName, challenges, updateCurrentChallenge) }
); } } export default connect(null, dispatchActions)(Block);