@shopgate/engage
Version:
Shopgate's ENGAGE library.
4 lines • 853 B
JavaScript
import{PipelineRequest,EVALIDATION}from'@shopgate/engage/core';import{SHOPGATE_USER_REGISTER}from"../constants";import{requestRegistration,validationErrorsRegistration,successRegistration,errorRegistration}from"../action-creators";/**
* @param {Object} customer Customer data
* @returns {Function} A redux thunk.
*/function submitRegistration(customer){return function(dispatch){dispatch(requestRegistration(customer));var request=new PipelineRequest(SHOPGATE_USER_REGISTER).setTrusted().setErrorBlacklist([EVALIDATION]).setInput({customer:customer}).dispatch();request.then(function(response){dispatch(successRegistration(response));})["catch"](function(error){if(error.code===EVALIDATION){dispatch(validationErrorsRegistration(error.errors));}else{dispatch(errorRegistration(error,customer));}});return request;};}export default submitRegistration;