2015-07-09 00:29:29 -07:00
|
|
|
import React, { PropTypes } from 'react';
|
2015-07-15 23:36:33 -07:00
|
|
|
import { Button, Col, Row, Panel } from 'react-bootstrap';
|
2015-07-15 20:50:11 -07:00
|
|
|
import { Navigation } from 'react-router';
|
|
|
|
import { contain } from 'thundercats-react';
|
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');
|
|
|
|
|
2015-07-14 21:19:37 -07:00
|
|
|
export default contain(
|
|
|
|
{
|
|
|
|
store: 'hikesStore',
|
2015-07-16 16:55:37 -07:00
|
|
|
fetchAction: 'hikesActions.fetchCurrentHike',
|
|
|
|
getPayload({ currentHike, params: { dashedName } }) {
|
2015-07-14 21:19:37 -07:00
|
|
|
const filterRegex = new RegExp(dashedName, 'i');
|
|
|
|
if (currentHike && filterRegex.test(currentHike.dashedName)) {
|
|
|
|
return {
|
|
|
|
isPrimed: true,
|
|
|
|
dashedName
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
isPrimed: false,
|
|
|
|
dashedName: dashedName
|
|
|
|
};
|
|
|
|
}
|
2015-07-09 00:29:29 -07:00
|
|
|
},
|
2015-07-14 21:19:37 -07:00
|
|
|
stampit(React, {
|
|
|
|
displayName: 'Lecture',
|
2015-07-09 00:29:29 -07:00
|
|
|
|
2015-07-14 21:19:37 -07:00
|
|
|
propTypes: {
|
2015-07-16 16:55:37 -07:00
|
|
|
currentHike: PropTypes.object,
|
|
|
|
dashedName: PropTypes.string,
|
|
|
|
params: PropTypes.object
|
2015-07-14 21:19:37 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
handleError: debug,
|
2015-07-15 20:50:11 -07:00
|
|
|
|
2015-07-14 21:19:37 -07:00
|
|
|
handleFinish() {
|
|
|
|
debug('loading questions');
|
2015-07-15 20:50:11 -07:00
|
|
|
const { dashedName } = this.props.params;
|
2015-07-15 21:00:51 -07:00
|
|
|
this.transitionTo(`/hikes/${dashedName}/questions/1`);
|
2015-07-14 23:44:21 -07:00
|
|
|
},
|
|
|
|
|
2015-07-16 09:04:57 -07:00
|
|
|
renderTranscript(transcript) {
|
|
|
|
return transcript.map((line, index) => (
|
|
|
|
<p key={ index }>{ line }</p>
|
|
|
|
)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2015-07-14 21:19:37 -07:00
|
|
|
render() {
|
2015-07-14 23:06:54 -07:00
|
|
|
const {
|
|
|
|
title,
|
2015-07-15 20:50:11 -07:00
|
|
|
challengeSeed = ['1'],
|
|
|
|
description = []
|
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>;
|
2015-07-14 21:19:37 -07:00
|
|
|
return (
|
|
|
|
<Col xs={ 12 }>
|
|
|
|
<Row>
|
2015-07-14 23:44:21 -07:00
|
|
|
<Panel className={ 'text-center' } title={ videoTitle }>
|
|
|
|
<Vimeo
|
|
|
|
onError={ this.handleError }
|
2015-07-15 20:50:11 -07:00
|
|
|
onFinish= { ::this.handleFinish }
|
2015-07-14 23:44:21 -07:00
|
|
|
videoId={ id } />
|
2015-07-14 21:19:37 -07:00
|
|
|
</Panel>
|
|
|
|
</Row>
|
2015-07-15 20:50:11 -07:00
|
|
|
<Row>
|
|
|
|
<Col xs={ 12 }>
|
|
|
|
<Panel>
|
|
|
|
<p>
|
2015-07-16 09:04:57 -07:00
|
|
|
{ this.renderTranscript(description) }
|
2015-07-15 20:50:11 -07:00
|
|
|
</p>
|
|
|
|
</Panel>
|
2015-07-15 23:36:33 -07:00
|
|
|
<Panel>
|
|
|
|
<Button
|
|
|
|
block={ true }
|
|
|
|
bsSize='large'
|
|
|
|
onClick={ ::this.handleFinish }>
|
|
|
|
Take me to the Questions
|
|
|
|
</Button>
|
|
|
|
</Panel>
|
2015-07-15 20:50:11 -07:00
|
|
|
</Col>
|
|
|
|
</Row>
|
2015-07-14 21:19:37 -07:00
|
|
|
</Col>
|
|
|
|
);
|
|
|
|
}
|
2015-07-15 20:50:11 -07:00
|
|
|
}).compose(Navigation)
|
2015-07-14 21:19:37 -07:00
|
|
|
);
|