cspace-ui
Version:
CollectionSpace user interface for browsers
55 lines (54 loc) • 2.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isWindowOpenFailed = exports.isWindowOpen = exports.isSuccess = exports.isPending = exports.getUsername = exports.getLandingPath = exports.getError = exports.getAuthCodeUrl = exports.default = void 0;
var _immutable = _interopRequireDefault(require("immutable"));
var _actionCodes = require("../constants/actionCodes");
var _modalNames = require("../constants/modalNames");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (state = _immutable.default.Map(), action) => {
switch (action.type) {
case _actionCodes.AUTH_CODE_URL_CREATED:
return state.clear().set('authCodeUrl', action.payload);
case _actionCodes.LOGIN_STARTED:
return state.clear().set('isPending', true);
case _actionCodes.LOGIN_FULFILLED:
return state.clear().set('isSuccess', true).set('landingPath', action.meta.landingPath).set('username', action.meta.username);
case _actionCodes.LOGIN_REJECTED:
return state.clear().set('error', _immutable.default.Map({
code: action.payload.code,
error: action.payload.error
}));
case _actionCodes.OPEN_MODAL:
if (action.meta.name === _modalNames.MODAL_LOGIN) {
return state.clear();
}
return state;
case _actionCodes.LOGIN_WINDOW_CLOSED:
return state.set('isWindowOpen', false).set('isWindowOpenFailed', false);
case _actionCodes.LOGIN_WINDOW_OPENED:
return state.set('isWindowOpen', true).set('isWindowOpenFailed', false);
case _actionCodes.LOGIN_WINDOW_OPEN_FAILED:
return state.set('isWindowOpen', false).set('isWindowOpenFailed', true);
default:
return state;
}
};
exports.default = _default;
const isPending = state => state.get('isPending');
exports.isPending = isPending;
const isSuccess = state => state.get('isSuccess');
exports.isSuccess = isSuccess;
const getLandingPath = state => state.get('landingPath');
exports.getLandingPath = getLandingPath;
const getUsername = state => state.get('username');
exports.getUsername = getUsername;
const getError = state => state.get('error');
exports.getError = getError;
const getAuthCodeUrl = state => state.get('authCodeUrl');
exports.getAuthCodeUrl = getAuthCodeUrl;
const isWindowOpen = state => state.get('isWindowOpen');
exports.isWindowOpen = isWindowOpen;
const isWindowOpenFailed = state => state.get('isWindowOpenFailed');
exports.isWindowOpenFailed = isWindowOpenFailed;