/* eslint-disable import/prefer-default-export */
/**
* All functions in this module are action creators and the return value should be passed to the
* redux store dispatch() function.
*
* IMPORTANT: This file contains imports that should only be bundled when doing a 'node' build.
* This action file should never be imported in the web bundle
* @module
*/
import { QUERY_VALUE_LOGOUT } from '../util/AuthenticationHelper/constants';
import { parsePaymentResponseQuery } from './paymentResponseActions';
import { parseLogoutResponseQuery, redirectMigrationLogout } from './logoutResponseActions';
/**
* This function will identify what kind of return we're getting and
* decrypts the response when necessary: payment or logout
*/
export const parseResponseQuery = (query, res, environmentConfig) => dispatch => {
if (query.result) {
return dispatch(parsePaymentResponseQuery(query, environmentConfig));
}
if (query.logoutId) {
return dispatch(parseLogoutResponseQuery(query, res, environmentConfig));
}
if (query.migration && query.migration === QUERY_VALUE_LOGOUT) {
return dispatch(redirectMigrationLogout(res, environmentConfig));
}
return Promise.resolve();
};