2018-02-19 13:10:35 +01:00

38 lines
785 B
JavaScript
Executable File

/*
*
* HomePage reducer
*
*/
import { fromJS, List, Map } from 'immutable';
import {
DROP_SUCCESS,
GET_DATA_SUCCESS,
ON_SEARCH,
} from './constants';
const initialState = fromJS({
entriesNumber: 0,
search: '',
uploadedFiles: List([Map({})]),
});
function homePageReducer(state = initialState, action) {
switch (action.type) {
case DROP_SUCCESS:
return state
.update('uploadedFiles', (list) => List(action.newFiles).concat(list));
case GET_DATA_SUCCESS:
return state
.update('uploadedFiles', () => List(action.data))
.update('entriesNumber', () => action.entriesNumber);
case ON_SEARCH:
return state.update('search', () => action.value);
default:
return state;
}
}
export default homePageReducer;