1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = createItemReducer;
|
7 |
|
8 | var _immutable = require('immutable');
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function 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 | } |
\ | No newline at end of file |