UNPKG

829 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = createItemReducer;
7
8var _immutable = require('immutable');
9
10/**
11 * @param actionTypes
12 * @param idField
13 * @returns {paginationReducer}
14 */
15function createItemReducer(actionTypes) {
16 var idField = arguments.length <= 1 || arguments[1] === undefined ? 'id' : arguments[1];
17
18
19 return function paginationReducer() {
20 var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
21 var action = arguments[1];
22
23
24 var itemId = action.data ? action.data[idField] : null;
25
26 switch (action.type) {
27
28 case actionTypes.fetchOneSuccess:
29 return itemId;
30
31 case actionTypes.fetchOneError:
32 return {};
33
34 default:
35 return state;
36 }
37 };
38} /** Created by hhj on 8/29/16. */
\No newline at end of file