Video question now loads

This commit is contained in:
Berkeley Martinez
2016-02-04 14:13:13 -08:00
parent 00187628a4
commit ac32912cd5
7 changed files with 28 additions and 23 deletions

View File

@ -63,7 +63,6 @@ export class FreeCodeCamp extends React.Component {
render() { render() {
const { username, points, picture } = this.props; const { username, points, picture } = this.props;
const navProps = { username, points, picture }; const navProps = { username, points, picture };
console.log('app', this.props.children);
return ( return (
<div> <div>

View File

@ -10,10 +10,12 @@ import { resetHike } from '../redux/actions';
const mapStateToProps = createSelector( const mapStateToProps = createSelector(
state => state.hikesApp.hikes.entities, state => state.hikesApp.hikes.entities,
state => state.hikesApp.currentHike, state => state.hikesApp.currentHike,
(hikes, currentHikeDashedName) => { state => state.hikesApp,
(hikes, currentHikeDashedName, { shouldShowQuestions }) => {
const currentHike = hikes[currentHikeDashedName]; const currentHike = hikes[currentHikeDashedName];
return { return {
title: currentHike.title title: currentHike ? currentHike.title : '',
shouldShowQuestions
}; };
} }
); );
@ -23,10 +25,12 @@ export class Hike extends React.Component {
static displayName = 'Hike'; static displayName = 'Hike';
static propTypes = { static propTypes = {
title: PropTypes.object, // actions
params: PropTypes.object,
resetHike: PropTypes.func, resetHike: PropTypes.func,
showQuestions: PropTypes.bool // ui
title: PropTypes.string,
params: PropTypes.object,
shouldShowQuestions: PropTypes.bool
}; };
componentWillUnmount() { componentWillUnmount() {
@ -49,7 +53,7 @@ export class Hike extends React.Component {
render() { render() {
const { const {
title, title,
showQuestions shouldShowQuestions
} = this.props; } = this.props;
return ( return (
@ -63,7 +67,7 @@ export class Hike extends React.Component {
<section <section
className={ 'text-center' } className={ 'text-center' }
title={ title }> title={ title }>
{ this.renderBody(showQuestions) } { this.renderBody(shouldShowQuestions) }
</section> </section>
</Row> </Row>
</Col> </Col>

View File

@ -5,6 +5,8 @@ import Vimeo from 'react-vimeo';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import debug from 'debug'; import debug from 'debug';
import { toggleQuestionView } from '../redux/actions';
const log = debug('fcc:hikes'); const log = debug('fcc:hikes');
const mapStateToProps = createSelector( const mapStateToProps = createSelector(
@ -29,10 +31,12 @@ export class Lecture extends React.Component {
static displayName = 'Lecture'; static displayName = 'Lecture';
static propTypes = { static propTypes = {
dashedName: PropTypes.string, // actions
description: PropTypes.array, toggleQuestionView: PropTypes.func,
// ui
id: PropTypes.string, id: PropTypes.string,
hikesActions: PropTypes.object description: PropTypes.array,
dashedName: PropTypes.string
}; };
shouldComponentUpdate(nextProps) { shouldComponentUpdate(nextProps) {
@ -42,11 +46,6 @@ export class Lecture extends React.Component {
handleError: log; handleError: log;
handleFinish(hikesActions) {
debug('loading questions');
hikesActions.toggleQuestions();
}
renderTranscript(transcript, dashedName) { renderTranscript(transcript, dashedName) {
return transcript.map((line, index) => ( return transcript.map((line, index) => (
<p <p
@ -61,8 +60,9 @@ export class Lecture extends React.Component {
const { const {
id = '1', id = '1',
description = [], description = [],
hikesActions toggleQuestionView
} = this.props; } = this.props;
const dashedName = 'foo'; const dashedName = 'foo';
return ( return (
@ -70,7 +70,7 @@ export class Lecture extends React.Component {
<Row> <Row>
<Vimeo <Vimeo
onError={ this.handleError } onError={ this.handleError }
onFinish= { () => this.handleFinish(hikesActions) } onFinish= { toggleQuestionView }
videoId={ id } /> videoId={ id } />
</Row> </Row>
<Row> <Row>
@ -81,7 +81,7 @@ export class Lecture extends React.Component {
block={ true } block={ true }
bsSize='large' bsSize='large'
bsStyle='primary' bsStyle='primary'
onClick={ () => this.handleFinish(hikesActions) }> onClick={ toggleQuestionView }>
Take me to the Questions Take me to the Questions
</Button> </Button>
</Row> </Row>
@ -90,4 +90,4 @@ export class Lecture extends React.Component {
} }
} }
export default connect(mapStateToProps)(Lecture); export default connect(mapStateToProps, { toggleQuestionView })(Lecture);

View File

@ -22,7 +22,7 @@ const actionsToBind = {
const mapStateToProps = createSelector( const mapStateToProps = createSelector(
state => state.hikesApp.hikes.entities, state => state.hikesApp.hikes.entities,
state => state.hikesApp.hikes.results, state => state.hikesApp.hikes.results,
state => state.hikesApp.ui, state => state.hikesApp,
state => state.app.isSignedIn, state => state.app.isSignedIn,
(hikesMap, hikesByDashname, ui, isSignedIn) => { (hikesMap, hikesByDashname, ui, isSignedIn) => {
const { const {

View File

@ -14,8 +14,9 @@ export const fetchHikesCompleted = createAction(
types.fetchHikesCompleted, types.fetchHikesCompleted,
(hikes, currentHike) => ({ hikes, currentHike }) (hikes, currentHike) => ({ hikes, currentHike })
); );
export const resetHike = createAction(types.resetHike);
export const toggleQuestion = createAction(types.toggleQuestion); export const toggleQuestionView = createAction(types.toggleQuestionView);
export const grabQuestions = createAction(types.grabQuestions, e => { export const grabQuestions = createAction(types.grabQuestions, e => {
let { pageX, pageY, touches } = e; let { pageX, pageY, touches } = e;

View File

@ -25,7 +25,7 @@ const initialState = {
export default handleActions( export default handleActions(
{ {
[types.toggleQuestion]: state => ({ [types.toggleQuestionView]: state => ({
...state, ...state,
shouldShowQuestions: !state.shouldShowQuestions, shouldShowQuestions: !state.shouldShowQuestions,
currentQuestion: 1 currentQuestion: 1

View File

@ -1,6 +1,7 @@
const types = [ const types = [
'fetchHikes', 'fetchHikes',
'fetchHikesCompleted', 'fetchHikesCompleted',
'resetHike',
'toggleQuestionView', 'toggleQuestionView',
'grabQuestion', 'grabQuestion',