diff --git a/common/app/create-app.jsx b/common/app/create-app.jsx
index 5fd9cfd4d2..362f1ea7da 100644
--- a/common/app/create-app.jsx
+++ b/common/app/create-app.jsx
@@ -10,7 +10,6 @@ import childRoutes from './routes';
// redux
import { createEpic } from 'redux-epic';
import createReducer from './create-reducer';
-import middlewares from './middlewares';
import sagas from './sagas';
// general utils
@@ -56,7 +55,6 @@ export default function createApp({
);
const enhancers = [
applyMiddleware(
- ...middlewares,
...sideMiddlewares,
sagaMiddleware
),
diff --git a/common/app/create-reducer.js b/common/app/create-reducer.js
index a42d4f8aac..c962d6415b 100644
--- a/common/app/create-reducer.js
+++ b/common/app/create-reducer.js
@@ -9,7 +9,6 @@ import {
reducer as jobsApp,
formNormalizer as jobsNormalizer
} from './routes/Jobs/redux';
-import { reducer as map } from './routes/map/redux';
export default function createReducer(sideReducers = {}) {
return combineReducers({
@@ -19,7 +18,6 @@ export default function createReducer(sideReducers = {}) {
hikesApp,
jobsApp,
challengesApp,
- map,
form: formReducer.normalize(jobsNormalizer)
});
}
diff --git a/common/app/middlewares.js b/common/app/middlewares.js
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/common/app/redux/actions.js b/common/app/redux/actions.js
index 8c2761068b..b89a2494af 100644
--- a/common/app/redux/actions.js
+++ b/common/app/redux/actions.js
@@ -45,21 +45,3 @@ export const createErrorObserable = error => Observable.just({
type: types.handleError,
error
});
-
-// challenges
-// these need to be used by more than one route so we put them here
-export const fetchChallenge = createAction(types.fetchChallenge);
-export const fetchChallengeCompleted = createAction(
- types.fetchChallengeCompleted,
- (_, challenge) => challenge,
- entities => ({ entities })
-);
-
-export const fetchChallenges = createAction(types.fetchChallenges);
-export const fetchChallengesCompleted = createAction(
- types.fetchChallengesCompleted,
- (_, superBlocks) => superBlocks,
- entities => ({ entities })
-);
-
-export const setChallenge = createAction(types.setChallenge);
diff --git a/common/app/redux/index.js b/common/app/redux/index.js
index 9cdbc9653d..d0e8381658 100644
--- a/common/app/redux/index.js
+++ b/common/app/redux/index.js
@@ -3,5 +3,4 @@ export { default as actions } from './actions';
export { default as types } from './types';
import fetchUserSaga from './fetch-user-saga';
-import fetchChallengesSaga from './fetch-challenges-saga';
-export const sagas = [ fetchUserSaga, fetchChallengesSaga ];
+export const sagas = [ fetchUserSaga ];
diff --git a/common/app/redux/reducer.js b/common/app/redux/reducer.js
index e95901abf5..6ef681c631 100644
--- a/common/app/redux/reducer.js
+++ b/common/app/redux/reducer.js
@@ -30,12 +30,6 @@ export default handleActions(
[types.updateNavHeight]: (state, { payload: navHeight }) => ({
...state,
navHeight
- }),
-
- // challenges
- [types.fetchChallengesCompleted]: (state, { payload = [] }) => ({
- ...state,
- superBlocks: payload
})
},
{
@@ -46,7 +40,6 @@ export default handleActions(
isSignedIn: false,
csrfToken: '',
windowHeight: 0,
- navHeight: 0,
- superBlocks: []
+ navHeight: 0
}
);
diff --git a/common/app/redux/types.js b/common/app/redux/types.js
index 0bd27ba711..9860e941bc 100644
--- a/common/app/redux/types.js
+++ b/common/app/redux/types.js
@@ -18,12 +18,5 @@ export default createTypes([
// data handling
'updateChallengesData',
'updateJobsData',
- 'updateHikesData',
-
- // challenges
- 'fetchChallenge',
- 'fetchChallenges',
- 'fetchChallengeCompleted',
- 'fetchChallengesCompleted',
- 'setChallenge'
+ 'updateHikesData'
], 'app');
diff --git a/common/app/routes/challenges/components/Challenges.jsx b/common/app/routes/challenges/components/Challenges.jsx
index d4aaa384e1..c2914aaefe 100644
--- a/common/app/routes/challenges/components/Challenges.jsx
+++ b/common/app/routes/challenges/components/Challenges.jsx
@@ -7,7 +7,7 @@ import PureComponent from 'react-pure-render/component';
import Challenge from './Challenge.jsx';
import Step from './step/Step.jsx';
-import { fetchChallenge } from '../../../redux/actions';
+import { fetchChallenge } from '../redux/actions';
import { challengeSelector } from '../redux/selectors';
const bindableActions = {
diff --git a/common/app/routes/map/components/Block.jsx b/common/app/routes/challenges/components/map/Block.jsx
similarity index 100%
rename from common/app/routes/map/components/Block.jsx
rename to common/app/routes/challenges/components/map/Block.jsx
diff --git a/common/app/routes/map/components/Coding-Prep.jsx b/common/app/routes/challenges/components/map/Coding-Prep.jsx
similarity index 100%
rename from common/app/routes/map/components/Coding-Prep.jsx
rename to common/app/routes/challenges/components/map/Coding-Prep.jsx
diff --git a/common/app/routes/map/components/Full-Stack.jsx b/common/app/routes/challenges/components/map/Full-Stack.jsx
similarity index 100%
rename from common/app/routes/map/components/Full-Stack.jsx
rename to common/app/routes/challenges/components/map/Full-Stack.jsx
diff --git a/common/app/routes/map/components/Map.jsx b/common/app/routes/challenges/components/map/Map.jsx
similarity index 100%
rename from common/app/routes/map/components/Map.jsx
rename to common/app/routes/challenges/components/map/Map.jsx
diff --git a/common/app/routes/map/components/Show.jsx b/common/app/routes/challenges/components/map/Show.jsx
similarity index 85%
rename from common/app/routes/map/components/Show.jsx
rename to common/app/routes/challenges/components/map/Show.jsx
index 5fa9ec6e6f..c781bf581a 100644
--- a/common/app/routes/map/components/Show.jsx
+++ b/common/app/routes/challenges/components/map/Show.jsx
@@ -8,19 +8,20 @@ import { createSelector } from 'reselect';
import Map from './Map.jsx';
import {
clearFilter,
- updateFilter
-} from '../redux/actions';
-import { setChallenge, fetchChallenges } from '../../../redux/actions';
+ updateFilter,
+ updateCurrentChallenge,
+ fetchChallenges
+} from '../../redux/actions';
const bindableActions = {
clearFilter,
fetchChallenges,
updateFilter,
- setChallenge
+ updateCurrentChallenge
};
const superBlocksSelector = createSelector(
- state => state.app.superBlocks,
+ state => state.challengesApp.superBlocks,
state => state.entities.superBlock,
state => state.entities.block,
state => state.entities.challenge,
@@ -49,7 +50,7 @@ const superBlocksSelector = createSelector(
const mapStateToProps = createSelector(
superBlocksSelector,
- state => state.map.filter,
+ state => state.challengesApp.filter,
({ superBlocks }, filter) => {
return {
superBlocks,
@@ -61,7 +62,7 @@ const mapStateToProps = createSelector(
const fetchOptions = {
fetchAction: 'fetchChallenges',
isPrimed({ superBlocks }) {
- return Array.isArray(superBlocks) && superBlocks.length > 0;
+ return Array.isArray(superBlocks) && superBlocks.length > 1;
}
};
@@ -72,7 +73,7 @@ export class ShowMap extends PureComponent {
filter: PropTypes.string,
superBlocks: PropTypes.array,
updateFilter: PropTypes.func,
- setChallenge: PropTypes.func
+ updateCurrentChallenge: PropTypes.func
};
render() {
diff --git a/common/app/routes/map/components/Super-Block.jsx b/common/app/routes/challenges/components/map/Super-Block.jsx
similarity index 100%
rename from common/app/routes/map/components/Super-Block.jsx
rename to common/app/routes/challenges/components/map/Super-Block.jsx
diff --git a/common/app/routes/challenges/index.js b/common/app/routes/challenges/index.js
index b430bc2c90..f561670dd3 100644
--- a/common/app/routes/challenges/index.js
+++ b/common/app/routes/challenges/index.js
@@ -1,6 +1,7 @@
import Challenges from './components/Challenges.jsx';
+import ShowMap from './components/map/Show.jsx';
-export default {
+export const challenges = {
path: 'challenges(/:dashedName)',
component: Challenges,
onEnter(nextState, replace) {
@@ -10,3 +11,8 @@ export default {
}
}
};
+
+export const map = {
+ path: 'map',
+ component: ShowMap
+};
diff --git a/common/app/routes/challenges/redux/actions.js b/common/app/routes/challenges/redux/actions.js
index 20ece869b4..bf1a8793a0 100644
--- a/common/app/routes/challenges/redux/actions.js
+++ b/common/app/routes/challenges/redux/actions.js
@@ -2,5 +2,33 @@ import { createAction } from 'redux-actions';
import types from './types';
+// step
export const goToStep = createAction(types.goToStep);
-export const setChallenge = createAction(types.setChallenge);
+
+
+// challenges
+export const fetchChallenge = createAction(types.fetchChallenge);
+export const fetchChallengeCompleted = createAction(
+ types.fetchChallengeCompleted,
+ (_, challenge) => challenge,
+ entities => ({ entities })
+);
+
+export const fetchChallenges = createAction(types.fetchChallenges);
+export const fetchChallengesCompleted = createAction(
+ types.fetchChallengesCompleted,
+ (_, superBlocks) => superBlocks,
+ entities => ({ entities })
+);
+
+export const updateCurrentChallenge = createAction(
+ types.updateCurrentChallenge
+);
+
+// map
+export const updateFilter = createAction(
+ types.updateFilter,
+ e => e.target.value
+);
+
+export const clearFilter = createAction(types.clearFilter);
diff --git a/common/app/redux/fetch-challenges-saga.js b/common/app/routes/challenges/redux/fetch-challenges-saga.js
similarity index 91%
rename from common/app/redux/fetch-challenges-saga.js
rename to common/app/routes/challenges/redux/fetch-challenges-saga.js
index 0fee53a2aa..c217f20863 100644
--- a/common/app/redux/fetch-challenges-saga.js
+++ b/common/app/routes/challenges/redux/fetch-challenges-saga.js
@@ -4,7 +4,7 @@ import {
createErrorObserable,
fetchChallengeCompleted,
fetchChallengesCompleted,
- setChallenge
+ updateCurrentChallenge
} from './actions';
export default function fetchChallengesSaga(action$, getState, { services }) {
@@ -22,7 +22,7 @@ export default function fetchChallengesSaga(action$, getState, { services }) {
if (type === fetchChallenge) {
return Observable.of(
fetchChallengeCompleted(entities, result),
- setChallenge(entities.challenge[result])
+ updateCurrentChallenge(entities.challenge[result])
);
}
return Observable.just(fetchChallengesCompleted(entities, result));
diff --git a/common/app/routes/challenges/redux/index.js b/common/app/routes/challenges/redux/index.js
index 9b248336b8..79b8c842e4 100644
--- a/common/app/routes/challenges/redux/index.js
+++ b/common/app/routes/challenges/redux/index.js
@@ -1,3 +1,6 @@
export actions from './actions';
export reducer from './reducer';
export types from './types';
+
+import fetchChallengesSaga from './fetch-challenges-saga';
+export const sagas = [ fetchChallengesSaga ];
diff --git a/common/app/routes/challenges/redux/reducer.js b/common/app/routes/challenges/redux/reducer.js
index b791e9b03a..85f06e5c60 100644
--- a/common/app/routes/challenges/redux/reducer.js
+++ b/common/app/routes/challenges/redux/reducer.js
@@ -7,7 +7,9 @@ const initialState = {
challenge: '',
currentStep: 0,
previousStep: -1,
- content: null
+ filter: '',
+ content: null,
+ superBlocks: []
};
function arrayToNewLineString(seedData = []) {
@@ -21,12 +23,6 @@ function buildSeed({ challengeSeed = [] } = {}) {
export default handleActions(
{
- [types.resetStep]: () => initialState,
- [types.goToStep]: (state, { payload: step = 0 }) => ({
- ...state,
- currentStep: step,
- previousStep: state.currentStep
- }),
[fetchChallengeCompleted]: (state, { payload = '' }) => ({
...state,
challenge: payload
@@ -35,6 +31,28 @@ export default handleActions(
...state,
challenge: challenge.dashedName,
content: buildSeed(challenge)
+ }),
+
+ // map
+ [types.updateFilter]: (state, { payload = ''}) => ({
+ ...state,
+ filter: payload
+ }),
+ [types.clearFilter]: (state) => ({
+ ...state,
+ filter: ''
+ }),
+ [types.fetchChallengesCompleted]: (state, { payload = [] }) => ({
+ ...state,
+ superBlocks: payload
+ }),
+
+ // step
+ [types.resetStep]: () => initialState,
+ [types.goToStep]: (state, { payload: step = 0 }) => ({
+ ...state,
+ currentStep: step,
+ previousStep: state.currentStep
})
},
initialState
diff --git a/common/app/routes/challenges/redux/types.js b/common/app/routes/challenges/redux/types.js
index 2c95ce3180..f0fa935c83 100644
--- a/common/app/routes/challenges/redux/types.js
+++ b/common/app/routes/challenges/redux/types.js
@@ -3,5 +3,15 @@ import createTypes from '../../../utils/create-types';
export default createTypes([
// step
'goToStep',
- 'setChallenge'
+
+ // challenges
+ 'fetchChallenge',
+ 'fetchChallenges',
+ 'fetchChallengeCompleted',
+ 'fetchChallengesCompleted',
+ 'updateCurrentChallenge',
+
+ // map
+ 'updateFilter',
+ 'clearFilter'
], 'challenges');
diff --git a/common/app/routes/challenges/step/Step.jsx b/common/app/routes/challenges/step/Step.jsx
deleted file mode 100644
index 3d22bf6960..0000000000
--- a/common/app/routes/challenges/step/Step.jsx
+++ /dev/null
@@ -1,274 +0,0 @@
-import React, { PropTypes } from 'react';
-import classnames from 'classnames';
-import { connect } from 'react-redux';
-import { createSelector } from 'reselect';
-import { goToStep } from '../../redux/actions';
-import PureComponent from 'react-pure-render/component';
-import ReactTransitionReplace from 'react-css-transition-replace';
-
-import { Button, Col, Image, Row } from 'react-bootstrap';
-
-const mapStateToProps = createSelector(
- state => state.challengesApp.currentStep,
- state => state.challengesApp.previousStep,
- (currentStep, previousStep) => ({
- currentStep,
- previousStep,
- isGoingForward: currentStep > previousStep
- })
-);
-
-const dispatchActions = {
- goToStep
-};
-
-const transitionTimeout = 1000;
-/* eslint-disable max-len, quotes */
-const challenge = {
- title: "Learn how Free Code Camp Works",
- description: [
- [
- "http://i.imgur.com/6ibIavQ.jpg",
- "A picture of Free Code Camp's 4 benefits: Get connected, Learn JavaScript, Build your Portfolio, Help nonprofits",
- "Welcome to Free Code Camp. We're an open source community of busy people who learn to code and help nonprofits.",
- "http://www.foo.com"
- ],
- [
- "http://i.imgur.com/Elb3dfj.jpg",
- "A screenshot of some of our campers coding together in Toronto.",
- "