37 lines
635 B
JavaScript
Raw Normal View History

2018-02-20 11:34:15 +01:00
/**
*
* ListPage reducer
*
*/
2018-02-20 15:51:20 +01:00
import { fromJS, List, Map } from 'immutable';
2018-02-20 11:34:15 +01:00
// ListPage constants
import {
2018-02-20 14:25:45 +01:00
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,
2018-02-20 11:34:15 +01:00
params: Map({
2018-02-20 15:51:20 +01:00
limit: 10,
page: 1,
sort: 'id',
source: 'content-manager',
2018-02-20 11:34:15 +01:00
}),
2018-02-20 15:51:20 +01:00
records: List([]),
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_SUCCEEDED:
return state
2018-02-20 15:51:20 +01:00
.update('count', () => action.data[0].count)
.update('records', () => List(action.data[1]));
2018-02-20 11:34:15 +01:00
default:
return state;
}
}
export default listPageReducer;