@shopgate/engage 6.22.0-beta.1 → 6.22.0-beta.10

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.
Files changed (165) hide show
  1. package/app-rating/action-creators/appStart.js +3 -3
  2. package/app-rating/action-creators/ordersPlaced.js +3 -3
  3. package/app-rating/action-creators/popup.js +4 -4
  4. package/app-rating/action-creators/timer.js +3 -3
  5. package/app-rating/actions/showModal.js +2 -2
  6. package/app-rating/constants/index.js +2 -2
  7. package/app-rating/reducers/index.js +2 -2
  8. package/app-rating/subscriptions/index.js +2 -2
  9. package/back-in-stock/components/BackInStockButton/index.js +2 -2
  10. package/back-in-stock/components/BackInStockButton/style.js +1 -1
  11. package/back-in-stock/components/CharacteristicsButton/index.js +1 -1
  12. package/back-in-stock/components/ProductInfoBackInStockButton/connector.js +1 -1
  13. package/back-in-stock/components/Subscriptions/components/List/index.js +2 -2
  14. package/back-in-stock/components/Subscriptions/components/Subscription/index.js +3 -3
  15. package/back-in-stock/providers/BackInStockSubscriptionsProvider.connector.js +2 -2
  16. package/back-in-stock/providers/BackInStockSubscriptionsProvider.js +2 -2
  17. package/back-in-stock/reducers/index.js +2 -2
  18. package/back-in-stock/selectors/index.js +32 -14
  19. package/back-in-stock/subscriptions/index.js +10 -2
  20. package/core/action-creators/appPermissions.js +9 -0
  21. package/core/action-creators/index.js +1 -0
  22. package/core/actions/getGeolocation.js +1 -1
  23. package/core/actions/grantCameraPermissions.js +1 -1
  24. package/core/actions/grantGeolocationPermissions.js +1 -1
  25. package/core/actions/grantPermissions.js +4 -4
  26. package/core/actions/grantPushPermissions.js +2 -2
  27. package/core/actions/index.js +1 -0
  28. package/core/actions/requestAppPermission.js +7 -0
  29. package/core/actions/requestAppPermissionStatus.js +7 -0
  30. package/core/collections/AppInitialization.js +49 -0
  31. package/core/collections/index.js +1 -0
  32. package/core/constants/actionTypes.js +1 -0
  33. package/core/constants/appFeatures.js +1 -0
  34. package/core/constants/index.js +6 -0
  35. package/core/helpers/appFeatures.js +7 -0
  36. package/core/helpers/index.js +1 -0
  37. package/core/index.js +8 -12
  38. package/core/initialization/index.js +7 -0
  39. package/core/streams/appPermissions.js +19 -0
  40. package/core/streams/index.js +1 -0
  41. package/package.json +7 -7
  42. package/product/components/Characteristics/Characteristic/components/SheetItem/index.js +3 -3
  43. package/product/components/Characteristics/Characteristic/components/SheetItem/style.js +1 -1
  44. package/push-opt-in/action-creators/index.js +1 -0
  45. package/push-opt-in/action-creators/optInTrigger.js +23 -0
  46. package/push-opt-in/action-creators/pushOptIn.js +7 -0
  47. package/push-opt-in/actions/index.js +1 -0
  48. package/push-opt-in/actions/pushOptInModal.js +8 -0
  49. package/push-opt-in/components/PushOptInModal/connector.js +9 -0
  50. package/push-opt-in/components/PushOptInModal/index.js +10 -0
  51. package/push-opt-in/components/PushOptInModal/push-opt-in.svg +62 -0
  52. package/push-opt-in/components/PushOptInModal/style.js +1 -0
  53. package/push-opt-in/components/index.js +1 -0
  54. package/push-opt-in/constants/index.js +1 -0
  55. package/push-opt-in/constants/optInModal.js +1 -0
  56. package/push-opt-in/constants/optInTrigger.js +1 -0
  57. package/push-opt-in/reducers/index.js +1 -0
  58. package/push-opt-in/reducers/optInModal.js +6 -0
  59. package/push-opt-in/reducers/optInTrigger.js +6 -0
  60. package/push-opt-in/selectors/index.js +1 -0
  61. package/push-opt-in/selectors/optInModal.js +8 -0
  62. package/push-opt-in/selectors/optInTrigger.js +5 -0
  63. package/push-opt-in/subscriptions/index.js +1 -0
  64. package/push-opt-in/subscriptions/optInTrigger.js +12 -0
  65. package/a11y/components/LiveMessage/__tests__/index.spec.js +0 -1
  66. package/a11y/components/LiveMessenger/__tests__/helpers.spec.js +0 -1
  67. package/a11y/components/LiveMessenger/__tests__/index.spec.js +0 -1
  68. package/a11y/components/Navigation/__tests__/index.spec.js +0 -1
  69. package/a11y/components/Section/__tests__/index.spec.js +0 -1
  70. package/a11y/index.spec.js +0 -1
  71. package/back-in-stock/components/Subscriptions/components/Subscription/connector.js +0 -3
  72. package/cart/index.spec.js +0 -1
  73. package/category/index.spec.js +0 -1
  74. package/checkout/index.spec.js +0 -1
  75. package/components/Footer/__tests__/Footer.spec.js +0 -8
  76. package/components/Form/Builder/Builder.spec.js +0 -19
  77. package/components/Form/Builder/classes/ActionListener.spec.js +0 -21
  78. package/components/Form/Builder/helpers/buildCountryList.spec.js +0 -1
  79. package/components/Form/Builder/helpers/buildFormDefaults.spec.js +0 -1
  80. package/components/Form/Builder/helpers/buildFormElements.spec.js +0 -3
  81. package/components/Form/Builder/helpers/buildProvinceList.spec.js +0 -1
  82. package/components/IntersectionVisibility/__tests__/index.js +0 -1
  83. package/components/View/__mocks__/context.js +0 -1
  84. package/components/View/__mocks__/index.js +0 -5
  85. package/components/View/__tests__/index.spec.js +0 -1
  86. package/components/View/__tests__/provider.spec.js +0 -1
  87. package/components/View/components/Above/__tests__/index.spec.js +0 -1
  88. package/components/View/components/Below/__tests__/index.spec.js +0 -1
  89. package/components/View/components/Content/__tests__/index.spec.js +0 -2
  90. package/components/__mocks__/index.js +0 -4
  91. package/components/index.spec.js +0 -1
  92. package/core/actions/__tests__/getGeolocation.spec.js +0 -2
  93. package/core/actions/__tests__/grantCameraPermissions.spec.js +0 -1
  94. package/core/actions/__tests__/grantGeolocationPermissions.spec.js +0 -1
  95. package/core/actions/__tests__/grantPermissions.spec.js +0 -9
  96. package/core/actions/__tests__/updateStatusBarBackground.spec.js +0 -1
  97. package/core/classes/__tests__/GeolocationRequest.spec.js +0 -5
  98. package/core/config/__tests__/getPageConfig.spec.js +0 -1
  99. package/core/config/__tests__/getPageSettings.spec.js +0 -2
  100. package/core/config/__tests__/getThemeAssets.spec.js +0 -1
  101. package/core/config/__tests__/getThemeColors.spec.js +0 -1
  102. package/core/config/__tests__/getThemeConfig.spec.js +0 -2
  103. package/core/config/__tests__/getThemeSettings.spec.js +0 -1
  104. package/core/config/__tests__/getThemeStyles.spec.js +0 -1
  105. package/core/config/__tests__/getWidgetConfig.spec.js +0 -1
  106. package/core/config/__tests__/getWidgetSettings.spec.js +0 -3
  107. package/core/helpers/__mocks__/i18n.js +0 -1
  108. package/core/helpers/__tests__/i18n.spec.js +0 -1
  109. package/core/helpers/__tests__/updateLegacyNavigationBar.spec.js +0 -1
  110. package/core/hocs/__mocks__/withWidgetSettings.js +0 -5
  111. package/core/hocs/__tests__/withApp.spec.js +0 -2
  112. package/core/hocs/__tests__/withCurrentProduct.spec.js +0 -2
  113. package/core/hocs/__tests__/withForwardedRef.spec.js +0 -1
  114. package/core/hocs/__tests__/withNavigation.spec.js +0 -2
  115. package/core/hocs/__tests__/withRoute.spec.js +0 -2
  116. package/core/hocs/__tests__/withTheme.spec.js +0 -2
  117. package/core/hocs/__tests__/withWidgetSettings.spec.js +0 -2
  118. package/core/hocs/__tests__/withWidgetStyles.spec.js +0 -2
  119. package/core/hooks/__tests__/useApp.spec.js +0 -1
  120. package/core/hooks/__tests__/useNavigation.spec.js +0 -1
  121. package/core/hooks/__tests__/usePageConfig.spec.js +0 -1
  122. package/core/hooks/__tests__/usePageSettings.spec.js +0 -1
  123. package/core/hooks/__tests__/useTheme.spec.js +0 -1
  124. package/core/hooks/__tests__/useWidgetConfig.spec.js +0 -1
  125. package/core/hooks/__tests__/useWidgetSettings.spec.js +0 -1
  126. package/core/hooks/__tests__/useWidgetStyles.spec.js +0 -1
  127. package/core/index.spec.js +0 -1
  128. package/core/providers/__tests__/AppProvider.spec.js +0 -2
  129. package/core/router/__tests__/helpers.spec.js +0 -1
  130. package/favorites/index.spec.js +0 -1
  131. package/filter/helpers/__tests__/buildUpdatedFilters.spec.js +0 -1
  132. package/filter/index.spec.js +0 -1
  133. package/index.spec.js +0 -1
  134. package/market/index.spec.js +0 -1
  135. package/orders/index.spec.js +0 -1
  136. package/page/index.spec.js +0 -1
  137. package/product/components/Description/__tests__/Description.spec.js +0 -1
  138. package/product/components/Media/helpers.spec.js +0 -3
  139. package/product/components/ProductCharacteristics/helpers/index.spec.js +0 -12
  140. package/product/components/ProductGridPrice/index.spec.js +0 -1
  141. package/product/components/ProductProperties/__tests__/Content.spec.js +0 -1
  142. package/product/components/ProductProperties/__tests__/Group.spec.js +0 -1
  143. package/product/components/ProductProperties/__tests__/GroupedProperties.spec.js +0 -1
  144. package/product/components/ProductProperties/__tests__/Lists.spec.js +0 -1
  145. package/product/components/ProductProperties/__tests__/ProductProperties.spec.js +0 -1
  146. package/product/components/ProductProperties/__tests__/Row.spec.js +0 -1
  147. package/product/components/ProductProperties/__tests__/Rows.spec.js +0 -1
  148. package/product/components/ProductProperties/__tests__/helpers/getGroupsFromProperties.spec.js +0 -1
  149. package/product/components/ProductProperties/__tests__/helpers/getSubgroupsFromProperties.spec.js +0 -1
  150. package/product/components/QuantityPicker/helpers.spec.js +0 -1
  151. package/product/components/__mocks__/context.js +0 -1
  152. package/product/hocs/withMapPricing.spec.js +0 -4
  153. package/product/hocs/withPriceCalculation.spec.js +0 -1
  154. package/product/index.spec.js +0 -1
  155. package/product/selectors/__tests__/media.spec.js +0 -1
  156. package/product/selectors/__tests__/price.spec.js +0 -1
  157. package/product/selectors/__tests__/product.spec.js +0 -2
  158. package/product/selectors/__tests__/relations.spec.js +0 -1
  159. package/product/selectors/__tests__/variants.spec.js +0 -1
  160. package/product/selectors/mocks/productProperties.mock.js +0 -1
  161. package/reviews/index.spec.js +0 -1
  162. package/scanner/index.spec.js +0 -1
  163. package/search/index.spec.js +0 -1
  164. package/user/index.spec.js +0 -1
  165. package/user/selectors/__tests__/login.spec.js +0 -1
@@ -1,7 +1,7 @@
1
- import{RESET_APP_START_COUNT,INCREASE_APP_START_COUNT}from"../constants";/**
1
+ import{APP_RATING_RESET_APP_START_COUNT,APP_RATING_INCREASE_APP_START_COUNT}from"../constants";/**
2
2
  * Increment the app start count
3
3
  * @return {Object} The dispatched action object.
4
- */export var increaseAppStartCount=function increaseAppStartCount(){return{type:INCREASE_APP_START_COUNT};};/**
4
+ */export var increaseAppStartCount=function increaseAppStartCount(){return{type:APP_RATING_INCREASE_APP_START_COUNT};};/**
5
5
  * Reset the app start count, and increment reset counts
6
6
  * @return {Object} The dispatched action object.
7
- */export var resetAppStartCount=function resetAppStartCount(){return{type:RESET_APP_START_COUNT};};
7
+ */export var resetAppStartCount=function resetAppStartCount(){return{type:APP_RATING_RESET_APP_START_COUNT};};
@@ -1,7 +1,7 @@
1
- import{RESET_ORDERS_PLACED_COUNT,INCREASE_ORDERS_PLACED_COUNT}from"../constants";/**
1
+ import{APP_RATING_RESET_ORDERS_PLACED_COUNT,APP_RATING_INCREASE_ORDERS_PLACED_COUNT}from"../constants";/**
2
2
  * Increment the orders placed count
3
3
  * @return {Object} The dispatched action object.
4
- */export var increaseOrdersPlacedCount=function increaseOrdersPlacedCount(){return{type:INCREASE_ORDERS_PLACED_COUNT};};/**
4
+ */export var increaseOrdersPlacedCount=function increaseOrdersPlacedCount(){return{type:APP_RATING_INCREASE_ORDERS_PLACED_COUNT};};/**
5
5
  * Reset the orders placed count, and increment reset counts
6
6
  * @return {Object} The dispatched action object.
7
- */export var resetOrdersPlacedCount=function resetOrdersPlacedCount(){return{type:RESET_ORDERS_PLACED_COUNT};};
7
+ */export var resetOrdersPlacedCount=function resetOrdersPlacedCount(){return{type:APP_RATING_RESET_ORDERS_PLACED_COUNT};};
@@ -1,11 +1,11 @@
1
- import{INCREASE_REJECTION_COUNT,SET_ALREADY_RATED,SET_LAST_POPUP_TIMESTAMP}from"../constants";/**
1
+ import{APP_RATING_INCREASE_REJECTION_COUNT,APP_RATING_SET_ALREADY_RATED,APP_RATING_SET_LAST_POPUP_TIMESTAMP}from"../constants";/**
2
2
  * Sets the last popup timestamp
3
3
  * @return {Object} The dispatched action object.
4
- */export var setLastPopupTimestamp=function setLastPopupTimestamp(){return{type:SET_LAST_POPUP_TIMESTAMP};};/**
4
+ */export var setLastPopupTimestamp=function setLastPopupTimestamp(){return{type:APP_RATING_SET_LAST_POPUP_TIMESTAMP};};/**
5
5
  * Sets the last popup timestamp
6
6
  * @return {Object} The dispatched action object.
7
- */export var increaseRejectionCount=function increaseRejectionCount(){return{type:INCREASE_REJECTION_COUNT};};/**
7
+ */export var increaseRejectionCount=function increaseRejectionCount(){return{type:APP_RATING_INCREASE_REJECTION_COUNT};};/**
8
8
  * Sets the last popup timestamp
9
9
  * @param {boolean} to the value to set the rated status
10
10
  * @return {Object} The dispatched action object.
11
- */export var setAlreadyRated=function setAlreadyRated(to){return{type:SET_ALREADY_RATED,to:to};};
11
+ */export var setAlreadyRated=function setAlreadyRated(to){return{type:APP_RATING_SET_ALREADY_RATED,to:to};};
@@ -1,7 +1,7 @@
1
- import{SET_TIMER_START_TIME,INCREASE_TIMER_REPEATS}from"../constants";/**
1
+ import{APP_RATING_SET_TIMER_START_TIME,APP_RATING_INCREASE_TIMER_REPEATS}from"../constants";/**
2
2
  * Reset the orders placed count, and increment reset counts
3
3
  * @return {Object} The dispatched action object.
4
- */export var resetTimerState=function resetTimerState(){return{type:INCREASE_TIMER_REPEATS};};/**
4
+ */export var resetTimerState=function resetTimerState(){return{type:APP_RATING_INCREASE_TIMER_REPEATS};};/**
5
5
  * Sets the timer start time
6
6
  * @return {Object} The dispatched action object.
7
- */export var setTimerStartTime=function setTimerStartTime(){return{type:SET_TIMER_START_TIME};};
7
+ */export var setTimerStartTime=function setTimerStartTime(){return{type:APP_RATING_SET_TIMER_START_TIME};};
@@ -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);});};}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import showModalAction from'@shopgate/pwa-common/actions/modal/showModal';import{getPlatform}from'@shopgate/pwa-common/selectors/client';import{historyPush}from'@shopgate/pwa-common/actions/router';import appConfig from'@shopgate/pwa-common/helpers/config';import{track}from'@shopgate/pwa-tracking/helpers';import{increaseRejectionCount,setAlreadyRated,setLastPopupTimestamp}from"../action-creators/popup";import{generateReviewLink}from"../helpers";import{TIMER_TIMESPAN}from"../constants";import{getAppRatingState}from"../selectors/appRating";var _appConfig$appRating=appConfig.appRating,bundleId=_appConfig$appRating.bundleId,minDaysBetweenPopups=_appConfig$appRating.minDaysBetweenPopups,askForFeedback=_appConfig$appRating.askForFeedback,feedbackLink=_appConfig$appRating.feedbackLink;/**
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);});};}function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import showModalAction from'@shopgate/pwa-common/actions/modal/showModal';import{getPlatform}from'@shopgate/pwa-common/selectors/client';import{historyPush}from'@shopgate/pwa-common/actions/router';import appConfig from'@shopgate/pwa-common/helpers/config';import{track}from'@shopgate/pwa-tracking/helpers';import{increaseRejectionCount,setAlreadyRated,setLastPopupTimestamp}from"../action-creators/popup";import{generateReviewLink}from"../helpers";import{APP_RATING_TIMER_TIMESPAN}from"../constants";import{getAppRatingState}from"../selectors/appRating";var _appConfig$appRating=appConfig.appRating,bundleId=_appConfig$appRating.bundleId,minDaysBetweenPopups=_appConfig$appRating.minDaysBetweenPopups,askForFeedback=_appConfig$appRating.askForFeedback,feedbackLink=_appConfig$appRating.feedbackLink;/**
2
2
  * to handle the modal confirmation
3
3
  * @param {string} url the url to redirect to
4
4
  * @param {boolean | null} setRated the url to redirect to
@@ -11,7 +11,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
11
11
  * @param {boolean} hasRepeats if the counters has repeats
12
12
  * @return {(function(*, *): void)|*}
13
13
  */export function showModal(resetAction,increaseAction,mustShow,hasRepeats){return/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var state,platform,reviewLink,appRatingState,isMinDaysBetweenPopupsElapsed,firstModalConfirmed,userGivesFeedback;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:state=getState();platform=getPlatform(state);reviewLink=generateReviewLink(bundleId[platform],platform);// no review link for current platform found -> don't show modal
14
- if(reviewLink){_context.next=5;break;}return _context.abrupt("return");case 5:if(!mustShow&&hasRepeats&&increaseAction){dispatch(increaseAction());}if(mustShow&&hasRepeats){_context.next=8;break;}return _context.abrupt("return");case 8:appRatingState=getAppRatingState(state);isMinDaysBetweenPopupsElapsed=Date.now()-appRatingState.lastPopupAt>=minDaysBetweenPopups*TIMER_TIMESPAN;if(isMinDaysBetweenPopupsElapsed){_context.next=12;break;}return _context.abrupt("return");case 12:dispatch(resetAction());dispatch(setLastPopupTimestamp());_context.next=16;return dispatch(showModalAction({confirm:'appRating.yes',dismiss:'appRating.no',title:'appRating.title',message:'appRating.message'}));case 16:firstModalConfirmed=_context.sent;track('customEvent',{eventCategory:'appReviewPrompt',eventAction:'decision',eventLabel:firstModalConfirmed?'yes':'no'},state);// user touched yes and we
14
+ if(reviewLink){_context.next=5;break;}return _context.abrupt("return");case 5:if(!mustShow&&hasRepeats&&increaseAction){dispatch(increaseAction());}if(mustShow&&hasRepeats){_context.next=8;break;}return _context.abrupt("return");case 8:appRatingState=getAppRatingState(state);isMinDaysBetweenPopupsElapsed=Date.now()-appRatingState.lastPopupAt>=minDaysBetweenPopups*APP_RATING_TIMER_TIMESPAN;if(isMinDaysBetweenPopupsElapsed){_context.next=12;break;}return _context.abrupt("return");case 12:dispatch(resetAction());dispatch(setLastPopupTimestamp());_context.next=16;return dispatch(showModalAction({confirm:'appRating.yes',dismiss:'appRating.no',title:'appRating.title',message:'appRating.message'}));case 16:firstModalConfirmed=_context.sent;track('customEvent',{eventCategory:'appReviewPrompt',eventAction:'decision',eventLabel:firstModalConfirmed?'yes':'no'},state);// user touched yes and we
15
15
  // redirect to store
16
16
  if(!firstModalConfirmed){_context.next=21;break;}dispatch(redirectTo(reviewLink,true));return _context.abrupt("return");case 21:// user doesn't want to rate
17
17
  dispatch(increaseRejectionCount());// we approve for rejection
@@ -1,2 +1,2 @@
1
- export var INCREASE_APP_START_COUNT='INCREASE_APP_START_COUNT';export var RESET_APP_START_COUNT='RESET_APP_START_COUNT';export var RESET_APP_START_STATE='RESET_APP_START_STATE';export var INCREASE_ORDERS_PLACED_COUNT='INCREASE_ORDERS_PLACED_COUNT';export var RESET_ORDERS_PLACED_COUNT='RESET_ORDERS_PLACED_COUNT';export var RESET_ORDERS_PLACED_STATE='RESET_ORDERS_PLACED_STATE';export var INCREASE_TIMER_REPEATS='INCREASE_TIMER_REPEATS';export var SET_TIMER_START_TIME='SET_TIMER_START_TIME';export var SET_LAST_POPUP_TIMESTAMP='SET_LAST_POPUP_TIMESTAMP';export var INCREASE_REJECTION_COUNT='INCREASE_REJECTION_COUNT';export var SET_ALREADY_RATED='SET_ALREADY_RATED';// currently the timespan is set to a day
2
- export var TIMER_TIMESPAN=1000*60*60*24;
1
+ export var APP_RATING_INCREASE_APP_START_COUNT='APP_RATING_INCREASE_APP_START_COUNT';export var APP_RATING_RESET_APP_START_COUNT='APP_RATING_RESET_APP_START_COUNT';export var APP_RATING_RESET_APP_START_STATE='APP_RATING_RESET_APP_START_STATE';export var APP_RATING_INCREASE_ORDERS_PLACED_COUNT='APP_RATING_INCREASE_ORDERS_PLACED_COUNT';export var APP_RATING_RESET_ORDERS_PLACED_COUNT='APP_RATING_RESET_ORDERS_PLACED_COUNT';export var APP_RATING_RESET_ORDERS_PLACED_STATE='APP_RATING_RESET_ORDERS_PLACED_STATE';export var APP_RATING_INCREASE_TIMER_REPEATS='APP_RATING_INCREASE_TIMER_REPEATS';export var APP_RATING_SET_TIMER_START_TIME='APP_RATING_SET_TIMER_START_TIME';export var APP_RATING_SET_LAST_POPUP_TIMESTAMP='APP_RATING_SET_LAST_POPUP_TIMESTAMP';export var APP_RATING_INCREASE_REJECTION_COUNT='APP_RATING_INCREASE_REJECTION_COUNT';export var APP_RATING_SET_ALREADY_RATED='APP_RATING_SET_ALREADY_RATED';// currently the timespan is set to a day
2
+ export var APP_RATING_TIMER_TIMESPAN=1000*60*60*24;
@@ -1,6 +1,6 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{INCREASE_APP_START_COUNT,RESET_APP_START_STATE,RESET_APP_START_COUNT,INCREASE_ORDERS_PLACED_COUNT,RESET_ORDERS_PLACED_COUNT,RESET_ORDERS_PLACED_STATE,INCREASE_TIMER_REPEATS,SET_TIMER_START_TIME,SET_LAST_POPUP_TIMESTAMP,INCREASE_REJECTION_COUNT,SET_ALREADY_RATED}from"../constants";var defaultState={appStartCount:0,appStartResetCount:0,ordersPlacedCount:0,ordersPlacedResetCount:0,timerRepeatsCount:0,timerStartTimestamp:null,lastPopupAt:null,rejectionCount:0,alreadyRated:false};/**
1
+ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{APP_RATING_INCREASE_APP_START_COUNT,APP_RATING_RESET_APP_START_STATE,APP_RATING_RESET_APP_START_COUNT,APP_RATING_INCREASE_ORDERS_PLACED_COUNT,APP_RATING_RESET_ORDERS_PLACED_COUNT,APP_RATING_RESET_ORDERS_PLACED_STATE,APP_RATING_INCREASE_TIMER_REPEATS,APP_RATING_SET_TIMER_START_TIME,APP_RATING_SET_LAST_POPUP_TIMESTAMP,APP_RATING_INCREASE_REJECTION_COUNT,APP_RATING_SET_ALREADY_RATED}from"../constants";var defaultState={appStartCount:0,appStartResetCount:0,ordersPlacedCount:0,ordersPlacedResetCount:0,timerRepeatsCount:0,timerStartTimestamp:null,lastPopupAt:null,rejectionCount:0,alreadyRated:false};/**
2
2
  * Stores all the app rating states.
3
3
  * @param {Object} [state] The current state.
4
4
  * @param {Object} action The action object.
5
5
  * @return {Object} The new state.
6
- */export default(function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case INCREASE_APP_START_COUNT:{return _extends({},state,{appStartCount:state.appStartCount+1});}case RESET_APP_START_COUNT:{return _extends({},state,{appStartCount:0,appStartResetCount:state.appStartResetCount+1});}case RESET_APP_START_STATE:{return _extends({},state,{appStartCount:0,appStartResetCount:0});}case INCREASE_ORDERS_PLACED_COUNT:{return _extends({},state,{ordersPlacedCount:state.ordersPlacedCount+1});}case RESET_ORDERS_PLACED_COUNT:{return _extends({},state,{ordersPlacedCount:0,ordersPlacedResetCount:state.ordersPlacedResetCount+1});}case RESET_ORDERS_PLACED_STATE:{return _extends({},state,{ordersPlacedCount:0,ordersPlacedResetCount:0});}case INCREASE_TIMER_REPEATS:{return _extends({},state,{timerRepeatsCount:state.timerRepeatsCount+1});}case SET_TIMER_START_TIME:{return _extends({},state,{timerStartTimestamp:Date.now()});}case SET_LAST_POPUP_TIMESTAMP:{return _extends({},state,{lastPopupAt:Date.now()});}case INCREASE_REJECTION_COUNT:{return _extends({},state,{rejectionCount:state.rejectionCount+1});}case SET_ALREADY_RATED:{return _extends({},state,{alreadyRated:action.to});}default:return state;}});
6
+ */export default(function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:defaultState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case APP_RATING_INCREASE_APP_START_COUNT:{return _extends({},state,{appStartCount:state.appStartCount+1});}case APP_RATING_RESET_APP_START_COUNT:{return _extends({},state,{appStartCount:0,appStartResetCount:state.appStartResetCount+1});}case APP_RATING_RESET_APP_START_STATE:{return _extends({},state,{appStartCount:0,appStartResetCount:0});}case APP_RATING_INCREASE_ORDERS_PLACED_COUNT:{return _extends({},state,{ordersPlacedCount:state.ordersPlacedCount+1});}case APP_RATING_RESET_ORDERS_PLACED_COUNT:{return _extends({},state,{ordersPlacedCount:0,ordersPlacedResetCount:state.ordersPlacedResetCount+1});}case APP_RATING_RESET_ORDERS_PLACED_STATE:{return _extends({},state,{ordersPlacedCount:0,ordersPlacedResetCount:0});}case APP_RATING_INCREASE_TIMER_REPEATS:{return _extends({},state,{timerRepeatsCount:state.timerRepeatsCount+1});}case APP_RATING_SET_TIMER_START_TIME:{return _extends({},state,{timerStartTimestamp:Date.now()});}case APP_RATING_SET_LAST_POPUP_TIMESTAMP:{return _extends({},state,{lastPopupAt:Date.now()});}case APP_RATING_INCREASE_REJECTION_COUNT:{return _extends({},state,{rejectionCount:state.rejectionCount+1});}case APP_RATING_SET_ALREADY_RATED:{return _extends({},state,{alreadyRated:action.to});}default:return state;}});
@@ -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 appConfig from'@shopgate/pwa-common/helpers/config';import{appDidStart$}from'@shopgate/pwa-common/streams/app';import event from'@shopgate/pwa-core/classes/Event';import{increaseAppStartCount,resetAppStartCount}from"../action-creators/appStart";import{increaseOrdersPlacedCount,resetOrdersPlacedCount}from"../action-creators/ordersPlaced";import{resetTimerState,setTimerStartTime}from"../action-creators/timer";import{TIMER_TIMESPAN}from"../constants";import{getAppRatingState}from"../selectors/appRating";import{showModal}from"../actions/showModal";/**
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 appConfig from'@shopgate/pwa-common/helpers/config';import{appDidStart$}from'@shopgate/pwa-common/streams/app';import event from'@shopgate/pwa-core/classes/Event';import{increaseAppStartCount,resetAppStartCount}from"../action-creators/appStart";import{increaseOrdersPlacedCount,resetOrdersPlacedCount}from"../action-creators/ordersPlaced";import{resetTimerState,setTimerStartTime}from"../action-creators/timer";import{APP_RATING_TIMER_TIMESPAN}from"../constants";import{getAppRatingState}from"../selectors/appRating";import{showModal}from"../actions/showModal";/**
2
2
  * App rating subscriptions
3
3
  * @param {Function} subscribe The subscribe function
4
4
  */export default function appRating(subscribe){var _appConfig$appRating=appConfig.appRating,appStarts=_appConfig$appRating.appStarts,ordersPlaced=_appConfig$appRating.ordersPlaced,timeInterval=_appConfig$appRating.timeInterval,rejectionMaxCount=_appConfig$appRating.rejectionMaxCount,bundleId=_appConfig$appRating.bundleId;// even subscriber to handle app start ratings
@@ -9,7 +9,7 @@ dispatch(increaseAppStartCount());state=getAppRatingState(getState());// if the
9
9
  // we'll cancel the operations as we
10
10
  // don't have to show the modal once more
11
11
  if(!state.alreadyRated){_context.next=7;break;}return _context.abrupt("return");case 7:if(!(state.rejectionCount>=rejectionMaxCount)){_context.next=9;break;}return _context.abrupt("return");case 9:// initiate the first start time
12
- if(state.timerStartTimestamp===null){dispatch(setTimerStartTime());}mustShowModal=false;hasRepeats=false;resetAction=null;increaseAction=null;if(timeInterval&&Number(timeInterval.value)>0&&Number(state.timerStartTimestamp)>0&&Date.now()-state.timerStartTimestamp>=timeInterval.value*TIMER_TIMESPAN){mustShowModal=true;hasRepeats=timeInterval.repeats===null||state.timerRepeatsCount<=timeInterval.repeats;resetAction=resetTimerState;// since the time is elapsed
12
+ if(state.timerStartTimestamp===null){dispatch(setTimerStartTime());}mustShowModal=false;hasRepeats=false;resetAction=null;increaseAction=null;if(timeInterval&&Number(timeInterval.value)>0&&Number(state.timerStartTimestamp)>0&&Date.now()-state.timerStartTimestamp>=timeInterval.value*APP_RATING_TIMER_TIMESPAN){mustShowModal=true;hasRepeats=timeInterval.repeats===null||state.timerRepeatsCount<=timeInterval.repeats;resetAction=resetTimerState;// since the time is elapsed
13
13
  // we reset the starting time
14
14
  increaseAction=setTimerStartTime;}else if(appStarts){mustShowModal=Number(appStarts.value)>0&&state.appStartCount>=appStarts.value;hasRepeats=appStarts.repeats===null||state.appStartResetCount<=appStarts.repeats;resetAction=resetAppStartCount;increaseAction=null;}// the actual show modal logic
15
15
  dispatch(showModal(resetAction,increaseAction,mustShowModal,hasRepeats));case 16:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}());// event subscriber to handle order placed ratings
@@ -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 React,{useCallback}from'react';import PropTypes from'prop-types';import{themeConfig}from'@shopgate/engage';import{Link,CheckedIcon,NotificationIcon}from'@shopgate/engage/components';import{BACK_IN_STOCK_PATTERN}from'@shopgate/engage/back-in-stock/constants';import{i18n}from'@shopgate/engage/core';import styles from"./style";import connect from"./connector";var colors=themeConfig.colors;/**
1
+ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}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 React,{useCallback}from'react';import PropTypes from'prop-types';import classNames from'classnames';import{themeConfig}from'@shopgate/engage';import{Link,CheckedIcon,NotificationIcon}from'@shopgate/engage/components';import{BACK_IN_STOCK_PATTERN}from'@shopgate/engage/back-in-stock/constants';import{i18n}from'@shopgate/engage/core';import styles from"./style";import connect from"./connector";var colors=themeConfig.colors;/**
2
2
  * This component renders a button to subscribe a product or a hint
3
3
  * that the product is already subscribed
4
4
  * @param {Object} props The component props
@@ -10,4 +10,4 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
10
10
  * @param {Function} props.addBackInStockSubscription Add product to back in stock list
11
11
  * @param {Function} props.grantPushPermissions Request / Set push permission
12
12
  * @return {JSX}
13
- */var BackInStockButton=function BackInStockButton(_ref){var productId=_ref.productId,_ref$isLinkToBackInSt=_ref.isLinkToBackInStockEnabled,isLinkToBackInStockEnabled=_ref$isLinkToBackInSt===void 0?false:_ref$isLinkToBackInSt,subscription=_ref.subscription,_ref$stopPropagation=_ref.stopPropagation,stopPropagation=_ref$stopPropagation===void 0?false:_ref$stopPropagation,addBackInStockSubscription=_ref.addBackInStockSubscription,grantPushPermissions=_ref.grantPushPermissions;var handleClick=useCallback(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event){var allowed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(stopPropagation){event.stopPropagation();}_context.next=3;return grantPushPermissions({rationaleModal:{message:'permissions.back_in_stock_push_notifications.message',confirm:'permissions.back_in_stock_push_notifications.confirm',dismiss:'permissions.back_in_stock_push_notifications.dismiss'}});case 3:allowed=_context.sent;if(allowed){addBackInStockSubscription({productId:productId});}case 5:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}(),[addBackInStockSubscription,grantPushPermissions,productId,stopPropagation]);if((subscription===null||subscription===void 0?void 0:subscription.status)==='active'){return/*#__PURE__*/React.createElement(Link,{href:BACK_IN_STOCK_PATTERN,disabled:!isLinkToBackInStockEnabled,className:styles.backInStockMessageContainer,tag:"span"},/*#__PURE__*/React.createElement(CheckedIcon,{color:colors.success,className:styles.icon}),/*#__PURE__*/React.createElement("span",{className:styles.backInStockMessage},i18n.text('back_in_stock.we_will_remind_you')));}return/*#__PURE__*/React.createElement("div",null,/*#__PURE__*/React.createElement("a",{role:"button",onClick:handleClick,className:styles.button},/*#__PURE__*/React.createElement("div",{className:styles.buttonContent},/*#__PURE__*/React.createElement(NotificationIcon,{color:colors.primary}),/*#__PURE__*/React.createElement("span",{className:styles.buttonText},i18n.text('back_in_stock.get_notified')))));};BackInStockButton.defaultProps={stopPropagation:false,isLinkToBackInStockEnabled:false,subscription:null,productId:null};export default connect(BackInStockButton);
13
+ */var BackInStockButton=function BackInStockButton(_ref){var productId=_ref.productId,_ref$isLinkToBackInSt=_ref.isLinkToBackInStockEnabled,isLinkToBackInStockEnabled=_ref$isLinkToBackInSt===void 0?false:_ref$isLinkToBackInSt,subscription=_ref.subscription,_ref$stopPropagation=_ref.stopPropagation,stopPropagation=_ref$stopPropagation===void 0?false:_ref$stopPropagation,addBackInStockSubscription=_ref.addBackInStockSubscription,grantPushPermissions=_ref.grantPushPermissions,alignRight=_ref.alignRight;var handleClick=useCallback(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event){var allowed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(stopPropagation){event.stopPropagation();}_context.next=3;return grantPushPermissions({useRationaleModal:true,useSettingsModal:true,rationaleModal:{message:'back_in_stock.rationale.message',confirm:'back_in_stock.rationale.confirm',dismiss:'common.cancel'}});case 3:allowed=_context.sent;if(allowed){addBackInStockSubscription({productId:productId});}case 5:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}(),[addBackInStockSubscription,grantPushPermissions,productId,stopPropagation]);if((subscription===null||subscription===void 0?void 0:subscription.status)==='active'){return/*#__PURE__*/React.createElement(Link,{href:BACK_IN_STOCK_PATTERN,disabled:!isLinkToBackInStockEnabled,className:classNames(styles.backInStockMessageContainer,_defineProperty({},styles.rightAligned,alignRight)),tag:"span"},/*#__PURE__*/React.createElement(CheckedIcon,{color:colors.success,className:styles.icon}),/*#__PURE__*/React.createElement("span",{className:styles.backInStockMessage},i18n.text('back_in_stock.we_will_remind_you')));}/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/anchor-is-valid */return/*#__PURE__*/React.createElement("a",{role:"button",tabIndex:0,onClick:handleClick,className:classNames(styles.button,_defineProperty({},styles.rightAligned,alignRight))},/*#__PURE__*/React.createElement(NotificationIcon,{color:colors.primary,className:styles.icon}),/*#__PURE__*/React.createElement("span",{className:styles.buttonText},i18n.text('back_in_stock.get_notified')));/* eslint-enable jsx-a11y/click-events-have-key-events, jsx-a11y/anchor-is-valid */};BackInStockButton.defaultProps={stopPropagation:false,isLinkToBackInStockEnabled:false,alignRight:false,subscription:null,productId:null};export default connect(BackInStockButton);
@@ -1 +1 @@
1
- import{css}from'glamor';import{themeConfig}from'@shopgate/engage';export default{button:css({color:themeConfig.colors.primary}).toString(),buttonContent:css({display:'flex',alignItems:'center'}).toString(),backInStockMessageContainer:css({lineHeight:'20px',display:'flex',alignItems:'center',textAlign:'end',width:'auto'}).toString(),backInStockMessage:css({marginLeft:'4px',verticalAlign:'middle',fontSize:'0.875rem'}).toString(),buttonText:css({marginLeft:'4px',fontSize:'0.875rem',lineHeight:'16.5px'}).toString(),icon:css({verticalAlign:'middle',display:'inline'}).toString()};
1
+ import{css}from'glamor';import{themeConfig}from'@shopgate/engage';export default{button:css({color:themeConfig.colors.primary,display:'flex',lineHeight:'16.5px'}).toString(),buttonContent:css({display:'flex',alignItems:'center'}).toString(),backInStockMessageContainer:css({lineHeight:'16.5px',display:'flex',alignItems:'center',width:'auto'}).toString(),rightAligned:css({display:'inline-block',textAlign:'right'}).toString(),backInStockMessage:css({verticalAlign:'middle',fontSize:'0.875rem'}).toString(),buttonText:css({fontSize:'0.875rem'}).toString(),icon:css({marginRight:4,marginTop:-1,verticalAlign:'middle',flexShrink:0,alignSelf:'flex-start',display:'inline-flex'}).toString()};
@@ -5,4 +5,4 @@ import React from'react';import PropTypes from'prop-types';import{BackInStockBut
5
5
  * @param {Object} props.variant The variant for this entry
6
6
  * @param {Object} props.subscription The subscription
7
7
  * @return {JSX}
8
- */var CharacteristicsButton=function CharacteristicsButton(_ref){var _variant$stock,_variant$stock2;var isBackInStockEnabled=_ref.isBackInStockEnabled,subscription=_ref.subscription,variant=_ref.variant;var productIsNotAVariant=!variant;var featureIsNotEnabled=!isBackInStockEnabled;var productIsNotAvailable=(variant===null||variant===void 0?void 0:(_variant$stock=variant.stock)===null||_variant$stock===void 0?void 0:_variant$stock.quantity)===0&&(variant===null||variant===void 0?void 0:(_variant$stock2=variant.stock)===null||_variant$stock2===void 0?void 0:_variant$stock2.ignoreQuantity)===false;if(productIsNotAVariant||featureIsNotEnabled||!productIsNotAvailable)return null;return/*#__PURE__*/React.createElement("div",{style:{display:'flex',justifyContent:'end'}},/*#__PURE__*/React.createElement(BackInStockButton,{subscription:subscription,stopPropagation:true,productId:variant.id}));};CharacteristicsButton.defaultProps={variant:{},subscription:null};export default withCurrentProduct(connect(CharacteristicsButton));
8
+ */var CharacteristicsButton=function CharacteristicsButton(_ref){var _variant$stock,_variant$stock2;var isBackInStockEnabled=_ref.isBackInStockEnabled,subscription=_ref.subscription,variant=_ref.variant;var productIsNotAVariant=!variant;var featureIsNotEnabled=!isBackInStockEnabled;var productIsNotAvailable=(variant===null||variant===void 0?void 0:(_variant$stock=variant.stock)===null||_variant$stock===void 0?void 0:_variant$stock.quantity)===0&&(variant===null||variant===void 0?void 0:(_variant$stock2=variant.stock)===null||_variant$stock2===void 0?void 0:_variant$stock2.ignoreQuantity)===false;if(productIsNotAVariant||featureIsNotEnabled||!productIsNotAvailable)return null;return/*#__PURE__*/React.createElement(BackInStockButton,{subscription:subscription,stopPropagation:true,productId:variant.id,alignRight:true});};CharacteristicsButton.defaultProps={variant:{},subscription:null};export default withCurrentProduct(connect(CharacteristicsButton));
@@ -1,3 +1,3 @@
1
1
  import{connect}from'react-redux';import{getIsBackInStockEnabled,makeGetSubscriptionByProduct}from'@shopgate/engage/back-in-stock/selectors';import{getProduct}from'@shopgate/engage/product';/**
2
2
  * @return {Object} The extended component props.
3
- */var makeMapStateToProps=function makeMapStateToProps(){var getSubscriptionByProduct=makeGetSubscriptionByProduct();return function(state,props){return{subscription:getSubscriptionByProduct(state,props),isBackInStockEnabled:getIsBackInStockEnabled(state,props),product:getProduct(state,props)};};};export default connect(makeMapStateToProps);
3
+ */var makeMapStateToProps=function makeMapStateToProps(){var getSubscriptionByProduct=makeGetSubscriptionByProduct({status:'active'});return function(state,props){return{subscription:getSubscriptionByProduct(state,props),isBackInStockEnabled:getIsBackInStockEnabled(state,props),product:getProduct(state,props)};};};export default connect(makeMapStateToProps);
@@ -1,4 +1,4 @@
1
- function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useCallback}from'react';import{css}from'glamor';import{LoadingIndicator,Accordion,Card}from'@shopgate/engage/components';import{i18n}from'@shopgate/engage/core';import{useBackInStockSubscriptions}from'@shopgate/engage/back-in-stock/hooks';import Subscription from"../Subscription";var styles={divider:css({height:1,width:'calc(100% + 32px)',backgroundColor:'rgb(234, 234, 234)',marginLeft:-16,marginRight:-16,marginBottom:16}).toString(),emptyText:css({marginBottom:16,textAlign:'center'}).toString(),listTitle:css({fontWeight:'700'}).toString()};/**
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useCallback}from'react';import{css}from'glamor';import{LoadingIndicator,Accordion,Card}from'@shopgate/engage/components';import{i18n}from'@shopgate/engage/core';import{useBackInStockSubscriptions}from'@shopgate/engage/back-in-stock/hooks';import Subscription from"../Subscription";var styles={root:css({margin:'8px 8px 10px'}).toString(),divider:css({height:1,width:'calc(100% + 32px)',backgroundColor:'rgb(234, 234, 234)',marginLeft:-16,marginRight:-16,marginBottom:16}).toString(),emptyText:css({marginBottom:16}).toString()};/**
2
2
  * The Back In Stock Subscriptions List.
3
3
  * @returns {JSX}
4
- */var List=function List(){var _useBackInStockSubscr=useBackInStockSubscriptions(),isInitial=_useBackInStockSubscr.isInitial,groupedSubscriptions=_useBackInStockSubscr.groupedSubscriptions;var _renderLabel=useCallback(function(groupKey){return/*#__PURE__*/React.createElement("div",{className:styles.listTitle},i18n.text("back_in_stock.list_states.".concat(groupKey)));},[]);return/*#__PURE__*/React.createElement("div",null,Object.entries(groupedSubscriptions).map(function(_ref){var _ref2=_slicedToArray(_ref,2),groupKey=_ref2[0],filteredSubscriptions=_ref2[1];return/*#__PURE__*/React.createElement(Card,{className:styles.root,key:groupKey},/*#__PURE__*/React.createElement(Accordion,{className:"",openWithChevron:true,renderLabel:function renderLabel(){return _renderLabel(groupKey);},chevronPosition:"left",startOpened:true},/*#__PURE__*/React.createElement("div",{className:styles.divider}),isInitial?/*#__PURE__*/React.createElement(LoadingIndicator,null):null,!isInitial&&filteredSubscriptions.length===0?/*#__PURE__*/React.createElement("div",{className:styles.emptyText},i18n.text('back_in_stock.empty_list_reminder')):null,!isInitial&&filteredSubscriptions.map(function(subscription,index){return/*#__PURE__*/React.createElement("div",{key:subscription.subscriptionCode},/*#__PURE__*/React.createElement(Subscription,{subscription:subscription,productId:subscription.productCode,key:subscription.subscriptionCode,group:groupKey}),index===filteredSubscriptions.length-1?null:/*#__PURE__*/React.createElement("div",{className:styles.divider}));})));}));};export default List;
4
+ */var List=function List(){var _useBackInStockSubscr=useBackInStockSubscriptions(),isInitial=_useBackInStockSubscr.isInitial,groupedSubscriptions=_useBackInStockSubscr.groupedSubscriptions;var _renderLabel=useCallback(function(groupKey){return/*#__PURE__*/React.createElement("div",null,i18n.text("back_in_stock.list_states.".concat(groupKey)));},[]);return/*#__PURE__*/React.createElement("div",null,Object.entries(groupedSubscriptions).map(function(_ref){var _ref2=_slicedToArray(_ref,2),groupKey=_ref2[0],filteredSubscriptions=_ref2[1];return/*#__PURE__*/React.createElement(Card,{className:styles.root,key:groupKey},/*#__PURE__*/React.createElement(Accordion,{className:"",openWithChevron:true,renderLabel:function renderLabel(){return _renderLabel(groupKey);},chevronPosition:"left",startOpened:true},/*#__PURE__*/React.createElement("div",{className:styles.divider}),isInitial?/*#__PURE__*/React.createElement(LoadingIndicator,null):null,!isInitial&&filteredSubscriptions.length===0?/*#__PURE__*/React.createElement("div",{className:styles.emptyText},i18n.text('back_in_stock.empty_list_reminder')):null,!isInitial&&filteredSubscriptions.map(function(subscription,index){return/*#__PURE__*/React.createElement("div",{key:subscription.subscriptionCode},/*#__PURE__*/React.createElement(Subscription,{subscription:subscription,productId:subscription.productCode,key:subscription.subscriptionCode,group:groupKey}),index===filteredSubscriptions.length-1?null:/*#__PURE__*/React.createElement("div",{className:styles.divider}));})));}));};export default List;
@@ -1,7 +1,7 @@
1
- import React from'react';import{css}from'glamor';import{Link,Ripple,PriceInfo,CrossIcon,PriceStriked,Price,Availability}from'@shopgate/engage/components';import{getProductRoute,ProductImage}from'@shopgate/engage/product';import PropTypes from'prop-types';import classNames from'classnames';import{themeConfig}from'@shopgate/engage';import{BackInStockButton}from'@shopgate/engage/back-in-stock/components';import{getThemeSettings,i18n}from'@shopgate/engage/core';import{useBackInStockSubscriptions}from'@shopgate/engage/back-in-stock/hooks';var variables=themeConfig.variables;var styles={root:css({display:'flex',position:'relative',marginBottom:16}).toString(),imageContainer:css({flex:0.4,maxWidth:170,minWidth:70,paddingRight:'8px'}).toString(),infoContainer:css({flex:1}).toString(),infoContainerRow:css({display:'flex',justifyContent:'space-between'}).toString(),baseContainerRow:css({flexDirection:'column',display:'flex',marginTop:'8px'}).toString(),priceContainerRow:css({flexDirection:'column',display:'flex',alignItems:'end',marginTop:'8px'}).toString(),priceContainer:css({minWidth:100}).toString(),priceInfo:css({wordBreak:'break-word',fontSize:'0.875rem',lineHeight:'0.875rem',color:'var(--color-text-low-emphasis)',padding:"".concat(variables.gap.xsmall,"px 0"),textAlign:'right'}).toString(),titleContainer:css({}).toString(),title:css({fontSize:17,fontWeight:600,flexWrap:'wrap',overflowWrap:'anywhere'}).toString(),removeContainer:css({minWidth:'30px'}).toString(),availabilityText:css({fontSize:'0.875rem',marginBottom:'4px'}).toString(),ripple:css({minWidth:'17px'}).toString()};/**
1
+ import React from'react';import{css}from'glamor';import{Link,Ripple,PriceInfo,CrossIcon,PriceStriked,Price,Availability}from'@shopgate/engage/components';import{getProductRoute,ProductImage}from'@shopgate/engage/product';import PropTypes from'prop-types';import classNames from'classnames';import{themeConfig}from'@shopgate/engage';import{BackInStockButton}from'@shopgate/engage/back-in-stock/components';import{getThemeSettings,i18n}from'@shopgate/engage/core';import{useBackInStockSubscriptions}from'@shopgate/engage/back-in-stock/hooks';var variables=themeConfig.variables;var styles={root:css({display:'flex',position:'relative',marginBottom:16}).toString(),imageContainer:css({flex:0.4,maxWidth:170,minWidth:70,paddingRight:'8px'}).toString(),infoContainer:css({flex:1}).toString(),infoContainerRow:css({display:'flex',justifyContent:'space-between'}).toString(),baseContainerRow:css({flexDirection:'column',display:'flex',marginTop:'8px'}).toString(),priceContainerRow:css({flexDirection:'column',display:'flex',alignItems:'end',marginTop:'8px'}).toString(),priceContainer:css({minWidth:100}).toString(),priceInfo:css({wordBreak:'break-word',fontSize:'0.875rem',lineHeight:'0.875rem',color:'var(--color-text-low-emphasis)',padding:"".concat(variables.gap.xsmall,"px 0"),textAlign:'right'}).toString(),titleContainer:css({}).toString(),title:css({fontSize:17,fontWeight:600,flexWrap:'wrap',overflowWrap:'anywhere'}).toString(),removeContainer:css({minWidth:'30px'}).toString(),availabilityText:css({fontSize:'0.875rem',marginBottom:'4px'}).toString(),characteristicText:css({fontSize:'0.875rem'}).toString(),ripple:css({minWidth:'17px'}).toString()};/**
2
2
  * Renders on single Back in Stock subscription
3
3
  * @param {Object} props Props.
4
4
  * @param {string} props.subscription The subscription which should be rendered
5
5
  * @returns {JSX}
6
- */var Subscription=function Subscription(_ref){var _product$price,_product$price2,_product$price3,_product$price4,_product$availability,_product$availability2;var subscription=_ref.subscription;var subscriptionCode=subscription.subscriptionCode,product=subscription.product;var _useBackInStockSubscr=useBackInStockSubscriptions(),removeBackInStockSubscription=_useBackInStockSubscr.removeBackInStockSubscription;var _ref2=getThemeSettings('AppImages')||{},gridResolutions=_ref2.ListImage;var currency=((_product$price=product.price)===null||_product$price===void 0?void 0:_product$price.currency)||'EUR';var defaultPrice=((_product$price2=product.price)===null||_product$price2===void 0?void 0:_product$price2.unitPrice)||0;var specialPrice=(_product$price3=product.price)===null||_product$price3===void 0?void 0:_product$price3.unitPriceStriked;var hasStrikePrice=((_product$price4=product.price)===null||_product$price4===void 0?void 0:_product$price4.discount)>0;var productLink=getProductRoute(product.id);return/*#__PURE__*/React.createElement("div",{className:styles.root},/*#__PURE__*/React.createElement(Link,{className:styles.imageContainer,component:"div",href:productLink,"aria-hidden":true},/*#__PURE__*/React.createElement(ProductImage,{src:product.featuredImageBaseUrl,resolutions:gridResolutions})),/*#__PURE__*/React.createElement("div",{className:styles.infoContainer},/*#__PURE__*/React.createElement("div",{className:styles.infoContainerRow},/*#__PURE__*/React.createElement(Link,{href:productLink,tag:"span",className:styles.titleContainer},/*#__PURE__*/React.createElement("span",{className:styles.title// eslint-disable-next-line react/no-danger
7
- ,dangerouslySetInnerHTML:{__html:"".concat(product.name)}})),/*#__PURE__*/React.createElement("div",{className:styles.removeContainer},/*#__PURE__*/React.createElement("button",{onClick:function onClick(){return removeBackInStockSubscription({subscriptionCode:subscriptionCode});},type:"button","aria-label":i18n.text('favorites.remove')},/*#__PURE__*/React.createElement(Ripple,{className:styles.ripple},/*#__PURE__*/React.createElement(CrossIcon,null))))),/*#__PURE__*/React.createElement("div",{className:classNames(styles.baseContainerRow)},/*#__PURE__*/React.createElement(Availability,{text:product===null||product===void 0?void 0:(_product$availability=product.availability)===null||_product$availability===void 0?void 0:_product$availability.text,state:product===null||product===void 0?void 0:(_product$availability2=product.availability)===null||_product$availability2===void 0?void 0:_product$availability2.state,showWhenAvailable:false,className:styles.availabilityText}),/*#__PURE__*/React.createElement(BackInStockButton,{subscription:subscription,onClick:function onClick(){}})),/*#__PURE__*/React.createElement("div",{className:styles.priceContainerRow},hasStrikePrice?/*#__PURE__*/React.createElement(PriceStriked,{value:specialPrice,currency:currency}):null,/*#__PURE__*/React.createElement(Price,{currency:currency,discounted:hasStrikePrice,unitPrice:defaultPrice}),!!product.price.info&&/*#__PURE__*/React.createElement(PriceInfo,{text:product.price.info,className:styles.priceInfo}))));};export default Subscription;
6
+ */var Subscription=function Subscription(_ref){var _product$price,_product$price2,_product$price3,_product$price4,_product$characterist,_product$availability,_product$availability2;var subscription=_ref.subscription;var subscriptionCode=subscription.subscriptionCode,product=subscription.product,productCode=subscription.productCode;var _useBackInStockSubscr=useBackInStockSubscriptions(),removeBackInStockSubscription=_useBackInStockSubscr.removeBackInStockSubscription;var _ref2=getThemeSettings('AppImages')||{},gridResolutions=_ref2.ListImage;var currency=((_product$price=product.price)===null||_product$price===void 0?void 0:_product$price.currency)||'EUR';var defaultPrice=((_product$price2=product.price)===null||_product$price2===void 0?void 0:_product$price2.unitPrice)||0;var specialPrice=(_product$price3=product.price)===null||_product$price3===void 0?void 0:_product$price3.unitPriceStriked;var hasStrikePrice=((_product$price4=product.price)===null||_product$price4===void 0?void 0:_product$price4.discount)>0;var productLink=getProductRoute(product.id);return/*#__PURE__*/React.createElement("div",{className:styles.root},/*#__PURE__*/React.createElement(Link,{className:styles.imageContainer,component:"div",href:productLink,"aria-hidden":true},/*#__PURE__*/React.createElement(ProductImage,{src:product.featuredImageBaseUrl,resolutions:gridResolutions})),/*#__PURE__*/React.createElement("div",{className:styles.infoContainer},/*#__PURE__*/React.createElement("div",{className:styles.infoContainerRow},/*#__PURE__*/React.createElement(Link,{href:productLink,tag:"span",className:styles.titleContainer},/*#__PURE__*/React.createElement("span",{className:styles.title// eslint-disable-next-line react/no-danger
7
+ ,dangerouslySetInnerHTML:{__html:"".concat(product.name)}})),/*#__PURE__*/React.createElement("div",{className:styles.removeContainer},/*#__PURE__*/React.createElement("button",{onClick:function onClick(){return removeBackInStockSubscription({subscriptionCode:subscriptionCode});},type:"button","aria-label":i18n.text('favorites.remove')},/*#__PURE__*/React.createElement(Ripple,{className:styles.ripple},/*#__PURE__*/React.createElement(CrossIcon,null))))),/*#__PURE__*/React.createElement("div",{className:classNames(styles.baseContainerRow)},product===null||product===void 0?void 0:(_product$characterist=product.characteristics)===null||_product$characterist===void 0?void 0:_product$characterist.map(function(_ref3){var label=_ref3.label,value=_ref3.value;return/*#__PURE__*/React.createElement("div",{key:label+value,className:styles.characteristicText},label,': ',value);}),/*#__PURE__*/React.createElement(Availability,{text:product===null||product===void 0?void 0:(_product$availability=product.availability)===null||_product$availability===void 0?void 0:_product$availability.text,state:product===null||product===void 0?void 0:(_product$availability2=product.availability)===null||_product$availability2===void 0?void 0:_product$availability2.state,showWhenAvailable:false,className:styles.availabilityText}),(subscription===null||subscription===void 0?void 0:subscription.status)==='active'&&/*#__PURE__*/React.createElement(BackInStockButton,{subscription:subscription,productId:productCode})),/*#__PURE__*/React.createElement("div",{className:styles.priceContainerRow},hasStrikePrice?/*#__PURE__*/React.createElement(PriceStriked,{value:specialPrice,currency:currency}):null,/*#__PURE__*/React.createElement(Price,{currency:currency,discounted:hasStrikePrice,unitPrice:defaultPrice}),!!product.price.info&&/*#__PURE__*/React.createElement(PriceInfo,{text:product.price.info,className:styles.priceInfo}))));};export default Subscription;
@@ -1,7 +1,7 @@
1
- import{connect}from'react-redux';import{getBackInStockSubscriptions,getBackInStockSubscriptionsFetching,getBackInStockSubscriptionsInitial}from'@shopgate/engage/back-in-stock/selectors';import{addBackInStockSubscription,removeBackInStockSubscription}from'@shopgate/engage/back-in-stock/actions';/**
1
+ import{connect}from'react-redux';import{getBackInStockSubscriptions,getBackInStockSubscriptionsFetching,getBackInStockSubscriptionsInitial,getAreBackInStockRequestsPossible}from'@shopgate/engage/back-in-stock/selectors';import{addBackInStockSubscription,removeBackInStockSubscription}from'@shopgate/engage/back-in-stock/actions';/**
2
2
  * @return {Function} The extended component props.
3
3
  */function makeMapStateToProps(){/**
4
4
  * @param {Object} state The application state.
5
5
  * @param {Object} props The component props
6
6
  * @returns {Object}
7
- */return function(state,props){return{subscriptions:getBackInStockSubscriptions(state,props),isFetching:getBackInStockSubscriptionsFetching(state,props),isInitial:getBackInStockSubscriptionsInitial(state,props)};};}var mapDispatchToProps={addBackInStockSubscription:addBackInStockSubscription,removeBackInStockSubscription:removeBackInStockSubscription};export default connect(makeMapStateToProps,mapDispatchToProps);
7
+ */return function(state,props){return{subscriptions:getBackInStockSubscriptions(state,props),isFetching:getBackInStockSubscriptionsFetching(state,props),isInitial:getBackInStockSubscriptionsInitial(state,props),requestsPossible:getAreBackInStockRequestsPossible(state,props)};};}var mapDispatchToProps={addBackInStockSubscription:addBackInStockSubscription,removeBackInStockSubscription:removeBackInStockSubscription};export default connect(makeMapStateToProps,mapDispatchToProps);
@@ -1,5 +1,5 @@
1
1
  import React,{useMemo}from'react';import PropTypes from'prop-types';import Context from"./BackInStockSubscriptionsProvider.context";import connect from"./BackInStockSubscriptionsProvider.connector";/**
2
2
  * Back in Stock Provider
3
3
  * @returns {JSX}
4
- */var BackInStockSubscriptionsProvider=function BackInStockSubscriptionsProvider(_ref){var subscriptions=_ref.subscriptions,children=_ref.children,addBackInStockSubscription=_ref.addBackInStockSubscription,isFetching=_ref.isFetching,isInitial=_ref.isInitial,removeBackInStockSubscription=_ref.removeBackInStockSubscription;var groupedSubscriptions=useMemo(function(){return subscriptions.reduce(function(acc,subscription){var status=subscription.status;var groupingStatus=status==='inactive'||status==='triggered'?'past':status;acc[groupingStatus].push(subscription);return acc;},{active:[],past:[]});},[subscriptions]);// Create memoized context value.
5
- var value=useMemo(function(){return{subscriptions:subscriptions,groupedSubscriptions:groupedSubscriptions,addBackInStockSubscription:addBackInStockSubscription,removeBackInStockSubscription:removeBackInStockSubscription,isFetching:isFetching,isInitial:isInitial};},[addBackInStockSubscription,groupedSubscriptions,isFetching,isInitial,removeBackInStockSubscription,subscriptions]);return/*#__PURE__*/React.createElement(Context.Provider,{value:value},children);};BackInStockSubscriptionsProvider.defaultProps={children:null,isFetching:false,isInitial:true};export default connect(BackInStockSubscriptionsProvider);
4
+ */var BackInStockSubscriptionsProvider=function BackInStockSubscriptionsProvider(_ref){var subscriptions=_ref.subscriptions,children=_ref.children,addBackInStockSubscription=_ref.addBackInStockSubscription,isFetching=_ref.isFetching,isInitial=_ref.isInitial,removeBackInStockSubscription=_ref.removeBackInStockSubscription,requestsPossible=_ref.requestsPossible;var groupedSubscriptions=useMemo(function(){return subscriptions.reduce(function(acc,subscription){var status=subscription.status;var groupingStatus=status==='inactive'||status==='triggered'?'past':status;acc[groupingStatus].push(subscription);return acc;},{active:[],past:[]});},[subscriptions]);// Create memoized context value.
5
+ var value=useMemo(function(){return{subscriptions:subscriptions,groupedSubscriptions:groupedSubscriptions,addBackInStockSubscription:addBackInStockSubscription,removeBackInStockSubscription:removeBackInStockSubscription,isFetching:isFetching,isInitial:isInitial&&requestsPossible};},[addBackInStockSubscription,groupedSubscriptions,isFetching,isInitial,removeBackInStockSubscription,subscriptions,requestsPossible]);return/*#__PURE__*/React.createElement(Context.Provider,{value:value},children);};BackInStockSubscriptionsProvider.defaultProps={children:null,isFetching:false,isInitial:true,requestsPossible:false};export default connect(BackInStockSubscriptionsProvider);
@@ -1,5 +1,5 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{ADD_BACK_IN_STOCK_SUBSCRIPTION,ADD_BACK_IN_STOCK_SUBSCRIPTION_ERROR,ADD_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_ERROR,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_SUCCESS,REMOVE_BACK_IN_STOCK_SUBSCRIPTION,REMOVE_BACK_IN_STOCK_SUBSCRIPTION_ERROR,REMOVE_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS}from'@shopgate/engage/back-in-stock/constants';var initialState={isFetching:false,isInitial:true,subscriptions:[]};/**
1
+ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{PERMISSION_ID_PUSH,APP_PERMISSION_STATUS_RECEIVED}from'@shopgate/engage/core/constants';import{ADD_BACK_IN_STOCK_SUBSCRIPTION,ADD_BACK_IN_STOCK_SUBSCRIPTION_ERROR,ADD_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_ERROR,FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_SUCCESS,REMOVE_BACK_IN_STOCK_SUBSCRIPTION,REMOVE_BACK_IN_STOCK_SUBSCRIPTION_ERROR,REMOVE_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS}from'@shopgate/engage/back-in-stock/constants';var initialState={isFetching:false,isInitial:true,subscriptions:[],pushPermissionStatus:null};/**
2
2
  * @param {Object} state The application state.
3
3
  * @param {Object} action The redux action.
4
4
  * @returns {Object}
5
- */export default(function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:initialState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS:{return _extends({},state,{isFetching:true});}case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_SUCCESS:{return _extends({},state,{isInitial:false,isFetching:false,subscriptions:action.subscriptions});}case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_ERROR:{return _extends({},state,{isFetching:false});}case ADD_BACK_IN_STOCK_SUBSCRIPTION:{return _extends({},state,{isFetching:true});}case ADD_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS:{return _extends({},state,{isFetching:false});}case ADD_BACK_IN_STOCK_SUBSCRIPTION_ERROR:{return _extends({},state,{isFetching:false});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION:{return _extends({},state,{isFetching:true});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS:{return _extends({},state,{isFetching:false});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION_ERROR:{return _extends({},state,{isFetching:false});}default:return state;}});
5
+ */export default(function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:initialState;var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS:{return _extends({},state,{isFetching:true});}case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_SUCCESS:{return _extends({},state,{isInitial:false,isFetching:false,subscriptions:action.subscriptions});}case FETCH_BACK_IN_STOCK_SUBSCRIPTIONS_ERROR:{return _extends({},state,{isFetching:false});}case ADD_BACK_IN_STOCK_SUBSCRIPTION:{return _extends({},state,{isFetching:true});}case ADD_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS:{return _extends({},state,{isFetching:false});}case ADD_BACK_IN_STOCK_SUBSCRIPTION_ERROR:{return _extends({},state,{isFetching:false});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION:{return _extends({},state,{isFetching:true});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION_SUCCESS:{return _extends({},state,{isFetching:false});}case REMOVE_BACK_IN_STOCK_SUBSCRIPTION_ERROR:{return _extends({},state,{isFetching:false});}case APP_PERMISSION_STATUS_RECEIVED:{if(action.permissionId!==PERMISSION_ID_PUSH){return state;}return _extends({},state,{pushPermissionStatus:action.status});}default:return state;}});
@@ -1,24 +1,42 @@
1
- import{createSelector}from'reselect';import{makeGetProductByCharacteristics}from'@shopgate/engage/product';import{appConfig}from'@shopgate/engage';/**
1
+ function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import{createSelector}from'reselect';import{makeGetProductByCharacteristics}from'@shopgate/engage/product';import{appSupportsPushOptIn}from'@shopgate/engage/core/helpers';import{hasSGJavaScriptBridge}from'@shopgate/pwa-core/helpers';import{appConfig}from'@shopgate/engage';import{getClientInformation}from'@shopgate/engage/core';import{PERMISSION_STATUS_GRANTED,PERMISSION_STATUS_NOT_SUPPORTED}from'@shopgate/engage/core/constants';/**
2
2
  * @param {Object} state The application state.
3
3
  * @returns {Object}
4
- */export var getBackInStockSubscriptions=function getBackInStockSubscriptions(state){return state.backInStock.subscriptions;};/**
5
- * @param {Object} state The application state.
6
- * @returns {Object}
7
- */export var getBackInStockSubscriptionsFetching=function getBackInStockSubscriptionsFetching(state){return state.backInStock.isFetching;};/**
8
- * @param {Object} state The application state.
9
- * @returns {Object}
10
- */export var getBackInStockSubscriptionsInitial=function getBackInStockSubscriptionsInitial(state){return state.backInStock.isInitial;};/**
4
+ */export var getBackInStockState=function getBackInStockState(state){return state.backInStock;};/**
5
+ * Selector to retrieve the back-in-stock subscriptions list
6
+ * @returns {Array}
7
+ */export var getBackInStockSubscriptions=createSelector(getBackInStockState,function(state){return state.subscriptions;});/**
8
+ * Selector to retrieve the current fetching state of back-in-stock subscriptions
9
+ * @returns {boolean}
10
+ */export var getBackInStockSubscriptionsFetching=createSelector(getBackInStockState,function(state){return state.isFetching;});/**
11
+ * Selector to determine if back-in-stock subscriptions have been fetched before
12
+ * @returns {boolean}
13
+ */export var getBackInStockSubscriptionsInitial=createSelector(getBackInStockState,function(state){return state.isInitial;});/**
14
+ * Selector to retrieve the current status of the push app permission
15
+ * @returns {string}
16
+ */export var getBackInStockPushPermissionStatus=createSelector(getBackInStockState,function(state){return state.pushPermissionStatus;});/**
11
17
  * Creates a selector that retrieves the subscription of
12
18
  * a product / variant or null by its variantId / productId
19
+ * @param {Object} params Params
20
+ * @param {string} params.status Get subscription for a specific status
13
21
  * @returns {Function}
14
- */export var makeGetSubscriptionByProduct=function makeGetSubscriptionByProduct(){return createSelector(function(state){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return props.variantId?props.variantId:props.productId;},getBackInStockSubscriptions,function(requestedProductCode,subscriptions){if(!requestedProductCode){return false;}return subscriptions.find(function(_ref){var productCode=_ref.productCode;return productCode===requestedProductCode;})||null;});};/**
22
+ */export var makeGetSubscriptionByProduct=function makeGetSubscriptionByProduct(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},status=_ref.status;return createSelector(function(state){var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return props.variantId?props.variantId:props.productId;},getBackInStockSubscriptions,function(requestedProductCode,subscriptions){if(!requestedProductCode){return false;}return subscriptions.find(function(_ref2){var productCode=_ref2.productCode,subscriptionStatus=_ref2.status;var match=productCode===requestedProductCode;if(match&&status){// When the selector factory is created for a specific status, the subscription also
23
+ // needs to fulfill this condition
24
+ match=subscriptionStatus===status;}return match;})||null;});};/**
15
25
  * Creates a selector that retrieves the subscription of
16
26
  * a product / variant by its characteristics
17
27
  * @returns {Function}
18
- */export var makeGetSubscriptionByCharacteristics=function makeGetSubscriptionByCharacteristics(){var getProductByCharacteristics=makeGetProductByCharacteristics();return createSelector(getProductByCharacteristics,getBackInStockSubscriptions,function(product,subscriptions){if(!product){return null;}return subscriptions.find(function(_ref2){var productCode=_ref2.productCode;return productCode===product.id;})||null;});};/**
19
- * Returns if the back in stock feature is enabled
20
- * @returns {Function}
21
- */export var getIsBackInStockEnabled=function getIsBackInStockEnabled(){return(appConfig===null||appConfig===void 0?void 0:appConfig.showBackInStock)||false;};/**
28
+ */export var makeGetSubscriptionByCharacteristics=function makeGetSubscriptionByCharacteristics(){var getProductByCharacteristics=makeGetProductByCharacteristics();return createSelector(getProductByCharacteristics,getBackInStockSubscriptions,function(product,subscriptions){if(!product){return null;}return subscriptions.find(function(_ref3){var productCode=_ref3.productCode;return productCode===product.id;})||null;});};/**
29
+ * Selector to determine if the back-in-stock feature is enabled
30
+ * @returns {boolean}
31
+ */export var getIsBackInStockEnabled=createSelector(getClientInformation,getBackInStockPushPermissionStatus,function(clientInformation,pushPermissionStatus){if(!appSupportsPushOptIn()){// Disabled when the app doesn't support the required features
32
+ return false;}// Perform app version checks when PWA runs outside the browser
33
+ if(hasSGJavaScriptBridge()){var _clientInformation$co=clientInformation.codebaseVersion,codebaseVersion=_clientInformation$co===void 0?'0.0.0':_clientInformation$co;var _codebaseVersion$spli=codebaseVersion.split('.'),_codebaseVersion$spli2=_slicedToArray(_codebaseVersion$spli,1),major=_codebaseVersion$spli2[0];/**
34
+ * The feature can be enabled on react-native-engage based apps (>= 11.0.0) with proper
35
+ * support for push permissions checks
36
+ */if(parseInt(major,10)<11||pushPermissionStatus===PERMISSION_STATUS_NOT_SUPPORTED){return false;}}return(appConfig===null||appConfig===void 0?void 0:appConfig.showBackInStock)||false;});/**
37
+ * Selector to determine if back-in-stock related requests are currently possible.
38
+ * @returns {boolean}
39
+ */export var getAreBackInStockRequestsPossible=createSelector(getIsBackInStockEnabled,getBackInStockPushPermissionStatus,function(featureEnabled,pushPermissionStatus){return featureEnabled&&pushPermissionStatus===PERMISSION_STATUS_GRANTED;});/**
22
40
  * Returns if subscription list is in use
23
- * @returns {Function}
41
+ * @returns {boolean}
24
42
  */export var getHasBackInStockSubscriptions=createSelector(getBackInStockSubscriptions,function(subscriptions){return!!subscriptions.length;});
@@ -1,3 +1,11 @@
1
- import showModal from'@shopgate/pwa-common/actions/modal/showModal';import{fetchBackInStockSubscriptions}from'@shopgate/engage/back-in-stock/actions';import{addBackInStockReminderSuccess$,backInStockReminderNeedsFetch$}from'@shopgate/engage/back-in-stock/streams';/**
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{appWillInit$}from'@shopgate/engage/core';import{PERMISSION_ID_PUSH}from'@shopgate/engage/core/constants';import{appInitialization}from'@shopgate/engage/core/collections';import{requestAppPermissionStatus}from'@shopgate/engage/core/actions';import showModal from'@shopgate/pwa-common/actions/modal/showModal';import{fetchBackInStockSubscriptions}from'@shopgate/engage/back-in-stock/actions';import{addBackInStockReminderSuccess$,backInStockReminderNeedsFetch$}from'@shopgate/engage/back-in-stock/streams';import{getIsBackInStockEnabled,getAreBackInStockRequestsPossible}from'@shopgate/engage/back-in-stock/selectors';/**
2
2
  * @param {Function} subscribe The subscribe function.
3
- */export default function backInStock(subscribe){subscribe(backInStockReminderNeedsFetch$,function(_ref){var dispatch=_ref.dispatch;dispatch(fetchBackInStockSubscriptions());});subscribe(addBackInStockReminderSuccess$,function(_ref2){var dispatch=_ref2.dispatch;dispatch(showModal({title:'back_in_stock.add_back_in_stock_success_modal.title',message:'back_in_stock.add_back_in_stock_success_modal.message',confirm:'modal.confirm',dismiss:null}));});}
3
+ */export default function backInStock(subscribe){subscribe(appWillInit$,function(){/**
4
+ * Back-in-stock requests are only possible when users granted push permissions. Otherwise
5
+ * the backend will not be able to assign the subscriptions to a device.
6
+ *
7
+ * So in the next block we register a new handler to the "appInitialization" collection which
8
+ * will retrieve the current status of the push permission before the React app starts.
9
+ *
10
+ * The back-in-stock reducer will store the status, so that selectors can work with it.
11
+ */appInitialization.set('back-in-stock',/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref){var dispatch,getState,isEnabled;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dispatch=_ref.dispatch,getState=_ref.getState;isEnabled=getIsBackInStockEnabled(getState());if(!isEnabled){_context.next=5;break;}_context.next=5;return dispatch(requestAppPermissionStatus({permissionId:PERMISSION_ID_PUSH}));case 5:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}());});subscribe(backInStockReminderNeedsFetch$,function(_ref3){var dispatch=_ref3.dispatch,getState=_ref3.getState;var requestsPossible=getAreBackInStockRequestsPossible(getState());if(requestsPossible){dispatch(fetchBackInStockSubscriptions());}});subscribe(addBackInStockReminderSuccess$,function(_ref4){var dispatch=_ref4.dispatch;dispatch(showModal({title:'back_in_stock.add_back_in_stock_success_modal.title',message:'back_in_stock.add_back_in_stock_success_modal.message',confirm:'modal.confirm',dismiss:null}));});}
@@ -0,0 +1,9 @@
1
+ import{APP_PERMISSION_STATUS_RECEIVED}from"../constants/actionTypes";/**
2
+ * Creates the APP_PERMISSION_STATUS_RECEIVED Redux action object that's supposed to be dispatched
3
+ * when a permission status was requested from the app.
4
+ * @param {Object} params Action params
5
+ * @param {string} params.permissionId The updated permission id
6
+ * @param {string} params.status The new status
7
+ * @param {Object} [params.options={}], Extended options for the permission
8
+ * @returns {Object} The Redux action object
9
+ */export var appPermissionStatusReceived=function appPermissionStatusReceived(_ref){var permissionId=_ref.permissionId,status=_ref.status,_ref$options=_ref.options,options=_ref$options===void 0?{}:_ref$options;return{type:APP_PERMISSION_STATUS_RECEIVED,permissionId:permissionId,status:status,options:options};};
@@ -0,0 +1 @@
1
+ export*from"./appPermissions";
@@ -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 grantGeolocationPermissions from"./grantGeolocationPermissions";import GeolocationRequest from"../classes/GeolocationRequest";import{GEOLOCATION_ERROR_DENIED}from"../constants/geolocationRequest";/**
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{GEOLOCATION_ERROR_DENIED}from'@shopgate/engage/core/constants';import grantGeolocationPermissions from"./grantGeolocationPermissions";import GeolocationRequest from"../classes/GeolocationRequest";/**
2
2
  * Determines the geolocation of the user. When not geolocation permissions are granted yet,
3
3
  * the user will be prompted to grant access.
4
4
  * @param {Object} options Action options.
@@ -1,4 +1,4 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{PERMISSION_ID_CAMERA}from'@shopgate/pwa-core/constants/AppPermissions';import grantPermissions from"./grantPermissions";/**
1
+ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{PERMISSION_ID_CAMERA}from'@shopgate/engage/core/constants';import grantPermissions from"./grantPermissions";/**
2
2
  * Determines the current state of the camera permissions.
3
3
  * If not already happened, the user will be prompted to grant permissions.
4
4
  * The action returns a promise which resolves with a boolean value, that indicates the state.
@@ -1,4 +1,4 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{PERMISSION_ID_LOCATION}from'@shopgate/pwa-core/constants/AppPermissions';import grantPermissions from"./grantPermissions";/**
1
+ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{PERMISSION_ID_LOCATION}from'@shopgate/engage/core/constants';import grantPermissions from"./grantPermissions";/**
2
2
  * Determines the current state of the geolocation permissions.
3
3
  * If not already happened, the user will be prompted to grant permissions.
4
4
  * The action returns a promise which resolves with a boolean value, that indicates the state.
@@ -1,4 +1,4 @@
1
- import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}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 event from'@shopgate/pwa-core/classes/Event';import{APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND}from'@shopgate/pwa-core/constants/AppEvents';import openAppSettings from'@shopgate/pwa-core/commands/openAppSettings';import{showModal}from'@shopgate/engage/core';import{STATUS_DENIED,STATUS_GRANTED,STATUS_NOT_DETERMINED,STATUS_NOT_SUPPORTED,availablePermissionsIds}from'@shopgate/pwa-core/constants/AppPermissions';import{getAppPermissions,requestAppPermissions}from'@shopgate/pwa-core/commands/appPermissions';import{logger}from'@shopgate/pwa-core/helpers';/**
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 event from'@shopgate/pwa-core/classes/Event';import openAppSettings from'@shopgate/pwa-core/commands/openAppSettings';import{showModal}from'@shopgate/engage/core';import{PERMISSION_STATUS_DENIED,PERMISSION_STATUS_GRANTED,PERMISSION_STATUS_NOT_DETERMINED,PERMISSION_STATUS_NOT_SUPPORTED,APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,availablePermissionsIds}from'@shopgate/engage/core/constants';import{logger}from'@shopgate/pwa-core/helpers';import requestAppPermission from"./requestAppPermission";import requestAppPermissionStatus from"./requestAppPermissionStatus";/**
2
2
  * Determines the current state of a specific permission for an app feature. If not already
3
3
  * happened, the user will be prompted to grant permissions.
4
4
  * The action returns a promise which resolves with a boolean value, that indicates the state.
@@ -20,10 +20,10 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToAr
20
20
  * @param {string} options.modal.dismiss Label for the dismiss button.
21
21
  * @param {Object} options.modal.params Additional parameters for i18n strings.
22
22
  * @return { Function } A redux thunk.
23
- */var grantPermissions=function grantPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){return new Promise(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve){var permissionId,_options$useSettingsM,useSettingsModal,_options$useRationale,useRationaleModal,_options$rationaleMod,rationaleModalOptions,_options$modal,modalOptions,status,_yield$getAppPermissi,_yield$getAppPermissi2,requestAllowed,_yield$requestAppPerm,_yield$requestAppPerm2,openSettings,handler;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:permissionId=options.permissionId,_options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?false:_options$useSettingsM,_options$useRationale=options.useRationaleModal,useRationaleModal=_options$useRationale===void 0?false:_options$useRationale,_options$rationaleMod=options.rationaleModal,rationaleModalOptions=_options$rationaleMod===void 0?{}:_options$rationaleMod,_options$modal=options.modal,modalOptions=_options$modal===void 0?{}:_options$modal;if(availablePermissionsIds.includes(permissionId)){_context2.next=5;break;}logger.error('grandPermissions: %s is no valid permission id',permissionId);resolve(false);return _context2.abrupt("return");case 5:_context2.next=7;return getAppPermissions([permissionId]);case 7:_yield$getAppPermissi=_context2.sent;_yield$getAppPermissi2=_slicedToArray(_yield$getAppPermissi,1);status=_yield$getAppPermissi2[0].status;if(!(status===STATUS_NOT_SUPPORTED)){_context2.next=13;break;}resolve(false);return _context2.abrupt("return");case 13:if(!(status===STATUS_NOT_DETERMINED)){_context2.next=29;break;}if(!useRationaleModal){_context2.next=21;break;}_context2.next=17;return dispatch(showModal({message:rationaleModalOptions.message||'',confirm:rationaleModalOptions.confirm||'',dismiss:rationaleModalOptions.dismiss||'',params:rationaleModalOptions.params||''}));case 17:requestAllowed=_context2.sent;if(!(requestAllowed===false)){_context2.next=21;break;}resolve(false);return _context2.abrupt("return");case 21:_context2.next=23;return requestAppPermissions([{permissionId:permissionId}]);case 23:_yield$requestAppPerm=_context2.sent;_yield$requestAppPerm2=_slicedToArray(_yield$requestAppPerm,1);status=_yield$requestAppPerm2[0].status;if(![STATUS_DENIED,STATUS_NOT_DETERMINED].includes(status)){_context2.next=29;break;}resolve(false);return _context2.abrupt("return");case 29:if(!(status===STATUS_GRANTED)){_context2.next=32;break;}resolve(true);return _context2.abrupt("return");case 32:if(!(status===STATUS_DENIED)){_context2.next=45;break;}if(useSettingsModal){_context2.next=36;break;}resolve(false);return _context2.abrupt("return");case 36:_context2.next=38;return dispatch(showModal({title:modalOptions.title||null,message:modalOptions.message,confirm:modalOptions.confirm,dismiss:modalOptions.dismiss,params:modalOptions.params}));case 38:openSettings=_context2.sent;if(openSettings){_context2.next=42;break;}resolve(false);return _context2.abrupt("return");case 42:/**
23
+ */var grantPermissions=function grantPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){return new Promise(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve){var permissionId,_options$useSettingsM,useSettingsModal,_options$useRationale,useRationaleModal,_options$rationaleMod,rationaleModalOptions,_options$modal,modalOptions,status,requestAllowed,openSettings,handler;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:permissionId=options.permissionId,_options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?false:_options$useSettingsM,_options$useRationale=options.useRationaleModal,useRationaleModal=_options$useRationale===void 0?false:_options$useRationale,_options$rationaleMod=options.rationaleModal,rationaleModalOptions=_options$rationaleMod===void 0?{}:_options$rationaleMod,_options$modal=options.modal,modalOptions=_options$modal===void 0?{}:_options$modal;if(availablePermissionsIds.includes(permissionId)){_context2.next=5;break;}logger.error('grandPermissions: %s is no valid permission id',permissionId);resolve(false);return _context2.abrupt("return");case 5:_context2.next=7;return dispatch(requestAppPermissionStatus({permissionId:permissionId}));case 7:status=_context2.sent;if(!(status===PERMISSION_STATUS_NOT_SUPPORTED)){_context2.next=11;break;}resolve(false);return _context2.abrupt("return");case 11:if(!(status===PERMISSION_STATUS_NOT_DETERMINED)){_context2.next=25;break;}if(!useRationaleModal){_context2.next=19;break;}_context2.next=15;return dispatch(showModal({message:rationaleModalOptions.message||'',confirm:rationaleModalOptions.confirm||'',dismiss:rationaleModalOptions.dismiss||'',params:rationaleModalOptions.params}));case 15:requestAllowed=_context2.sent;if(!(requestAllowed===false)){_context2.next=19;break;}resolve(false);return _context2.abrupt("return");case 19:_context2.next=21;return dispatch(requestAppPermission({permissionId:permissionId}));case 21:status=_context2.sent;if(![PERMISSION_STATUS_DENIED,PERMISSION_STATUS_NOT_DETERMINED].includes(status)){_context2.next=25;break;}resolve(false);return _context2.abrupt("return");case 25:if(!(status===PERMISSION_STATUS_GRANTED)){_context2.next=28;break;}resolve(true);return _context2.abrupt("return");case 28:if(!(status===PERMISSION_STATUS_DENIED)){_context2.next=41;break;}if(useSettingsModal){_context2.next=32;break;}resolve(false);return _context2.abrupt("return");case 32:_context2.next=34;return dispatch(showModal({title:modalOptions.title||null,message:modalOptions.message,confirm:modalOptions.confirm,dismiss:modalOptions.dismiss,params:modalOptions.params}));case 34:openSettings=_context2.sent;if(openSettings){_context2.next=38;break;}resolve(false);return _context2.abrupt("return");case 38:/**
24
24
  * Handler for the app event.
25
- */handler=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var _yield$getAppPermissi3,_yield$getAppPermissi4;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:event.removeCallback(APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,handler);_context.next=3;return getAppPermissions([permissionId]);case 3:_yield$getAppPermissi3=_context.sent;_yield$getAppPermissi4=_slicedToArray(_yield$getAppPermissi3,1);status=_yield$getAppPermissi4[0].status;resolve(status===STATUS_GRANTED);case 7:case"end":return _context.stop();}}},_callee);}));return function handler(){return _ref2.apply(this,arguments);};}();/**
25
+ */handler=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:event.removeCallback(APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,handler);_context.next=3;return dispatch(requestAppPermissionStatus({permissionId:permissionId}));case 3:status=_context.sent;resolve(status===PERMISSION_STATUS_GRANTED);case 5:case"end":return _context.stop();}}},_callee);}));return function handler(){return _ref2.apply(this,arguments);};}();/**
26
26
  * Register an event handler, so that we can perform the permissions check again,
27
27
  * when the user comes back from the settings.
28
28
  */event.addCallback(APP_EVENT_APPLICATION_WILL_ENTER_FOREGROUND,handler);// Open the settings (protected by a timeout, so that the modal closes before the app is left).
29
- setTimeout(function(){openAppSettings();},0);case 45:case"end":return _context2.stop();}}},_callee2);}));return function(_x){return _ref.apply(this,arguments);};}());};};export default grantPermissions;
29
+ setTimeout(function(){openAppSettings();},0);case 41:case"end":return _context2.stop();}}},_callee2);}));return function(_x){return _ref.apply(this,arguments);};}());};};export default grantPermissions;
@@ -1,4 +1,4 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{PERMISSION_ID_PUSH}from'@shopgate/pwa-core/constants/AppPermissions';import grantPermissions from"./grantPermissions";/**
1
+ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{PERMISSION_ID_PUSH}from'@shopgate/engage/core/constants';import grantPermissions from"./grantPermissions";/**
2
2
  * Determines the current state of the push permissions.
3
3
  * If not already happened, the user will be prompted to grant permissions.
4
4
  * The action returns a promise which resolves with a boolean value, that indicates the state.
@@ -19,4 +19,4 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
19
19
  * @param {string} options.modal.dismiss Label for the dismiss button.
20
20
  * @param {Object} options.modal.params Additional parameters for i18n strings.
21
21
  * @return { Function } A redux thunk.
22
- */var grantPushPermissions=function grantPushPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){var _options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?true:_options$useSettingsM,_options$useRationale=options.useRationaleModal,useRationaleModal=_options$useRationale===void 0?true:_options$useRationale,_options$modal=options.modal,modal=_options$modal===void 0?{}:_options$modal,_options$rationaleMod=options.rationaleModal,rationaleModal=_options$rationaleMod===void 0?{}:_options$rationaleMod;return dispatch(grantPermissions({permissionId:PERMISSION_ID_PUSH,useSettingsModal:useSettingsModal,useRationaleModal:useRationaleModal,modal:_extends({title:null,message:'permissions.access_denied.push_message',confirm:'permissions.access_denied.settings_button'},modal),rationaleModal:rationaleModal}));};};export default grantPushPermissions;
22
+ */var grantPushPermissions=function grantPushPermissions(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return function(dispatch){var _options$useSettingsM=options.useSettingsModal,useSettingsModal=_options$useSettingsM===void 0?false:_options$useSettingsM,_options$useRationale=options.useRationaleModal,useRationaleModal=_options$useRationale===void 0?false:_options$useRationale,_options$modal=options.modal,modal=_options$modal===void 0?{}:_options$modal,_options$rationaleMod=options.rationaleModal,rationaleModal=_options$rationaleMod===void 0?{}:_options$rationaleMod;return dispatch(grantPermissions({permissionId:PERMISSION_ID_PUSH,useSettingsModal:useSettingsModal,useRationaleModal:useRationaleModal,modal:_extends({title:null,message:'permissions.access_denied.push_message',confirm:'permissions.access_denied.settings_button'},modal),rationaleModal:rationaleModal}));};};export default grantPushPermissions;
@@ -0,0 +1 @@
1
+ export{default as getGeolocation}from"./getGeolocation";export{default as grantCameraPermissions}from"./grantCameraPermissions";export{default as grantGeolocationPermissions}from"./grantGeolocationPermissions";export{default as grantPushPermissions}from"./grantPushPermissions";export{default as requestAppPermission}from"./requestAppPermission";export{default as requestAppPermissionStatus}from"./requestAppPermissionStatus";export{default as updateStatusBarBackground}from"./updateStatusBarBackground";
@@ -0,0 +1,7 @@
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}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{requestAppPermissions}from'@shopgate/pwa-core/commands/appPermissions';import{PERMISSION_STATUS_NOT_SUPPORTED}from'@shopgate/engage/core/constants';import{appPermissionStatusReceived}from"../action-creators";/**
2
+ * Requests an additional app permission from the operating system.
3
+ * Additionally it propagates the received status via the APP_PERMISSION_STATUS_RECEIVED action.
4
+ * @param {Object} params The action params
5
+ * @param {string} params.permissionId The desired app permission id
6
+ * @returns {Function} A Redux thunk
7
+ */var requestAppPermission=function requestAppPermission(_ref){var permissionId=_ref.permissionId;return/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var _yield$requestAppPerm;var _ref3,_ref4,_ref4$,status,options;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return requestAppPermissions([{permissionId:permissionId}]);case 2:_context.t1=_yield$requestAppPerm=_context.sent;_context.t0=_context.t1!==null;if(!_context.t0){_context.next=6;break;}_context.t0=_yield$requestAppPerm!==void 0;case 6:if(!_context.t0){_context.next=10;break;}_context.t2=_yield$requestAppPerm;_context.next=11;break;case 10:_context.t2=[];case 11:_ref3=_context.t2;_ref4=_slicedToArray(_ref3,1);_ref4$=_ref4[0];_ref4$=_ref4$===void 0?{status:PERMISSION_STATUS_NOT_SUPPORTED}:_ref4$;status=_ref4$.status,options=_ref4$.options;dispatch(appPermissionStatusReceived({permissionId:permissionId,status:status,options:options}));return _context.abrupt("return",status);case 18:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}();};export default requestAppPermission;
@@ -0,0 +1,7 @@
1
+ import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}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{getAppPermissions}from'@shopgate/pwa-core/commands/appPermissions';import{PERMISSION_STATUS_NOT_SUPPORTED}from'@shopgate/engage/core/constants';import{appPermissionStatusReceived}from"../action-creators";/**
2
+ * Determines the current status of an app permission from the operating system.
3
+ * Additionally it propagates the received status via the APP_PERMISSION_STATUS_RECEIVED action.
4
+ * @param {Object} params The action params
5
+ * @param {string} params.permissionId The desired app permission id
6
+ * @returns {Function} A Redux thunk
7
+ */var requestAppPermissionStatus=function requestAppPermissionStatus(_ref){var permissionId=_ref.permissionId;return/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var _yield$getAppPermissi;var _ref3,_ref4,_ref4$,status,options;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return getAppPermissions([permissionId]);case 2:_context.t1=_yield$getAppPermissi=_context.sent;_context.t0=_context.t1!==null;if(!_context.t0){_context.next=6;break;}_context.t0=_yield$getAppPermissi!==void 0;case 6:if(!_context.t0){_context.next=10;break;}_context.t2=_yield$getAppPermissi;_context.next=11;break;case 10:_context.t2=[];case 11:_ref3=_context.t2;_ref4=_slicedToArray(_ref3,1);_ref4$=_ref4[0];_ref4$=_ref4$===void 0?{status:PERMISSION_STATUS_NOT_SUPPORTED}:_ref4$;status=_ref4$.status,options=_ref4$.options;dispatch(appPermissionStatusReceived({permissionId:permissionId,status:status,options:options}));return _context.abrupt("return",status);case 18:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}();};export default requestAppPermissionStatus;