2020-02-18 16:39:03 +01:00
|
|
|
import { fromJS } from 'immutable';
|
|
|
|
|
|
|
|
const initialState = fromJS({
|
2020-02-18 18:05:52 +01:00
|
|
|
// currentStep: 'browse',
|
|
|
|
currentStep: 'upload',
|
|
|
|
filesToUpload: [],
|
2020-02-18 16:39:03 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const reducer = (state, action) => {
|
|
|
|
switch (action.type) {
|
2020-02-18 18:05:52 +01:00
|
|
|
case 'ADD_FILES_TO_UPLOAD':
|
|
|
|
return state
|
|
|
|
.update('filesToUpload', list =>
|
|
|
|
list.concat(
|
|
|
|
Object.keys(action.filesToUpload).reduce(
|
|
|
|
(acc, current) => [...acc, action.filesToUpload[current]],
|
|
|
|
[]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.update('currentStep', () => action.nextStep);
|
|
|
|
case 'GO_TO':
|
|
|
|
return state.update('currentStep', () => action.to);
|
2020-02-18 16:39:03 +01:00
|
|
|
case 'RESET_PROPS':
|
|
|
|
return initialState;
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export default reducer;
|
|
|
|
export { initialState };
|