38 lines
773 B
JavaScript
Raw Normal View History

/*
*
* HomePage reducer
*
*/
2018-02-16 14:17:24 +01:00
import { fromJS, List } from 'immutable';
2018-02-16 14:17:24 +01:00
import {
DROP_SUCCESS,
GET_DATA_SUCCESS,
2018-02-16 14:17:24 +01:00
ON_SEARCH,
} from './constants';
const initialState = fromJS({
entriesNumber: 0,
search: '',
2018-02-16 14:17:24 +01:00
uploadedFiles: List([]),
});
function homePageReducer(state = initialState, action) {
switch (action.type) {
2018-02-16 14:17:24 +01:00
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;