2015-07-09 00:29:29 -07:00
|
|
|
import React, { PropTypes } from 'react';
|
2015-07-15 10:54:03 -07:00
|
|
|
import { Col, Row, Panel } from 'react-bootstrap';
|
|
|
|
import { contain } from 'thundercats-react';
|
2015-07-09 00:29:29 -07:00
|
|
|
import stampit from 'react-stampit';
|
|
|
|
// import debugFactory from 'debug';
|
|
|
|
|
2015-07-15 10:54:03 -07:00
|
|
|
export default contain(
|
|
|
|
{
|
|
|
|
store: 'hikesStore',
|
|
|
|
map({ hikes, currentHike }) {
|
|
|
|
const { tests = [] } = currentHike;
|
|
|
|
return {
|
|
|
|
hikes,
|
|
|
|
currentHike,
|
|
|
|
tests
|
|
|
|
};
|
|
|
|
},
|
|
|
|
fetchAction: 'hikesActions.getHike',
|
|
|
|
getPayload({ currentHike, hikes, params: { dashedName } }) {
|
|
|
|
const filterRegex = new RegExp(dashedName, 'i');
|
|
|
|
if (currentHike && filterRegex.test(currentHike.dashedName)) {
|
|
|
|
return {
|
|
|
|
hikes: [],
|
|
|
|
isPrimed: true,
|
|
|
|
dashedName
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
hikes,
|
|
|
|
isPrimed: false,
|
|
|
|
dashedName: dashedName
|
|
|
|
};
|
|
|
|
}
|
2015-07-09 00:29:29 -07:00
|
|
|
},
|
2015-07-15 10:54:03 -07:00
|
|
|
stampit(React, {
|
|
|
|
displayName: 'Question',
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
params: PropTypes.object,
|
|
|
|
currentHike: PropTypes.object,
|
|
|
|
tests: PropTypes.array
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
2015-07-15 21:56:06 -07:00
|
|
|
const { tests } = this.props;
|
|
|
|
const { number = '1' } = this.props.params;
|
|
|
|
|
|
|
|
const [question, answer, info] = tests[number - 1] || [];
|
2015-07-09 00:29:29 -07:00
|
|
|
|
2015-07-15 10:54:03 -07:00
|
|
|
return (
|
|
|
|
<Col xs={ 12 }>
|
|
|
|
<Row>
|
|
|
|
<Panel>
|
|
|
|
<p>{ question }</p>
|
|
|
|
</Panel>
|
|
|
|
</Row>
|
|
|
|
</Col>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|