@shopgate/pwa-common
Version:
Common library for the Shopgate Connect PWA.
4 lines • 891 B
JavaScript
import{mutable}from'@shopgate/engage/core/helpers';import{hasSGJavaScriptBridge,defaultClientInformation,getWebStorageEntry}from'@shopgate/pwa-core';import{requestClientInformation,receiveClientInformation,errorClientInformation}from"../../action-creators/client";/**
* Requests the client information from the web storage.
* @return {Function} A redux thunk.
*/function fetchClientInformation(){return function(dispatch){dispatch(requestClientInformation());if(!hasSGJavaScriptBridge()){dispatch(receiveClientInformation(defaultClientInformation));return Promise.resolve({aga:0,value:defaultClientInformation});}var request=getWebStorageEntry({name:'clientInformation'});request.then(function(response){return dispatch(receiveClientInformation(response.value));})["catch"](function(){dispatch(errorClientInformation());});return request;};}export default mutable(fetchClientInformation);