@ordergroove/offers 2.23.1 → 2.24.1

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 (58) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/build.js +5 -0
  3. package/dist/bundle-report.html +220 -63
  4. package/dist/examples.js +385 -1897
  5. package/dist/examples.js.map +7 -1
  6. package/dist/offers.js +251 -214
  7. package/dist/offers.js.map +7 -1
  8. package/examples/index.html +3 -0
  9. package/examples/index.js +4 -4
  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_ → __tests__}/offers.spec.js +3 -5
  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 +11 -14
  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/SelectFrequency.js +4 -8
  23. package/src/components/UpsellButton.js +2 -5
  24. package/src/components/UpsellModal.js +6 -10
  25. package/src/components/__tests__/FrequencyStatus.spec.js +33 -38
  26. package/src/components/__tests__/IncentiveText.spec.js +1 -1
  27. package/src/components/__tests__/Modal.spec.js +1 -1
  28. package/src/components/__tests__/NextUpcomingOrder.spec.js +1 -1
  29. package/src/components/__tests__/Offer.spec.js +5 -7
  30. package/src/components/__tests__/OptinButton.spec.js +1 -1
  31. package/src/components/__tests__/OptinSelect.spec.js +1 -1
  32. package/src/components/__tests__/OptinStatus.spec.js +1 -1
  33. package/src/components/__tests__/Select.spec.js +1 -1
  34. package/src/components/__tests__/SelectFrequency.spec.js +17 -6
  35. package/src/components/__tests__/Text.spec.js +1 -1
  36. package/src/components/__tests__/Tooltip.spec.js +1 -1
  37. package/src/components/__tests__/UpsellButton.spec.js +4 -6
  38. package/src/components/__tests__/When.spec.js +1 -1
  39. package/src/core/__tests__/api.spec.js +10 -3
  40. package/src/core/__tests__/base.spec.js +8 -2
  41. package/src/core/__tests__/reducer.spec.js +1 -1
  42. package/src/core/actions.js +9 -6
  43. package/src/core/adapters.js +3 -3
  44. package/src/core/api.js +4 -1
  45. package/src/core/localStorage.js +1 -1
  46. package/src/core/middleware.js +9 -7
  47. package/src/core/selectors.js +19 -33
  48. package/src/index.js +1 -4
  49. package/src/init-func-tests.js +1 -2
  50. package/src/init-test.js +3 -0
  51. package/src/test-mode.js +5 -3
  52. package/dist/index.html +0 -125
  53. package/dist/offers-preview-mode.bundle.js +0 -2
  54. package/dist/offers-preview-mode.bundle.js.map +0 -1
  55. package/dist/offers-test-mode.bundle.js +0 -100
  56. package/dist/offers-test-mode.bundle.js.map +0 -1
  57. package/src/_tests_/test-mode.spec.js +0 -15
  58. package/webpack.config.js +0 -43
@@ -147,16 +147,27 @@ describe('frequencyEquals', () => {
147
147
  const underTest = frequencyEquals;
148
148
 
149
149
  it('should return false given null arguments', () => {
150
- [[null, { every: 1, period: 1 }], [{ every: 1, period: 1 }, null], [null, null]].forEach(args =>
151
- expect(underTest(...args)).toBe(false)
152
- );
150
+ [
151
+ [null, { every: 1, period: 1 }],
152
+ [{ every: 1, period: 1 }, null],
153
+ [null, null]
154
+ ].forEach(args => expect(underTest(...args)).toBe(false));
153
155
  });
154
156
 
155
157
  it('should return false given frequencies are not same', () => {
156
158
  [
157
- [{ every: 1, period: 1 }, { every: 1, period: 2 }],
158
- [{ every: 1, period: 1 }, { every: 2, period: 1 }],
159
- [{ every: 1, period: 1 }, { every: 2, period: 2 }]
159
+ [
160
+ { every: 1, period: 1 },
161
+ { every: 1, period: 2 }
162
+ ],
163
+ [
164
+ { every: 1, period: 1 },
165
+ { every: 2, period: 1 }
166
+ ],
167
+ [
168
+ { every: 1, period: 1 },
169
+ { every: 2, period: 2 }
170
+ ]
160
171
  ].forEach(args => expect(underTest(...args)).toBe(false));
161
172
  });
162
173
 
@@ -1,7 +1,7 @@
1
1
  import { Text } from '../Text';
2
2
  import { appendToBody } from './utils';
3
3
 
4
- customElements.define('og-text', Text);
4
+ customElements.define('og-text-test', Text);
5
5
 
6
6
  describe('Text', () => {
7
7
  it('should show the i18n text matching the key', async () => {
@@ -1,7 +1,7 @@
1
1
  import { Tooltip } from '../Tooltip';
2
2
  import { appendToBody } from './utils';
3
3
 
4
- customElements.define('og-tooltip', Tooltip);
4
+ customElements.define('og-tooltip-test', Tooltip);
5
5
 
6
6
  describe('Tooltip', () => {
7
7
  it('should render content div with correct position class', async () => {
@@ -1,24 +1,22 @@
1
1
  import { appendToBody } from './utils';
2
2
  import { UpsellButton } from '../UpsellButton';
3
- import { UpsellModal } from '../UpsellModal';
4
3
 
5
- customElements.define('og-upsell-button', UpsellButton);
6
- customElements.define('og-upsell-modal', UpsellModal);
4
+ customElements.define('og-upsell-button-test', UpsellButton);
7
5
 
8
6
  describe('UpsellButton', () => {
9
7
  it('should call fetchOrders given auth, no upcomingOrderDate', async () => {
10
8
  const element = new UpsellButton();
11
- element.auth = {};
12
9
  element.fetchOrders = jasmine.createSpy('fetchOrders');
10
+ element.auth = {};
13
11
  await appendToBody(element);
14
12
  expect(element.fetchOrders).toHaveBeenCalledWith();
15
13
  });
16
14
 
17
15
  it('should not call fetchOrders given auth and upcomingOrderDate', async () => {
18
16
  const element = new UpsellButton();
17
+ element.fetchOrders = jasmine.createSpy('fetchOrders');
19
18
  element.auth = {};
20
19
  element.upcomingOrderDate = 'yum date';
21
- element.fetchOrders = jasmine.createSpy('fetchOrders');
22
20
  await appendToBody(element);
23
21
  expect(element.fetchOrders).not.toHaveBeenCalled();
24
22
  });
@@ -44,7 +42,7 @@ describe('UpsellButton', () => {
44
42
  it('should open og-upsell-modal found in the offer', async () => {
45
43
  const ogOffer = document.createElement('og-offer');
46
44
  const ogUpsellButton = new UpsellButton();
47
- const ogUpsellModal = new UpsellModal();
45
+ const ogUpsellModal = document.createElement('og-upsell-modal');
48
46
 
49
47
  ogOffer.appendChild(ogUpsellButton);
50
48
  ogOffer.appendChild(ogUpsellModal);
@@ -10,7 +10,7 @@ class When extends WhenBase {
10
10
  return this._product;
11
11
  }
12
12
  }
13
- customElements.define('og-when', When);
13
+ customElements.define('og-when-test', When);
14
14
 
15
15
  describe('Conditional', () => {
16
16
  it('should not render child given test result is false', async () => {
@@ -1,6 +1,8 @@
1
- import { MATCHED, fetchMock } from 'fetch-mock';
1
+ import fetchMock from 'fetch-mock';
2
+
2
3
  import { api, toQuery, withFetchJson, withAuth, withHost, parseFrequency } from '../api';
3
4
 
5
+ const MATCHED = fetchMock.MATCHED;
4
6
  describe('api.fetchOffer', () => {
5
7
  describe('test request', () => {
6
8
  beforeEach(() => fetchMock.get('*', {}));
@@ -11,7 +13,7 @@ describe('api.fetchOffer', () => {
11
13
  expect(typeof api.fetchOffer).toEqual('function');
12
14
  });
13
15
 
14
- it('shoud throw if no arguments', () => {
16
+ it('should throw if no arguments', () => {
15
17
  expect(() => {
16
18
  api.fetchOffer();
17
19
  }).toThrow(new Error('host required'));
@@ -175,7 +177,12 @@ describe('helpers', () => {
175
177
 
176
178
  it('should join key=value&foo=bar', () => {
177
179
  expect(toQuery({ key: 'value', foo: 'bar' })).toEqual('key=value&foo=bar');
178
- expect(toQuery([['key', 'value'], ['foo', 'bar']])).toEqual('key=value&foo=bar');
180
+ expect(
181
+ toQuery([
182
+ ['key', 'value'],
183
+ ['foo', 'bar']
184
+ ])
185
+ ).toEqual('key=value&foo=bar');
179
186
  });
180
187
  });
181
188
  });
@@ -24,7 +24,10 @@ describe('TemplateElement', () => {
24
24
  });
25
25
 
26
26
  it('should return boolean given element has attribute with true string', () => {
27
- [['one', 'true'], ['two', 'True']].forEach(([attrName, attrValue]) => {
27
+ [
28
+ ['one', 'true'],
29
+ ['two', 'True']
30
+ ].forEach(([attrName, attrValue]) => {
28
31
  const el = new MockElement();
29
32
  el.setAttribute(attrName, attrValue);
30
33
  expect(el.getOption(attrName)).toBe(true);
@@ -32,7 +35,10 @@ describe('TemplateElement', () => {
32
35
  });
33
36
 
34
37
  it('should return boolean given element has attribute with false string', () => {
35
- [['three', 'false'], ['four', 'False']].forEach(([attrName, attrValue]) => {
38
+ [
39
+ ['three', 'false'],
40
+ ['four', 'False']
41
+ ].forEach(([attrName, attrValue]) => {
36
42
  const el = new MockElement();
37
43
  el.setAttribute(attrName, attrValue);
38
44
  expect(el.getOption(attrName)).toBe(false);
@@ -17,7 +17,7 @@ describe('reducers', () => {
17
17
  function testMergeReducerWithActionAndPayload(reducerFn, actionType, payload) {
18
18
  it('should append object to stock', () => {
19
19
  const initial = { 'yum state key': 'yum state val' };
20
- const actual = reducerFn(initial, { type: constants[actionType], payload: payload });
20
+ const actual = reducerFn(initial, { type: constants[actionType], payload });
21
21
  expect(actual).toEqual({ ...initial, foo: false });
22
22
  });
23
23
 
@@ -39,12 +39,12 @@ export const createSessionId = merchantId => ({
39
39
 
40
40
  export const requestAuth = payload => ({
41
41
  type: constants.REQUEST_AUTH,
42
- payload: payload
42
+ payload
43
43
  });
44
44
 
45
45
  export const authorize = (merchantId, sigfield, ts, sig) => ({
46
46
  type: constants.AUTHORIZE,
47
- payload: { public_id: merchantId, sig_field: sigfield, ts: ts, sig: sig }
47
+ payload: { public_id: merchantId, sig_field: sigfield, ts, sig }
48
48
  });
49
49
 
50
50
  export const unauthorized = reason => ({
@@ -192,7 +192,10 @@ export const fetchOffer = (product, module = 'pdp') =>
192
192
  dispatch(requestAction);
193
193
  return api
194
194
  .fetchOffer(apiUrl, merchantId, sessionId, product, module)
195
- .then(response => dispatch(receiveOffer(response)), err => dispatch(fetchResponseError(err)))
195
+ .then(
196
+ response => dispatch(receiveOffer(response)),
197
+ err => dispatch(fetchResponseError(err))
198
+ )
196
199
  .finally(() => dispatch(fetchDone(requestAction)));
197
200
  };
198
201
 
@@ -207,7 +210,7 @@ export const requestCreateOneTime = (product, order, quantity, offerId) => ({
207
210
 
208
211
  export const receiveCreateOneTime = payload => ({
209
212
  type: constants.CREATE_ONE_TIME,
210
- payload: payload
213
+ payload
211
214
  });
212
215
 
213
216
  export const requestConvertOneTimeToSubscription = (item, frequency) => ({
@@ -262,12 +265,12 @@ export const createIu = (product, order, quantity, subscribed = false, frequency
262
265
 
263
266
  export const setLocale = payload => ({
264
267
  type: constants.SET_LOCALE,
265
- payload: payload
268
+ payload
266
269
  });
267
270
 
268
271
  export const setConfig = payload => ({
269
272
  type: constants.SET_CONFIG,
270
- payload: payload
273
+ payload
271
274
  });
272
275
 
273
276
  export const addTemplate = (selector, markup, config) => ({
@@ -19,14 +19,14 @@ export const getProductsForPurchasePost = (state = {}, productIds = []) =>
19
19
  }
20
20
  };
21
21
  if (state.firstOrderPlaceDate && state.firstOrderPlaceDate[optin.id]) {
22
- purchasePostObject['subscription_info']['first_order_place_date'] = state.firstOrderPlaceDate[optin.id];
22
+ purchasePostObject.subscription_info.first_order_place_date = state.firstOrderPlaceDate[optin.id];
23
23
  }
24
24
  if (state.productToSubscribe && state.productToSubscribe[optin.id]) {
25
- purchasePostObject['tracking_override']['product'] = state.productToSubscribe[optin.id];
25
+ purchasePostObject.tracking_override.product = state.productToSubscribe[optin.id];
26
26
  }
27
27
  return purchasePostObject;
28
28
  })
29
- .filter(optin => optin['tracking_override'].offer)
29
+ .filter(optin => optin.tracking_override.offer)
30
30
  .filter(optin => (productIds.length ? productIds.includes(optin.product) : optin));
31
31
 
32
32
  export default { getProductsForPurchasePost };
package/src/core/api.js CHANGED
@@ -86,7 +86,10 @@ export const fetchOrders = memoize(
86
86
  withFetchJson(
87
87
  withHost(
88
88
  withAuth((status = 1, ordering = 'place') => [
89
- `/orders/?${toQuery([['status', status], ['ordering', ordering]])}`
89
+ `/orders/?${toQuery([
90
+ ['status', status],
91
+ ['ordering', ordering]
92
+ ])}`
90
93
  ])
91
94
  )
92
95
  ),
@@ -51,7 +51,7 @@ export const listenLocalStorageChanges = store =>
51
51
  const { key, newValue } = ev;
52
52
  if (key === STORE_ROOT && newValue === null) {
53
53
  store.dispatch({ type: LOCAL_STORAGE_CLEAR });
54
- setImmediate(() => store.dispatch(requestSessionId()));
54
+ setTimeout(() => store.dispatch(requestSessionId()), 0);
55
55
  } else if (key === STORE_ROOT) {
56
56
  store.dispatch({
57
57
  type: LOCAL_STORAGE_CHANGE,
@@ -6,19 +6,21 @@ import { saveState } from './localStorage';
6
6
  export const dispatchEvent = (name, detail, el = document) =>
7
7
  el.dispatchEvent(
8
8
  new CustomEvent(name, {
9
- detail: detail
9
+ detail
10
10
  })
11
11
  );
12
12
 
13
13
  export const dispatchOptinChangedEvent = optedIn => ({
14
14
  payload: { product: { id: productId, components } = {} } = {}
15
15
  } = {}) =>
16
- setImmediate(() =>
17
- dispatchEvent('optin-changed', {
18
- productId: productId,
19
- components: components,
20
- optedIn: optedIn
21
- })
16
+ setTimeout(
17
+ () =>
18
+ dispatchEvent('optin-changed', {
19
+ productId,
20
+ components,
21
+ optedIn
22
+ }),
23
+ 0
22
24
  );
23
25
 
24
26
  export const conditionals = [
@@ -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
@@ -77,7 +77,7 @@ const offers = {
77
77
  customElements.define('og-next-upcoming-order', ConnectedNextUpcomingOrder);
78
78
  } catch (err) {
79
79
  // eslint-disable-next-line no-console
80
- console.error(err);
80
+ console.log('this?', err);
81
81
  }
82
82
  offers.register = () => 0;
83
83
  },
@@ -156,9 +156,6 @@ const offers = {
156
156
  return offers;
157
157
  },
158
158
  setPublicPath(publicPath) {
159
- /* eslint-disable camelcase, no-undef */
160
- __webpack_require__.p = publicPath;
161
- /* eslint-enable */
162
159
  return offers;
163
160
  }
164
161
  };
@@ -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(window.merchantId, window.env, 0);
@@ -0,0 +1,3 @@
1
+ import og from './index';
2
+
3
+ og.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":""}