39 lines
689 B
JavaScript
Raw Normal View History

2018-02-20 11:34:15 +01:00
/**
*
* ListPage reducer
*
*/
import { fromJS, Map } from 'immutable';
// ListPage constants
import {
2018-02-20 14:25:45 +01:00
GET_DATA,
GET_DATA_SUCCEEDED,
2018-02-20 11:34:15 +01:00
} from './constants';
const initialState = fromJS({
2018-02-20 14:25:45 +01:00
count: 0,
currentModel: '',
2018-02-20 11:34:15 +01:00
params: Map({
currentPage: 1,
}),
2018-02-20 14:25:45 +01:00
source: '',
2018-02-20 11:34:15 +01:00
});
function listPageReducer(state = initialState, action) {
switch (action.type) {
2018-02-20 14:25:45 +01:00
case GET_DATA:
return state
.update('currentModel', () => action.currentModel)
.update('source', () => action.source);
case GET_DATA_SUCCEEDED:
return state
.update('count', () => action.data[0].count);
2018-02-20 11:34:15 +01:00
default:
return state;
}
}
export default listPageReducer;