@ordergroove/offers 2.23.1 → 2.24.1-alpha-PR-566-18.13

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 (64) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/build.js +5 -0
  3. package/dist/bundle-report.html +221 -63
  4. package/dist/examples.js +385 -1897
  5. package/dist/examples.js.map +7 -1
  6. package/dist/offers.js +266 -214
  7. package/dist/offers.js.map +7 -1
  8. package/examples/index.html +3 -0
  9. package/examples/index.js +19 -6
  10. package/karma-functional.conf.js +12 -10
  11. package/karma.conf.js +20 -10
  12. package/package.json +10 -15
  13. package/src/__tests__/offers.spec.js +111 -0
  14. package/src/__tests__/test-mode.spec.js +16 -0
  15. package/src/components/FrequencyStatus.js +2 -2
  16. package/src/components/IncentiveText.js +1 -1
  17. package/src/components/Offer.js +21 -15
  18. package/src/components/OptinButton.js +2 -5
  19. package/src/components/OptinSelect.js +2 -2
  20. package/src/components/OptinToggle.js +1 -4
  21. package/src/components/OptoutButton.js +1 -4
  22. package/src/components/Price.js +54 -0
  23. package/src/components/SelectFrequency.js +4 -8
  24. package/src/components/UpsellButton.js +2 -5
  25. package/src/components/UpsellModal.js +6 -10
  26. package/src/components/__tests__/FrequencyStatus.spec.js +33 -38
  27. package/src/components/__tests__/IncentiveText.spec.js +1 -1
  28. package/src/components/__tests__/Modal.spec.js +1 -1
  29. package/src/components/__tests__/NextUpcomingOrder.spec.js +1 -1
  30. package/src/components/__tests__/OG.fspec.js +2 -2
  31. package/src/components/__tests__/Offer.spec.js +5 -7
  32. package/src/components/__tests__/OptinButton.spec.js +1 -1
  33. package/src/components/__tests__/OptinSelect.spec.js +1 -1
  34. package/src/components/__tests__/OptinStatus.spec.js +1 -1
  35. package/src/components/__tests__/Price.fspec.js +43 -0
  36. package/src/components/__tests__/Select.spec.js +1 -1
  37. package/src/components/__tests__/SelectFrequency.spec.js +17 -6
  38. package/src/components/__tests__/Text.spec.js +1 -1
  39. package/src/components/__tests__/Tooltip.spec.js +1 -1
  40. package/src/components/__tests__/UpsellButton.spec.js +4 -6
  41. package/src/components/__tests__/When.spec.js +1 -1
  42. package/src/core/__tests__/api.spec.js +10 -3
  43. package/src/core/__tests__/base.spec.js +8 -2
  44. package/src/core/__tests__/reducer.spec.js +1 -1
  45. package/src/core/actions.js +16 -10
  46. package/src/core/adapters.js +3 -3
  47. package/src/core/api.js +4 -1
  48. package/src/core/constants.js +1 -0
  49. package/src/core/localStorage.js +1 -1
  50. package/src/core/middleware.js +9 -7
  51. package/src/core/reducer.js +10 -0
  52. package/src/core/selectors.js +19 -33
  53. package/src/index.js +187 -153
  54. package/src/init-func-tests.js +1 -2
  55. package/src/init-test.js +3 -0
  56. package/src/test-mode.js +5 -3
  57. package/dist/index.html +0 -125
  58. package/dist/offers-preview-mode.bundle.js +0 -2
  59. package/dist/offers-preview-mode.bundle.js.map +0 -1
  60. package/dist/offers-test-mode.bundle.js +0 -100
  61. package/dist/offers-test-mode.bundle.js.map +0 -1
  62. package/src/_tests_/offers.spec.js +0 -18
  63. package/src/_tests_/test-mode.spec.js +0 -15
  64. package/webpack.config.js +0 -43
@@ -55,24 +55,19 @@ export const defaultFrequenciesSelector = state => state.defaultFrequencies || {
55
55
  */
56
56
  export const makeOptedinSelector = memoize(
57
57
  product =>
58
- createSelector(
59
- optedinSelector,
60
- optedoutSelector,
61
- autoshipSelector,
62
- (optedin, optedout, autoshipByDefault) => {
63
- const entry = optedin.find(b => isSameProduct(product, b));
64
- if (entry) {
65
- return entry;
66
- }
67
- if (optedout.find(b => isSameProduct(product, b))) {
68
- return false;
69
- }
70
- if (product && autoshipByDefault[product.id]) {
71
- return { id: product.id };
72
- }
58
+ createSelector(optedinSelector, optedoutSelector, autoshipSelector, (optedin, optedout, autoshipByDefault) => {
59
+ const entry = optedin.find(b => isSameProduct(product, b));
60
+ if (entry) {
61
+ return entry;
62
+ }
63
+ if (optedout.find(b => isSameProduct(product, b))) {
73
64
  return false;
74
65
  }
75
- ),
66
+ if (product && autoshipByDefault[product.id]) {
67
+ return { id: product.id };
68
+ }
69
+ return false;
70
+ }),
76
71
  product => JSON.stringify(product)
77
72
  );
78
73
  /**
@@ -82,16 +77,13 @@ export const makeOptedinSelector = memoize(
82
77
  */
83
78
  export const makeSubscribedSelector = memoize(
84
79
  product =>
85
- createSelector(
86
- optedinSelector,
87
- optedin => {
88
- const entry = optedin.find(b => isSameProduct(product, b));
89
- if (entry) {
90
- return entry;
91
- }
92
- return false;
80
+ createSelector(optedinSelector, optedin => {
81
+ const entry = optedin.find(b => isSameProduct(product, b));
82
+ if (entry) {
83
+ return entry;
93
84
  }
94
- ),
85
+ return false;
86
+ }),
95
87
  product => JSON.stringify(product)
96
88
  );
97
89
 
@@ -101,19 +93,13 @@ export const makeSubscribedSelector = memoize(
101
93
  * @param {String} productId
102
94
  */
103
95
  export const makeOptedoutSelector = memoize(productId =>
104
- createSelector(
105
- optedoutSelector,
106
- optedout => optedout.find(b => isSameProduct(productId, b))
107
- )
96
+ createSelector(optedoutSelector, optedout => optedout.find(b => isSameProduct(productId, b)))
108
97
  );
109
98
 
110
99
  export const frequencySelector = state => state.frequency;
111
100
 
112
101
  export const makeProductFrequencySelector = memoize(productId =>
113
- createSelector(
114
- makeOptedinSelector(productId),
115
- productOptin => (productOptin && productOptin.frequency) || null
116
- )
102
+ createSelector(makeOptedinSelector(productId), productOptin => (productOptin && productOptin.frequency) || null)
117
103
  );
118
104
 
119
105
  /**
package/src/index.js CHANGED
@@ -1,172 +1,206 @@
1
- const { offersLiveEditor } = require('@ordergroove/offers-live-editor');
2
-
3
- const { setStore } = require('./core/connect');
4
- const { getStore } = require('./core/store');
5
- const { listenLocalStorageChanges } = require('./core/localStorage');
6
- const adapters = require('./core/adapters');
7
- const actions = require('./core/actions');
8
- const { ConnectedWhen } = require('./components/When');
9
- const { ConnectedOptinButton } = require('./components/OptinButton');
10
- const { ConnectedOptoutButton } = require('./components/OptoutButton');
11
- const { ConnectedOptinSelect } = require('./components/OptinSelect');
12
- const { ConnectedUpsellButton } = require('./components/UpsellButton');
13
- const { ConnectedUpsellModal } = require('./components/UpsellModal');
14
- const { ConnectedOptinToggle } = require('./components/OptinToggle');
15
- const { ConnectedOptinStatus } = require('./components/OptinStatus');
16
- const { ConnectedText } = require('./components/Text');
17
- const { ConnectedIncentiveText } = require('./components/IncentiveText');
18
- const { ConnectedSelectFrequency } = require('./components/SelectFrequency');
19
- const { ConnectedNextUpcomingOrder } = require('./components/NextUpcomingOrder');
20
- const { ConnectedOffer } = require('./components/Offer');
21
- const { Modal } = require('./components/Modal');
22
- const { Select } = require('./components/Select');
23
- const { Tooltip } = require('./components/Tooltip');
24
- const { ConnectedFrequencyStatus } = require('./components/FrequencyStatus');
25
- const testMode = require('./test-mode');
26
- const { default: api } = require('./core/api');
27
- const { environment } = require('./core/reducer');
1
+ import { offersLiveEditor } from '@ordergroove/offers-live-editor';
2
+ import { setStore } from './core/connect';
3
+ import { getStore } from './core/store';
4
+ import { listenLocalStorageChanges } from './core/localStorage';
5
+ import * as adapters from './core/adapters';
6
+ import * as actions from './core/actions';
7
+ import { ConnectedWhen } from './components/When';
8
+ import { ConnectedOptinButton } from './components/OptinButton';
9
+ import { ConnectedOptoutButton } from './components/OptoutButton';
10
+ import { ConnectedOptinSelect } from './components/OptinSelect';
11
+ import { ConnectedUpsellButton } from './components/UpsellButton';
12
+ import { ConnectedUpsellModal } from './components/UpsellModal';
13
+ import { ConnectedOptinToggle } from './components/OptinToggle';
14
+ import { ConnectedOptinStatus } from './components/OptinStatus';
15
+ import { ConnectedText } from './components/Text';
16
+ import { ConnectedIncentiveText } from './components/IncentiveText';
17
+ import { ConnectedSelectFrequency } from './components/SelectFrequency';
18
+ import { ConnectedNextUpcomingOrder } from './components/NextUpcomingOrder';
19
+ import { ConnectedOffer } from './components/Offer';
20
+ import { Modal } from './components/Modal';
21
+ import { Select } from './components/Select';
22
+ import { Tooltip } from './components/Tooltip';
23
+ import { ConnectedFrequencyStatus } from './components/FrequencyStatus';
24
+ import * as testMode from './test-mode';
25
+ import { api } from './core/api';
26
+ import { environment, offer } from './core/reducer';
27
+ import { RECEIVE_PRODUCT_PLANS } from './core/constants';
28
+ import ConnectedPrice from './components/Price';
28
29
 
29
30
  testMode.enable();
30
31
  let store;
31
- const offers = {
32
- setEnvironment(e) {
33
- store.dispatch(actions.setEnvironment(e));
34
- return offers;
35
- },
36
- setMerchantId(m) {
37
- store.dispatch(actions.setMerchantId(m));
38
- return offers;
39
- },
40
- setAuthUrl(authUrl) {
41
- store.dispatch(actions.setAuthUrl(authUrl));
42
- return offers;
43
- },
44
- getProductsForPurchasePost(productIds = []) {
45
- return adapters.getProductsForPurchasePost(store.getState(), productIds);
46
- },
47
- getOptins(productIds = []) {
48
- return adapters.getProductsForPurchasePost(store.getState(), productIds);
49
- },
50
- clear() {
51
- store.dispatch(actions.checkout());
52
- },
53
- addOptinChangedCallback(fn) {
54
- if (typeof fn === 'function') document.addEventListener('optin-changed', e => fn(e.detail));
55
- },
56
- disableOptinChangedCallbacks() {
57
- document.addEventListener('optin-changed', e => e.stopPropagation(), true);
58
- },
59
- register() {
60
- try {
61
- customElements.define('og-when', ConnectedWhen);
62
- customElements.define('og-text', ConnectedText);
63
- customElements.define('og-incentive-text', ConnectedIncentiveText);
64
- customElements.define('og-offer', ConnectedOffer);
65
- customElements.define('og-select-frequency', ConnectedSelectFrequency);
66
- customElements.define('og-optout-button', ConnectedOptoutButton);
67
- customElements.define('og-optin-toggle', ConnectedOptinToggle);
68
- customElements.define('og-optin-status', ConnectedOptinStatus);
69
- customElements.define('og-optin-button', ConnectedOptinButton);
70
- customElements.define('og-optin-select', ConnectedOptinSelect);
71
- customElements.define('og-upsell-button', ConnectedUpsellButton);
72
- customElements.define('og-frequency-status', ConnectedFrequencyStatus);
73
- customElements.define('og-modal', Modal);
74
- customElements.define('og-select', Select);
75
- customElements.define('og-tooltip', Tooltip);
76
- customElements.define('og-upsell-modal', ConnectedUpsellModal);
77
- customElements.define('og-next-upcoming-order', ConnectedNextUpcomingOrder);
78
- } catch (err) {
79
- // eslint-disable-next-line no-console
80
- console.error(err);
81
- }
82
- offers.register = () => 0;
83
- },
84
- previewMode(set) {
85
- window.og = window.og || {};
86
- if (set === false) {
87
- delete window.og;
88
- } else {
89
- window.og.previewMode = true;
32
+
33
+ export const offers = {};
34
+
35
+ export function setEnvironment(e) {
36
+ store.dispatch(actions.setEnvironment(e));
37
+ return offers;
38
+ }
39
+ export function setMerchantId(m) {
40
+ store.dispatch(actions.setMerchantId(m));
41
+ return offers;
42
+ }
43
+ export function setAuthUrl(authUrl) {
44
+ store.dispatch(actions.setAuthUrl(authUrl));
45
+ return offers;
46
+ }
47
+ export function getProductsForPurchasePost(productIds = []) {
48
+ return adapters.getProductsForPurchasePost(store.getState(), productIds);
49
+ }
50
+ export function getOptins(productIds = []) {
51
+ return adapters.getProductsForPurchasePost(store.getState(), productIds);
52
+ }
53
+ export function clear() {
54
+ store.dispatch(actions.checkout());
55
+ }
56
+ export function addOptinChangedCallback(fn) {
57
+ if (typeof fn === 'function') document.addEventListener('optin-changed', e => fn(e.detail));
58
+ }
59
+ export function disableOptinChangedCallbacks() {
60
+ document.addEventListener('optin-changed', e => e.stopPropagation(), true);
61
+ }
62
+ export function register() {
63
+ try {
64
+ customElements.define('og-when', ConnectedWhen);
65
+ customElements.define('og-text', ConnectedText);
66
+ customElements.define('og-incentive-text', ConnectedIncentiveText);
67
+ customElements.define('og-offer', ConnectedOffer);
68
+ customElements.define('og-select-frequency', ConnectedSelectFrequency);
69
+ customElements.define('og-optout-button', ConnectedOptoutButton);
70
+ customElements.define('og-optin-toggle', ConnectedOptinToggle);
71
+ customElements.define('og-optin-status', ConnectedOptinStatus);
72
+ customElements.define('og-optin-button', ConnectedOptinButton);
73
+ customElements.define('og-optin-select', ConnectedOptinSelect);
74
+ customElements.define('og-upsell-button', ConnectedUpsellButton);
75
+ customElements.define('og-frequency-status', ConnectedFrequencyStatus);
76
+ customElements.define('og-modal', Modal);
77
+ customElements.define('og-select', Select);
78
+ customElements.define('og-tooltip', Tooltip);
79
+ customElements.define('og-upsell-modal', ConnectedUpsellModal);
80
+ customElements.define('og-next-upcoming-order', ConnectedNextUpcomingOrder);
81
+ customElements.define('og-price', ConnectedPrice);
82
+ } catch (err) {
83
+ // eslint-disable-next-line no-console
84
+ console.warn(err);
85
+ }
86
+ offers.register = () => 0;
87
+ }
88
+ export function previewMode(set) {
89
+ window.og = window.og || {};
90
+ if (set === false) {
91
+ delete window.og;
92
+ } else {
93
+ window.og.previewMode = true;
94
+ }
95
+ return this;
96
+ }
97
+ export function config(configuration) {
98
+ store.dispatch(actions.setConfig(configuration));
99
+ return offers;
100
+ }
101
+ export function setLocale(locale) {
102
+ store.dispatch(actions.setLocale(locale));
103
+ return offers;
104
+ }
105
+ export function addTemplate(tagName, content, configOption) {
106
+ store.dispatch(actions.addTemplate(tagName, content, configOption));
107
+ return offers;
108
+ }
109
+ /**
110
+ * templates object where keys are selectors and values are content
111
+ */
112
+ export function setTemplates(templates) {
113
+ store.dispatch(actions.setTemplates(templates));
114
+ return offers;
115
+ }
116
+ export function setPublicPath(publicPath) {
117
+ return offers;
118
+ }
119
+ export function resolveSettings(merchantId, env, settings, storeInstance = store) {
120
+ if (merchantId && env && settings) {
121
+ let products = [];
122
+ if (settings.product) {
123
+ products.push(settings.product);
124
+ } else if (settings.cart && Array.isArray(settings.cart.products)) {
125
+ products = products.concat(settings.cart.products);
90
126
  }
91
- return this;
92
- },
93
- /**
94
- * Initialize OG object
95
- * @param {*} merchantId
96
- * @param {*} env
97
- * @param {*} authUrl
98
- */
99
- initialize(merchantId, env, authUrl) {
100
- if (offers.isReady) {
101
- console.warn('og.offers has been initialized already. Skipping.');
102
- return offers;
127
+ const { apiUrl } = environment({}, actions.setEnvironment(env));
128
+ const { sessionId } = storeInstance.getState();
129
+ if (sessionId) {
130
+ products.forEach(product => {
131
+ api.fetchOffer(apiUrl, merchantId, sessionId, `${product}`, 'pdp');
132
+ });
103
133
  }
104
- store = getStore();
105
-
106
- const settings = window.og_settings;
107
- if (merchantId && env && settings) {
108
- let products = [];
109
- if (settings.product) {
110
- products.push(settings.product);
111
- } else if (settings.cart && Array.isArray(settings.cart.products)) {
112
- products = products.concat(settings.cart.products);
113
- }
114
- const { apiUrl } = environment({}, actions.setEnvironment(env));
115
- const { sessionId } = store.getState();
116
- if (sessionId) {
117
- products.forEach(product => api.fetchOffer(apiUrl, merchantId, sessionId, `${product}`, 'pdp'));
118
- }
134
+
135
+ if (settings.product_discounts && typeof settings.product_discounts === 'object') {
136
+ storeInstance.dispatch({ type: RECEIVE_PRODUCT_PLANS, payload: settings.product_discounts });
119
137
  }
138
+ }
139
+ }
120
140
 
121
- setStore(store);
122
- if (merchantId) offers.setMerchantId(merchantId);
123
- if (env) offers.setEnvironment(env);
124
- if (authUrl) offers.setAuthUrl(authUrl);
141
+ /**
142
+ * Initialize OG object
143
+ * @param {*} merchantId
144
+ * @param {*} env
145
+ * @param {*} authUrl
146
+ */
147
+ export function initialize(merchantId, env, authUrl) {
148
+ if (offers.isReady) {
149
+ console.warn('og.offers has been initialized already. Skipping.');
150
+ return offers;
151
+ }
125
152
 
126
- window.addEventListener('storage', listenLocalStorageChanges(store));
153
+ store = getStore();
127
154
 
128
- if (merchantId && env) {
129
- store.dispatch(actions.requestSessionId());
130
- store.dispatch(actions.fetchAuth());
131
- offers.register();
132
- }
155
+ offers.store = store;
156
+ offers.resolveSettings(merchantId, env, window.og_settings, store);
133
157
 
134
- offers.isReady = true;
158
+ setStore(store);
135
159
 
136
- return offers;
137
- },
160
+ if (merchantId) offers.setMerchantId(merchantId);
161
+ if (env) offers.setEnvironment(env);
162
+ if (authUrl) offers.setAuthUrl(authUrl);
138
163
 
139
- config(configuration) {
140
- store.dispatch(actions.setConfig(configuration));
141
- return offers;
142
- },
143
- setLocale(locale) {
144
- store.dispatch(actions.setLocale(locale));
145
- return offers;
146
- },
147
- addTemplate(tagName, content, config) {
148
- store.dispatch(actions.addTemplate(tagName, content, config));
149
- return offers;
150
- },
151
- /**
152
- * templates object where keys are selectors and values are content
153
- */
154
- setTemplates(templates) {
155
- store.dispatch(actions.setTemplates(templates));
156
- return offers;
157
- },
158
- setPublicPath(publicPath) {
159
- /* eslint-disable camelcase, no-undef */
160
- __webpack_require__.p = publicPath;
161
- /* eslint-enable */
162
- return offers;
164
+ window.addEventListener('storage', listenLocalStorageChanges(store));
165
+
166
+ if (merchantId && env) {
167
+ store.dispatch(actions.requestSessionId());
168
+ store.dispatch(actions.fetchAuth());
169
+ offers.register();
163
170
  }
164
- };
171
+
172
+ offers.isReady = true;
173
+
174
+ return offers;
175
+ }
176
+
177
+ export default initialize;
178
+
179
+ Object.assign(offers, {
180
+ setEnvironment,
181
+ setMerchantId,
182
+ setAuthUrl,
183
+ getProductsForPurchasePost,
184
+ getOptins,
185
+ clear,
186
+ addOptinChangedCallback,
187
+ disableOptinChangedCallbacks,
188
+ register,
189
+ previewMode,
190
+ config,
191
+ setLocale,
192
+ addTemplate,
193
+ setTemplates,
194
+ setPublicPath,
195
+ resolveSettings,
196
+ initialize
197
+ });
198
+
165
199
  window.OG = window.OG || {};
166
200
  Object.assign(window.OG, offers);
167
201
  Object.assign(offers.initialize, offers);
168
202
 
169
203
  offersLiveEditor();
170
204
 
171
- // use this syntax to allow es6 module be called as default function og.offers(...)
172
- module.exports = offers.initialize;
205
+ // // use this syntax to allow es6 module be called as default function og.offers(...)
206
+ // module.exports = offers.initialize;
@@ -1,5 +1,4 @@
1
- const og = window.og;
2
1
  window.OG_SAVE_TO_LOCAL_TIMEOUT = 1;
3
2
  window.merchantId = '12345678901234567890123456789012';
4
3
  window.env = 'staging';
5
- og.offers(window.merchantId, window.env, 0);
4
+ window.og.offers.initialize(window.merchantId, window.env, 0);
@@ -0,0 +1,3 @@
1
+ import { initialize } from './index';
2
+
3
+ initialize('some-merchant', 'staging');
package/src/test-mode.js CHANGED
@@ -1,3 +1,5 @@
1
+ import runTests from './run-tests';
2
+
1
3
  export const keys = [
2
4
  79, // O
3
5
  71, // G
@@ -7,6 +9,8 @@ export const keys = [
7
9
  ];
8
10
 
9
11
  export const enable = () => {
12
+ if (window.OG_OFFERS_TEST_MODE_ENABLE) return;
13
+ window.OG_OFFERS_TEST_MODE_ENABLE = true;
10
14
  let keysCounter = 0;
11
15
  document.addEventListener(
12
16
  'keyup',
@@ -19,9 +23,7 @@ export const enable = () => {
19
23
  }, 5000);
20
24
  keysCounter += 1;
21
25
  if (keysCounter >= keys.length) {
22
- import(/* webpackChunkName: "offers-test-mode" */ './run-tests.js').then(({ default: runTests }) => {
23
- runTests();
24
- });
26
+ runTests();
25
27
  }
26
28
  } else {
27
29
  keysCounter = 0;
package/dist/index.html DELETED
@@ -1,125 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Ordergroove Offers</title>
5
- <style type="text/css">
6
- body {
7
- font-family: Arial;
8
- }
9
- fieldset {
10
- width: 80%;
11
- margin: auto auto 2em;
12
- padding: 1em;
13
- border: 1px solid #ccc;
14
- border-radius: 0.5em;
15
- }
16
-
17
- hr {
18
- margin: 1em 0;
19
- border: none;
20
- border-top: 1px solid #ccc;
21
- }
22
- #the-content {
23
- display: flex;
24
- flex-wrap: wrap;
25
- }
26
- #choose-offer,
27
- #the-code,
28
- #the-js {
29
- outline: none;
30
- height: 100vh;
31
- font-size: 13px;
32
- padding: 5px;
33
- border: none;
34
- border-right: 1px solid #ccc;
35
- box-sizing: border-box;
36
- cursor: pointer;
37
- }
38
- #the-offer {
39
- padding: 50px;
40
- width: 50vw;
41
- }
42
-
43
- #the-code {
44
- flex: 1 0;
45
- }
46
- #choose-offer option {
47
- padding: 5px;
48
- padding: 10px;
49
- border-radius: 5px;
50
- }
51
- #the-js {
52
- padding: 2px;
53
- font-family: monospace;
54
- }
55
- #the-html {
56
- width: 100%;
57
- }
58
- #the-js {
59
- border: none;
60
- width: 49%;
61
- float: right;
62
- height: 400px;
63
- }
64
- #preview-mode {
65
- position: absolute;
66
- left: 260px;
67
- }
68
- </style>
69
- <style type="text/css" id="offersGlobalCss">
70
- og-offer {
71
- --og-global-family: Tahoma;
72
- --og-global-size: 14px;
73
- --og-global-color: blue;
74
-
75
- --og-tooltip-family: Arial, Helvetica, sans-serif;
76
- --og-tooltip-size: 10px;
77
- --og-tooltip-color: rgba(245, 166, 35, 1);
78
-
79
- --og-upsell-background: rgba(202, 25, 148, 1);
80
- --og-upsell-family: Arial, Helvetica, sans-serif;
81
- --og-upsell-size: 13px;
82
- --og-upsell-color: rgba(231, 12, 12, 1);
83
-
84
- --og-modal-button-family: Arial, Helvetica, sans-serif;
85
- --og-modal-button-size: 13px;
86
- --og-modal-button-color: #333333;
87
- --og-confirm-button-background: #00449e;
88
- --og-confirm-button-color: rgba(216, 54, 54, 1);
89
- --og-modal-button-background: #e6e6e6;
90
- --og-upsell-color: rgba(80, 227, 194, 1);
91
- --og-modal-button-font-family: Arial, Helvetica, sans-serif;
92
- --og-modal-button-font-size: 25px;
93
- --og-modal-button-font-color: rgba(107, 6, 128, 1);
94
- --og-confirm-button-background-color: rgba(192, 205, 223, 1);
95
- --og-modal-button-background-color: rgba(135, 224, 33, 1);
96
- }
97
- .tooltip-example {
98
- display: inline-block;
99
- border: 2px dashed blue;
100
- margin: 3px;
101
- width: 100px;
102
- height: 20px;
103
- padding: 5px;
104
- }
105
- </style>
106
- </head>
107
- <body>
108
- <div id="the-content">
109
- <select id="choose-offer" multiple></select>
110
- <select id="preview-mode">
111
- <option>regular</option>
112
- <option>upsell</option>
113
- <option>subscribed</option>
114
- <option>not-subscribed</option>
115
- </select>
116
-
117
- <div id="the-offer">
118
- <og-offer product="UD729" id="regular1" preview="regular"></og-offer>
119
- </div>
120
- </div>
121
-
122
- <pre id="the-html"></pre>
123
- <textarea id="the-js" readonly></textarea>
124
- <script type="text/javascript" src="offers.js"></script><script type="text/javascript" src="examples.js"></script></body>
125
- </html>
@@ -1,2 +0,0 @@
1
- (window.webpackJsonp=window.webpackJsonp||[]).push([[2],{54:function(e,t,a){"use strict";a.r(t),a.d(t,"setPreviewStandardOffer",(function(){return r})),a.d(t,"setPreviewUpsellOffer",(function(){return s})),a.d(t,"setPreview",(function(){return n}));var c=a(3),i=a(0);const r=(e,t)=>async function(a){await a({type:i.F,payload:e}),await a({type:i.J}),await a(Object(c.receiveOffer)({in_stock:{[t]:!0},eligibility_groups:{[t]:["subscription","upsell"]},result:"success",autoship:{[t]:!0},modifiers:{},module_view:{regular:"096135e6650111e9a444bc764e106cf4"},incentives_display:{"47c01e9aacbe40389b5c7325d79091aa":{field:"sub_total",object:"order",type:"Discount Percent",value:5},e6534b9d877f41e586c37b7d8abc3a58:{field:"total_price",object:"item",type:"Discount Percent",value:10},f35e842710b24929922db4a529eecd40:{field:"total_price",object:"item",type:"Discount Percent",value:10},"5be321d7c17f4e18a757212b9a20bfcc":{field:"total_price",object:"item",type:"Discount Percent",value:1}},incentives:{[t]:{initial:["5be321d7c17f4e18a757212b9a20bfcc"],ongoing:["e6534b9d877f41e586c37b7d8abc3a58","47c01e9aacbe40389b5c7325d79091aa","f35e842710b24929922db4a529eecd40"]}}}))},s=(e,t)=>async function(a,r){await a({type:i.G,payload:e});const{merchantId:s}=r();e?(await a(Object(c.receiveOffer)({in_stock:{[t]:!0},module_view:{regular:"096135e6650111e9a444bc764e106cf4"},default_frequencies:{[t]:{every:1,every_period:3}},eligibility_groups:{[t]:["subscription","upsell"]},result:"success",autoship:{[t]:!0},modifiers:{}})),await a(Object(c.receiveOrders)({count:1,next:null,previous:null,results:[{merchant:"0e5de2bedc5e11e3a2e4bc764e106cf4",customer:"TestCust",payment:"e98e789aba0111e9b90fbc764e107990",shipping_address:"b3a5816ae59611e78937bc764e1043b0",public_id:"23322d4a83eb11ea9a1ebc764e101db1",sub_total:"206.98",tax_total:"0.00",shipping_total:"10.00",discount_total:"0.00",total:"216.98",created:"2020-04-21 11:14:11",place:"2020-06-24 00:00:00",cancelled:null,tries:0,generic_error_count:0,status:1,type:1,order_merchant_id:null,rejected_message:null,extra_data:null,locked:!1,oos_free_shipping:!1}]})),await a(Object(c.authorize)(s,"sig_field","ts","sig"))):await a(Object(c.unauthorized)())},n=(e,t,a)=>async function(t,n){switch(await t({type:i.j}),await t({type:i.F,payload:!1}),await t({type:i.G,payload:!1}),e){case"regular":t(r(!0,a.product.id));break;case"upsell":t(s(!0,a.product.id));break;case"subscribed":t(r(!0,a.product.id)),t(Object(c.optinProduct)(a.product,"2_2"))}}}}]);
2
- //# sourceMappingURL=offers-preview-mode.bundle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["webpack://og.[name]/./src/core/actions-preview.js"],"names":["setPreviewStandardOffer","isPreview","productId","async","dispatch","type","payload","in_stock","eligibility_groups","result","autoship","modifiers","module_view","regular","incentives_display","field","object","value","e6534b9d877f41e586c37b7d8abc3a58","f35e842710b24929922db4a529eecd40","incentives","initial","ongoing","setPreviewUpsellOffer","getState","merchantId","default_frequencies","every","every_period","count","next","previous","results","merchant","customer","payment","shipping_address","public_id","sub_total","tax_total","shipping_total","discount_total","total","created","place","cancelled","tries","generic_error_count","status","order_merchant_id","rejected_message","extra_data","locked","oos_free_shipping","setPreview","oldValue","ownProps","product","id"],"mappings":"yFAAA,kLAGO,MAAMA,EAA0B,CAACC,EAAWC,IACjDC,eAA4CC,SACpCA,EAAS,CACbC,KAAM,IACNC,QAASL,UAELG,EAAS,CACbC,KAAM,YAEFD,EACJ,uBAAa,CACXG,SAAU,CAAE,CAACL,IAAY,GACzBM,mBAAoB,CAAE,CAACN,GAAY,CAAC,eAAgB,WACpDO,OAAQ,UACRC,SAAU,CAAE,CAACR,IAAY,GACzBS,UAAW,GACXC,YAAa,CAAEC,QAAS,oCACxBC,mBAAoB,CAClB,mCAAoC,CAClCC,MAAO,YACPC,OAAQ,QACRX,KAAM,mBACNY,MAAO,GAETC,iCAAkC,CAChCH,MAAO,cACPC,OAAQ,OACRX,KAAM,mBACNY,MAAO,IAETE,iCAAkC,CAChCJ,MAAO,cACPC,OAAQ,OACRX,KAAM,mBACNY,MAAO,IAET,mCAAoC,CAClCF,MAAO,cACPC,OAAQ,OACRX,KAAM,mBACNY,MAAO,IAGXG,WAAY,CACV,CAAClB,GAAY,CACXmB,QAAS,CAAC,oCACVC,QAAS,CACP,mCACA,mCACA,0CAQDC,EAAwB,CAACtB,EAAWC,IAC/CC,eAA0CC,EAAUoB,SAC5CpB,EAAS,CAAEC,KAAM,IAAoCC,QAASL,IAEpE,MAAM,WAAEwB,GAAeD,IACnBvB,SACIG,EACJ,uBAAa,CACXG,SAAU,CAAE,CAACL,IAAY,GACzBU,YAAa,CAAEC,QAAS,oCACxBa,oBAAqB,CAAE,CAACxB,GAAY,CAAEyB,MAAO,EAAGC,aAAc,IAC9DpB,mBAAoB,CAAE,CAACN,GAAY,CAAC,eAAgB,WACpDO,OAAQ,UACRC,SAAU,CAAE,CAACR,IAAY,GACzBS,UAAW,YAGTP,EACJ,wBAAc,CACZyB,MAAO,EACPC,KAAM,KACNC,SAAU,KACVC,QAAS,CACP,CACEC,SAAU,mCACVC,SAAU,WACVC,QAAS,mCACTC,iBAAkB,mCAClBC,UAAW,mCACXC,UAAW,SACXC,UAAW,OACXC,eAAgB,QAChBC,eAAgB,OAChBC,MAAO,SACPC,QAAS,sBACTC,MAAO,sBACPC,UAAW,KACXC,MAAO,EACPC,oBAAqB,EACrBC,OAAQ,EACR3C,KAAM,EACN4C,kBAAmB,KACnBC,iBAAkB,KAClBC,WAAY,KACZC,QAAQ,EACRC,mBAAmB,aAKrBjD,EAAS,oBAAUqB,EAAY,YAAa,KAAM,eAElDrB,EAAS,2BAIRkD,EAAa,CAACrC,EAAOsC,EAAUC,IAC1CrD,eAAeC,EAAUoB,GAWvB,aAVMpB,EAAS,CAAEC,KAAM,YACjBD,EAAS,CACbC,KAAM,IACNC,SAAS,UAELF,EAAS,CACbC,KAAM,IACNC,SAAS,IAGHW,GACN,IAAK,UACHb,EAASJ,GAAwB,EAAMwD,EAASC,QAAQC,KACxD,MACF,IAAK,SACHtD,EAASmB,GAAsB,EAAMiC,EAASC,QAAQC,KACtD,MACF,IAAK,aACHtD,EAASJ,GAAwB,EAAMwD,EAASC,QAAQC,KACxDtD,EAAS,uBAAaoD,EAASC,QAAS","file":"offers-preview-mode.bundle.js","sourcesContent":["import { receiveOffer, receiveOrders, authorize, unauthorized, optinProduct, optoutProduct } from './actions';\nimport * as constants from './constants';\n\nexport const setPreviewStandardOffer = (isPreview, productId) =>\n async function setPreviewStandardOfferThunk(dispatch) {\n await dispatch({\n type: constants.SET_PREVIEW_STANDARD_OFFER,\n payload: isPreview\n });\n await dispatch({\n type: constants.UNAUTHORIZED\n });\n await dispatch(\n receiveOffer({\n in_stock: { [productId]: true },\n eligibility_groups: { [productId]: ['subscription', 'upsell'] },\n result: 'success',\n autoship: { [productId]: true },\n modifiers: {},\n module_view: { regular: '096135e6650111e9a444bc764e106cf4' },\n incentives_display: {\n '47c01e9aacbe40389b5c7325d79091aa': {\n field: 'sub_total',\n object: 'order',\n type: 'Discount Percent',\n value: 5\n },\n e6534b9d877f41e586c37b7d8abc3a58: {\n field: 'total_price',\n object: 'item',\n type: 'Discount Percent',\n value: 10\n },\n f35e842710b24929922db4a529eecd40: {\n field: 'total_price',\n object: 'item',\n type: 'Discount Percent',\n value: 10\n },\n '5be321d7c17f4e18a757212b9a20bfcc': {\n field: 'total_price',\n object: 'item',\n type: 'Discount Percent',\n value: 1\n }\n },\n incentives: {\n [productId]: {\n initial: ['5be321d7c17f4e18a757212b9a20bfcc'],\n ongoing: [\n 'e6534b9d877f41e586c37b7d8abc3a58',\n '47c01e9aacbe40389b5c7325d79091aa',\n 'f35e842710b24929922db4a529eecd40'\n ]\n }\n }\n })\n );\n };\n\nexport const setPreviewUpsellOffer = (isPreview, productId) =>\n async function setPreviewUpsellOfferThunk(dispatch, getState) {\n await dispatch({ type: constants.SET_PREVIEW_UPSELL_OFFER, payload: isPreview });\n\n const { merchantId } = getState();\n if (isPreview) {\n await dispatch(\n receiveOffer({\n in_stock: { [productId]: true },\n module_view: { regular: '096135e6650111e9a444bc764e106cf4' },\n default_frequencies: { [productId]: { every: 1, every_period: 3 } },\n eligibility_groups: { [productId]: ['subscription', 'upsell'] },\n result: 'success',\n autoship: { [productId]: true },\n modifiers: {}\n })\n );\n await dispatch(\n receiveOrders({\n count: 1,\n next: null,\n previous: null,\n results: [\n {\n merchant: '0e5de2bedc5e11e3a2e4bc764e106cf4',\n customer: 'TestCust',\n payment: 'e98e789aba0111e9b90fbc764e107990',\n shipping_address: 'b3a5816ae59611e78937bc764e1043b0',\n public_id: '23322d4a83eb11ea9a1ebc764e101db1',\n sub_total: '206.98',\n tax_total: '0.00',\n shipping_total: '10.00',\n discount_total: '0.00',\n total: '216.98',\n created: '2020-04-21 11:14:11',\n place: '2020-06-24 00:00:00',\n cancelled: null,\n tries: 0,\n generic_error_count: 0,\n status: 1,\n type: 1,\n order_merchant_id: null,\n rejected_message: null,\n extra_data: null,\n locked: false,\n oos_free_shipping: false\n }\n ]\n })\n );\n await dispatch(authorize(merchantId, 'sig_field', 'ts', 'sig'));\n } else {\n await dispatch(unauthorized());\n }\n };\n\nexport const setPreview = (value, oldValue, ownProps) =>\n async function(dispatch, getState) {\n await dispatch({ type: constants.LOCAL_STORAGE_CLEAR });\n await dispatch({\n type: constants.SET_PREVIEW_STANDARD_OFFER,\n payload: false\n });\n await dispatch({\n type: constants.SET_PREVIEW_UPSELL_OFFER,\n payload: false\n });\n\n switch (value) {\n case 'regular':\n dispatch(setPreviewStandardOffer(true, ownProps.product.id));\n break;\n case 'upsell':\n dispatch(setPreviewUpsellOffer(true, ownProps.product.id));\n break;\n case 'subscribed':\n dispatch(setPreviewStandardOffer(true, ownProps.product.id));\n dispatch(optinProduct(ownProps.product, '2_2'));\n break;\n default:\n }\n };\n"],"sourceRoot":""}