2018-02-08 12:01:06 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* HomePage reducer
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-02-16 14:17:24 +01:00
|
|
|
import { fromJS, List } from 'immutable';
|
2018-02-08 12:01:06 +01:00
|
|
|
|
2018-02-16 14:17:24 +01:00
|
|
|
import {
|
|
|
|
DROP_SUCCESS,
|
|
|
|
ON_SEARCH,
|
|
|
|
} from './constants';
|
2018-02-08 12:01:06 +01:00
|
|
|
|
2018-02-15 17:46:57 +01:00
|
|
|
const initialState = fromJS({
|
|
|
|
search: '',
|
2018-02-16 14:17:24 +01:00
|
|
|
uploadedFiles: List([]),
|
2018-02-15 17:46:57 +01:00
|
|
|
});
|
2018-02-08 12:01:06 +01:00
|
|
|
|
|
|
|
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));
|
2018-02-15 17:46:57 +01:00
|
|
|
case ON_SEARCH:
|
|
|
|
return state.update('search', () => action.value);
|
2018-02-08 12:01:06 +01:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default homePageReducer;
|