Files
freeCodeCamp/common/app/routes/Hikes/components/Lecture.jsx

76 lines
1.7 KiB
React
Raw Normal View History

2015-07-09 00:29:29 -07:00
import React, { PropTypes } from 'react';
import { contain } from 'thundercats-react';
2015-07-10 12:10:03 -07:00
import { Col, Row, Panel } from 'react-bootstrap';
2015-07-09 00:29:29 -07:00
import stampit from 'react-stampit';
import Vimeo from 'react-vimeo';
import debugFactory from 'debug';
const debug = debugFactory('freecc:hikes');
export default contain(
{
store: 'hikesStore',
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
},
stampit(React, {
displayName: 'Lecture',
2015-07-09 00:29:29 -07:00
propTypes: {
params: PropTypes.object
},
handleError: debug,
handleFinish() {
debug('loading questions');
},
2015-07-09 00:29:29 -07:00
2015-07-14 23:44:21 -07:00
renderQuestions(questions) {
return questions.map(([question]) => {
return (
<Panel>
<p>{ question }</p>
</Panel>
);
});
},
render() {
2015-07-14 23:06:54 -07:00
const {
title,
2015-07-15 10:54:03 -07:00
challengeSeed = ['1']
2015-07-14 23:06:54 -07:00
} = this.props.currentHike;
const [ id ] = challengeSeed;
2015-07-09 00:29:29 -07:00
2015-07-14 23:44:21 -07:00
const videoTitle = <h2>{ title }</h2>;
return (
<Col xs={ 12 }>
<Row>
2015-07-14 23:44:21 -07:00
<Panel className={ 'text-center' } title={ videoTitle }>
<Vimeo
onError={ this.handleError }
onFinish= { this.handleFinish }
videoId={ id } />
</Panel>
</Row>
</Col>
);
}
})
);