2017-06-06 23:19:12 +02:00
|
|
|
import { createSelector } from "reselect";
|
2017-08-30 14:48:32 +02:00
|
|
|
import { selectCurrentParams } from "selectors/navigation";
|
2017-04-28 17:14:44 +02:00
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export const _selectState = state => state.costInfo || {};
|
2017-04-28 17:14:44 +02:00
|
|
|
|
|
|
|
export const selectAllCostInfoByUri = createSelector(
|
|
|
|
_selectState,
|
2017-06-06 23:19:12 +02:00
|
|
|
state => state.byUri || {}
|
2017-06-06 06:21:55 +02:00
|
|
|
);
|
2017-04-28 17:14:44 +02:00
|
|
|
|
2017-05-15 05:50:59 +02:00
|
|
|
export const selectCostInfoForUri = (state, props) => {
|
2017-06-06 23:19:12 +02:00
|
|
|
return selectAllCostInfoByUri(state)[props.uri];
|
2017-06-06 06:21:55 +02:00
|
|
|
};
|
2017-04-29 19:02:25 +02:00
|
|
|
|
|
|
|
export const makeSelectCostInfoForUri = () => {
|
2017-06-06 23:19:12 +02:00
|
|
|
return createSelector(selectCostInfoForUri, costInfo => costInfo);
|
2017-06-06 06:21:55 +02:00
|
|
|
};
|
2017-05-28 17:16:07 +02:00
|
|
|
|
2017-08-22 23:19:33 +02:00
|
|
|
export const selectCostForCurrentPageUri = createSelector(
|
|
|
|
selectAllCostInfoByUri,
|
|
|
|
selectCurrentParams,
|
|
|
|
(costInfo, params) =>
|
|
|
|
params.uri && costInfo[params.uri] ? costInfo[params.uri].cost : undefined
|
|
|
|
);
|
|
|
|
|
2017-05-28 17:16:07 +02:00
|
|
|
export const selectFetchingCostInfo = createSelector(
|
|
|
|
_selectState,
|
2017-06-06 23:19:12 +02:00
|
|
|
state => state.fetching || {}
|
2017-06-06 06:21:55 +02:00
|
|
|
);
|
2017-05-28 17:16:07 +02:00
|
|
|
|
|
|
|
const selectFetchingCostInfoForUri = (state, props) => {
|
2017-06-06 23:19:12 +02:00
|
|
|
return selectFetchingCostInfo(state)[props.uri];
|
2017-06-06 06:21:55 +02:00
|
|
|
};
|
2017-05-28 17:16:07 +02:00
|
|
|
|
|
|
|
export const makeSelectFetchingCostInfoForUri = () => {
|
2017-06-06 23:19:12 +02:00
|
|
|
return createSelector(selectFetchingCostInfoForUri, fetching => !!fetching);
|
2017-06-06 06:21:55 +02:00
|
|
|
};
|