1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-11-14 02:40:05 -05:00
moneygo/js/reducers/ImportReducer.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-06-04 16:01:42 -04:00
var assign = require('object-assign');
var ImportConstants = require('../constants/ImportConstants');
var UserConstants = require('../constants/UserConstants');
const initialState = {
showModal: false,
importing: false,
uploadProgress: 0,
importFinished: false,
importFailed: false,
errorMessage: null
};
module.exports = function(state = initialState, action) {
switch (action.type) {
case ImportConstants.OPEN_IMPORT_MODAL:
return assign({}, initialState, {
showModal: true
});
case ImportConstants.CLOSE_IMPORT_MODAL:
case UserConstants.USER_LOGGEDOUT:
return initialState;
case ImportConstants.BEGIN_IMPORT:
return assign({}, state, {
importing: true
});
case ImportConstants.UPDATE_IMPORT_PROGRESS:
return assign({}, state, {
uploadProgress: action.progress
});
case ImportConstants.IMPORT_FINISHED:
return assign({}, state, {
importing: false,
uploadProgress: 100,
importFinished: true
});
case ImportConstants.IMPORT_FAILED:
return assign({}, state, {
importing: false,
importFailed: true,
errorMessage: action.error
});
default:
return state;
}
};