@shopgate/engage 7.22.0-beta.5 → 7.22.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -43,7 +43,5 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
43
43
|
*/},{key:"set",value:function set(key,handler){this.store.set(key,handler);return this;}/**
|
|
44
44
|
* Invokes all registered handlers
|
|
45
45
|
* @returns {Promise<{results: [], errors: []}>}
|
|
46
|
-
*/},{key:"initialize",value:function(){var _initialize=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref){var dispatch,getState,
|
|
47
|
-
|
|
48
|
-
}return res;}).filter(Boolean);results=[];errors=[];// eslint-disable-next-line no-restricted-syntax
|
|
49
|
-
_iteratorNormalCompletion=true;_didIteratorError=false;_iteratorError=undefined;_context.prev=7;_iterator=promises[Symbol.iterator]();case 9:if(_iteratorNormalCompletion=(_step=_iterator.next()).done){_context.next=25;break;}promise=_step.value;_context.prev=11;_context.t0=results;_context.next=15;return promise;case 15:_context.t1=_context.sent;_context.t0.push.call(_context.t0,_context.t1);_context.next=22;break;case 19:_context.prev=19;_context.t2=_context["catch"](11);errors.push(_context.t2);case 22:_iteratorNormalCompletion=true;_context.next=9;break;case 25:_context.next=31;break;case 27:_context.prev=27;_context.t3=_context["catch"](7);_didIteratorError=true;_iteratorError=_context.t3;case 31:_context.prev=31;_context.prev=32;if(!_iteratorNormalCompletion&&_iterator["return"]!=null){_iterator["return"]();}case 34:_context.prev=34;if(!_didIteratorError){_context.next=37;break;}throw _iteratorError;case 37:return _context.finish(34);case 38:return _context.finish(31);case 39:return _context.abrupt("return",{results:results,errors:errors});case 40:case"end":return _context.stop();}},_callee,this,[[7,27,31,39],[11,19],[32,,34,38]]);}));function initialize(_x){return _initialize.apply(this,arguments);}return initialize;}()}]);}();export default new AppInitialization();
|
|
46
|
+
*/},{key:"initialize",value:function(){var _initialize=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref){var dispatch,getState,results,errors,_i,_Array$from,handler;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch=_ref.dispatch,getState=_ref.getState;results=[];errors=[];// eslint-disable-next-line no-restricted-syntax
|
|
47
|
+
_i=0,_Array$from=Array.from(this.store.values());case 4:if(!(_i<_Array$from.length)){_context.next=20;break;}handler=_Array$from[_i];_context.prev=6;_context.t0=results;_context.next=10;return handler({dispatch:dispatch,getState:getState});case 10:_context.t1=_context.sent;_context.t0.push.call(_context.t0,_context.t1);_context.next=17;break;case 14:_context.prev=14;_context.t2=_context["catch"](6);errors.push(_context.t2);case 17:_i++;_context.next=4;break;case 20:return _context.abrupt("return",{results:results,errors:errors});case 21:case"end":return _context.stop();}},_callee,this,[[6,14]]);}));function initialize(_x){return _initialize.apply(this,arguments);}return initialize;}()}]);}();export default new AppInitialization();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{PipelineRequest}from
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{mutable}from'@shopgate/engage/core/helpers';import{PipelineRequest}from'@shopgate/engage/core/classes';import selectLocation from"../action-creators/selectLocation";import{getPreferredLocation}from"../selectors";/**
|
|
2
2
|
* Fetches the default location of the user
|
|
3
3
|
* @returns {Function} redux thunk
|
|
4
|
-
*/var fetchDefaultLocation=function fetchDefaultLocation(){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var request,_ref2,location;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:request=new PipelineRequest('shopgate.user.getDefaultLocation').dispatch();_context.next=3;return request;case 3:_ref2=_context.sent;location=_ref2.location;if(location){dispatch(selectLocation(location));}return _context.abrupt("return",request);case
|
|
4
|
+
*/var fetchDefaultLocation=function fetchDefaultLocation(){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var _getPreferredLocation;var request,_ref2,location,selectedLocationCode;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:request=new PipelineRequest('shopgate.user.getDefaultLocation').dispatch();_context.next=3;return request;case 3:_ref2=_context.sent;location=_ref2.location;selectedLocationCode=(_getPreferredLocation=getPreferredLocation(getState()))===null||_getPreferredLocation===void 0?void 0:_getPreferredLocation.code;if(selectedLocationCode!==(location===null||location===void 0?void 0:location.code)||location===null){dispatch(selectLocation(location));}return _context.abrupt("return",request);case 8:case"end":return _context.stop();}},_callee);}));return function(_x,_x2){return _ref.apply(this,arguments);};}());};export default mutable(fetchDefaultLocation);
|
|
@@ -6,9 +6,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){
|
|
|
6
6
|
*/var setLocationOnceAvailable=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(locationCode,dispatch){var _ref3,initialLocations;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;_context.next=3;return initialLocationsPromise;case 3:_ref3=_context.sent;initialLocations=_ref3.locations;if(initialLocations.some(function(l){return l.code===locationCode;})){_context.next=7;break;}return _context.abrupt("return");case 7:dispatch(selectLocation({code:locationCode}));requestAnimationFrame(function(){dispatch(setPending(false));});_context.next=13;break;case 11:_context.prev=11;_context.t0=_context["catch"](0);case 13:case"end":return _context.stop();}},_callee,null,[[0,11]]);}));return function setLocationOnceAvailable(_x,_x2){return _ref.apply(this,arguments);};}();/**
|
|
7
7
|
* Locations subscriptions.
|
|
8
8
|
* @param {Function} subscribe The subscribe function.
|
|
9
|
-
*/function locationsSubscriber(subscribe){subscribe(appWillInit$,function(){appInitialization.set('location',/*#__PURE__*/function(){var _ref5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref4){var dispatch
|
|
10
|
-
location=getPreferredLocation(getState());// if NO location has been set: get location from backend and set in redux
|
|
11
|
-
if(!(!location&&hasNewServices())){_context2.next=5;break;}_context2.next=5;return dispatch(fetchDefaultLocation());case 5:case"end":return _context2.stop();}},_callee2);}));return function(_x3){return _ref5.apply(this,arguments);};}());});subscribe(preferredLocationDidUpdate$,function(_ref6){var dispatch=_ref6.dispatch,getState=_ref6.getState;var preferredLocation=getPreferredLocation(getState());if(preferredLocation){dispatch(sendDefaultLocationCode(preferredLocation.code));}});subscribe(cookieConsentInitialized$,/*#__PURE__*/function(){var _ref8=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref7){var dispatch,getState,userSearch,_ref10,locations,preferredLocation,code,hasLocation,_ref12,preferredLocationDefault,locationToPreselect;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:dispatch=_ref7.dispatch,getState=_ref7.getState;if(hasNewServices()){_context3.next=3;break;}return _context3.abrupt("return");case 3:// Fetch merchants locations.
|
|
9
|
+
*/function locationsSubscriber(subscribe){subscribe(appWillInit$,function(){appInitialization.set('location',/*#__PURE__*/function(){var _ref5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref4){var dispatch;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:dispatch=_ref4.dispatch;if(!hasNewServices()){_context2.next=4;break;}_context2.next=4;return dispatch(fetchDefaultLocation());case 4:case"end":return _context2.stop();}},_callee2);}));return function(_x3){return _ref5.apply(this,arguments);};}());});subscribe(preferredLocationDidUpdate$,function(_ref6){var dispatch=_ref6.dispatch,getState=_ref6.getState;var preferredLocation=getPreferredLocation(getState());if(preferredLocation){dispatch(sendDefaultLocationCode(preferredLocation.code));}});subscribe(cookieConsentInitialized$,/*#__PURE__*/function(){var _ref8=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref7){var dispatch,getState,userSearch,_ref10,locations,preferredLocation,code,hasLocation,_ref12,preferredLocationDefault,locationToPreselect;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:dispatch=_ref7.dispatch,getState=_ref7.getState;if(hasNewServices()){_context3.next=3;break;}return _context3.abrupt("return");case 3:// Fetch merchants locations.
|
|
12
10
|
userSearch=getUserSearch(getState());_context3.prev=4;_context3.next=7;return dispatch(fetchLocations(userSearch));case 7:_ref10=_context3.sent;locations=_ref10.locations;preferredLocation=getPreferredLocation(getState());if(!preferredLocation){_context3.next=16;break;}code=preferredLocation.code;// Check if the preferred location is included within the fetched locations
|
|
13
11
|
hasLocation=!!locations.find(function(location){return location.code===code;});if(hasLocation){_context3.next=16;break;}_context3.next=16;return dispatch(fetchLocations({codes:[code]}));case 16:// Preset preferredLocation if configured
|
|
14
12
|
_ref12=getThemeSettings('@shopgate/engage/locations')||{},preferredLocationDefault=_ref12.preferredLocationDefault;if(preferredLocationDefault){// check if there is already a preferredLocation for the user, if not set one
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/engage",
|
|
3
|
-
"version": "7.22.0-beta.
|
|
3
|
+
"version": "7.22.0-beta.7",
|
|
4
4
|
"description": "Shopgate's ENGAGE library.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@shopgate/native-modules": "1.0.0-beta.18",
|
|
19
|
-
"@shopgate/pwa-common": "7.22.0-beta.
|
|
20
|
-
"@shopgate/pwa-common-commerce": "7.22.0-beta.
|
|
21
|
-
"@shopgate/pwa-core": "7.22.0-beta.
|
|
22
|
-
"@shopgate/pwa-ui-ios": "7.22.0-beta.
|
|
23
|
-
"@shopgate/pwa-ui-material": "7.22.0-beta.
|
|
24
|
-
"@shopgate/pwa-ui-shared": "7.22.0-beta.
|
|
19
|
+
"@shopgate/pwa-common": "7.22.0-beta.7",
|
|
20
|
+
"@shopgate/pwa-common-commerce": "7.22.0-beta.7",
|
|
21
|
+
"@shopgate/pwa-core": "7.22.0-beta.7",
|
|
22
|
+
"@shopgate/pwa-ui-ios": "7.22.0-beta.7",
|
|
23
|
+
"@shopgate/pwa-ui-material": "7.22.0-beta.7",
|
|
24
|
+
"@shopgate/pwa-ui-shared": "7.22.0-beta.7",
|
|
25
25
|
"@stripe/react-stripe-js": "^1.16.5",
|
|
26
26
|
"@stripe/stripe-js": "^1.3.1",
|
|
27
27
|
"@virtuous/conductor": "~2.5.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React,{useMemo}from'react';import PropTypes from'prop-types';import classNames from'classnames';import{Grid,I18n,Button,Modal}from'@shopgate/engage/components';import{appConfig}from'@shopgate/engage';import pushImage from"./push-opt-in.svg";import styles from"./style";import connect from"./connector";/**
|
|
1
|
+
import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import throttle from'lodash/throttle';import classNames from'classnames';import{Grid,I18n,Button,Modal}from'@shopgate/engage/components';import{appConfig}from'@shopgate/engage';import pushImage from"./push-opt-in.svg";import styles from"./style";import connect from"./connector";/**
|
|
2
2
|
* The Push opt-in modal component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX.Element}
|
|
@@ -6,4 +6,5 @@ import React,{useMemo}from'react';import PropTypes from'prop-types';import class
|
|
|
6
6
|
try{// encode SVG string to UTF-8 byte array to handle non-Latin1 characters
|
|
7
7
|
// (e.g. Unicode characters like emojis)
|
|
8
8
|
var utf8Encoder=new TextEncoder();var svgBytes=utf8Encoder.encode(modalImageSVG);// Convert the byte array to a Base64 string
|
|
9
|
-
var base64Svg=btoa(String.fromCharCode.apply(null,svgBytes));return"data:image/svg+xml;base64,".concat(base64Svg);}catch(e){return pushImage;}},[modalImageSVG,modalImageURL])
|
|
9
|
+
var base64Svg=btoa(String.fromCharCode.apply(null,svgBytes));return"data:image/svg+xml;base64,".concat(base64Svg);}catch(e){return pushImage;}},[modalImageSVG,modalImageURL]);// Button event handlers are throttled to prevent multiple clicks
|
|
10
|
+
var handleAllowPushOptIn=useCallback(throttle(allowPushOptIn,1000,{leading:true,trailing:false}),[]);var handleDenyPushOptIn=useCallback(throttle(denyPushOptIn,1000,{leading:true,trailing:false}),[]);if(!isPushOptInModalVisible){return null;}return React.createElement(Modal,{isOpened:isPushOptInModalVisible,classes:{content:styles.modalContent,layout:styles.modalLayout}},React.createElement(Grid,{className:classNames(styles.container,'push-opt-in-modal__container'),role:"alertdialog","aria-modal":true,"aria-labelledby":"pushOptInDialogTitle","aria-describedby":"pushOptInDialogMessage"},React.createElement(Grid.Item,{className:styles.item},React.createElement("img",{src:imageSRC,className:classNames(styles.image,'push-opt-in-modal__image'),alt:"","aria-hidden":"true"}),React.createElement(I18n.Text,{className:classNames(styles.title,'push-opt-in-modal__title'),string:modalTitle||'pushOptInModal.title',id:"pushOptInDialogTitle"}),React.createElement(I18n.Text,{className:classNames('push-opt-in-modal__message'),string:modalMessage||'pushOptInModal.message',id:"pushOptInDialogMessage"}),React.createElement(Button,{onClick:handleAllowPushOptIn,type:"primary",className:classNames(styles.button,'push-opt-in-modal__button-allow')},React.createElement(I18n.Text,{string:modalButtonAllow||'pushOptInModal.buttonAllow'})),React.createElement(Button,{onClick:handleDenyPushOptIn,type:"plain",className:classNames(styles.button,'push-opt-in-modal__button-deny')},React.createElement(I18n.Text,{string:modalButtonDeny||'pushOptInModal.buttonDeny',className:styles.buttonText})))));};export default connect(PushOptInModal);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React,{useMemo}from'react';import PropTypes from'prop-types';import{Grid,I18n,Button,Modal,Link,ConditionalWrapper}from'@shopgate/engage/components';import{appConfig}from'@shopgate/engage';import classNames from'classnames';import connect from"./connector";import cookieImage from"./tracking-opt-in.svg";import styles from"./style";/**
|
|
1
|
+
import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import throttle from'lodash/throttle';import{Grid,I18n,Button,Modal,Link,ConditionalWrapper}from'@shopgate/engage/components';import{appConfig}from'@shopgate/engage';import classNames from'classnames';import connect from"./connector";import cookieImage from"./tracking-opt-in.svg";import styles from"./style";/**
|
|
2
2
|
* The cookie consent modal component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX.Element}
|
|
@@ -6,4 +6,5 @@ import React,{useMemo}from'react';import PropTypes from'prop-types';import{Grid,
|
|
|
6
6
|
try{// encode SVG string to UTF-8 byte array to handle non-Latin1 characters
|
|
7
7
|
// (e.g. Unicode characters like emojis)
|
|
8
8
|
var utf8Encoder=new TextEncoder();var svgBytes=utf8Encoder.encode(modalImageSVG);// Convert the byte array to a Base64 string
|
|
9
|
-
var base64Svg=btoa(String.fromCharCode.apply(null,svgBytes));return"data:image/svg+xml;base64,".concat(base64Svg);}catch(e){return cookieImage;}},[modalImageSVG,modalImageURL])
|
|
9
|
+
var base64Svg=btoa(String.fromCharCode.apply(null,svgBytes));return"data:image/svg+xml;base64,".concat(base64Svg);}catch(e){return cookieImage;}},[modalImageSVG,modalImageURL]);// Button event handlers are throttled to prevent multiple clicks
|
|
10
|
+
var handleAcceptAllCookies=useCallback(throttle(acceptAllCookies,1000,{leading:true,trailing:false}),[]);var handleAcceptRequiredCookies=useCallback(throttle(acceptRequiredCookies,1000,{leading:true,trailing:false}),[]);var handleOpenPrivacySettings=useCallback(throttle(openPrivacySettings,1000,{leading:true,trailing:false}),[]);if(!isCookieConsentModalVisible){return null;}return React.createElement(Modal,{isOpened:isCookieConsentModalVisible,classes:{content:styles.modalContent,layout:styles.modalLayout}},React.createElement(Grid,{component:"div",className:classNames(styles.container,'cookie-consent-modal__container'),role:"alertdialog","aria-modal":true,"aria-labelledby":"cookieConsentDialogTitle","aria-describedby":"cookieConsentDialogMessage"},React.createElement(Grid.Item,{component:"div",className:styles.item},React.createElement("img",{src:imageSRC,className:classNames(styles.image,'cookie-consent-modal__image'),alt:"","aria-hidden":"true"}),React.createElement(I18n.Text,{className:classNames(styles.title,'cookie-consent-modal__title'),string:modalTitle||'cookieConsentModal.title',id:"cookieConsentDialogTitle"}),React.createElement(I18n.Text,{string:modalMessage||'cookieConsentModal.message',className:classNames('cookie-consent-modal__message'),acceptPlainTextWithPlaceholders:true,id:"cookieConsentDialogMessage"},React.createElement(I18n.Placeholder,{forKey:"privacyLink"},React.createElement(ConditionalWrapper,{condition:!!privacyPolicyLink,wrapper:function wrapper(children){return React.createElement(Link,{href:privacyPolicyLink,tag:"span"},children);}},React.createElement(I18n.Text,{string:"cookieConsentModal.privacyText",className:styles.link})))),React.createElement(Grid.Item,{component:"div",className:styles.buttonWrapper},React.createElement(Button,{onClick:handleAcceptAllCookies,type:"primary",className:classNames(styles.button,'cookie-consent-modal__button-accept-all')},React.createElement(I18n.Text,{string:modalButtonAcceptAll||'cookieConsentModal.buttonAcceptAll'})),showRequiredCookiesButton?React.createElement(Button,{onClick:handleAcceptRequiredCookies,type:"simple",className:classNames(styles.button,'cookie-consent-modal__button-accept-required')},React.createElement(I18n.Text,{string:modalButtonOnlyRequired||'cookieConsentModal.modalButtonOnlyRequired'})):null,React.createElement(Button,{onClick:handleOpenPrivacySettings,type:"simple",className:classNames(styles.button,'cookie-consent-modal__button-open-settings')},React.createElement(I18n.Text,{string:modalButtonConfigureSettings||'cookieConsentModal.buttonConfigure'}))))));};CookieConsentModal.defaultProps={privacyPolicyLink:null};export default connect(CookieConsentModal);
|