Fix rendering specific hike from server
This commit is contained in:
@ -31,7 +31,7 @@ const fetchOptions = {
|
|||||||
fetchAction: 'fetchHikes',
|
fetchAction: 'fetchHikes',
|
||||||
|
|
||||||
isPrimed: ({ hikes }) => hikes && !!hikes.length,
|
isPrimed: ({ hikes }) => hikes && !!hikes.length,
|
||||||
getPayload: ({ params: { dashedName } }) => dashedName,
|
getActionArgs: ({ params: { dashedName } }) => [ dashedName ],
|
||||||
shouldContainerFetch(props, nextProps) {
|
shouldContainerFetch(props, nextProps) {
|
||||||
return props.params.dashedName !== nextProps.params.dashedName;
|
return props.params.dashedName !== nextProps.params.dashedName;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import types from './types';
|
|||||||
import { fetchHikesCompleted } from './actions';
|
import { fetchHikesCompleted } from './actions';
|
||||||
import { handleError } from '../../../redux/types';
|
import { handleError } from '../../../redux/types';
|
||||||
|
|
||||||
import { getCurrentHike } from './utils';
|
import { findCurrentHike } from './utils';
|
||||||
|
|
||||||
// const log = debug('fcc:fetch-hikes-saga');
|
// const log = debug('fcc:fetch-hikes-saga');
|
||||||
const hike = new Schema('hike', { idAttribute: 'dashedName' });
|
const hike = new Schema('hike', { idAttribute: 'dashedName' });
|
||||||
@ -30,7 +30,7 @@ export default ({ services }) => ({ dispatch }) => next => {
|
|||||||
results: result.hikes
|
results: result.hikes
|
||||||
};
|
};
|
||||||
|
|
||||||
const currentHike = getCurrentHike(hikes, dashedName);
|
const currentHike = findCurrentHike(hikes, dashedName);
|
||||||
|
|
||||||
return fetchHikesCompleted(hikes, currentHike);
|
return fetchHikesCompleted(hikes, currentHike);
|
||||||
})
|
})
|
||||||
|
@ -18,7 +18,7 @@ function getFirstHike(hikes) {
|
|||||||
// hikes: Hikes,
|
// hikes: Hikes,
|
||||||
// dashedName: String
|
// dashedName: String
|
||||||
// }) => String
|
// }) => String
|
||||||
export function findCurrentHike(hikes = {}, dashedName) {
|
export function findCurrentHike(hikes, dashedName) {
|
||||||
if (!dashedName) {
|
if (!dashedName) {
|
||||||
return getFirstHike(hikes) || {};
|
return getFirstHike(hikes) || {};
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ export function findCurrentHike(hikes = {}, dashedName) {
|
|||||||
})
|
})
|
||||||
.reduce((throwAway, hike) => {
|
.reduce((throwAway, hike) => {
|
||||||
return hike;
|
return hike;
|
||||||
}, {});
|
}, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCurrentHike(hikes = {}, dashedName) {
|
export function getCurrentHike(hikes = {}, dashedName) {
|
||||||
|
Reference in New Issue
Block a user