@ordergroove/offers 2.35.3 → 2.35.5-alpha-PR-802-3.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.
- package/CHANGELOG.md +8 -0
- package/dist/bundle-report.html +12 -12
- package/dist/examples.js +3 -2
- package/dist/examples.js.map +2 -2
- package/dist/offers.js +61 -76
- package/dist/offers.js.map +3 -3
- package/examples/index.html +1 -1
- package/examples/index.js +0 -1
- package/examples/shopify-cart.html +5 -8
- package/examples/shopify-pdp.html +8 -12
- package/karma-functional.conf.js +1 -1
- package/karma-shopify.conf.js +1 -1
- package/karma.conf.js +1 -1
- package/package.json +4 -4
- package/src/components/FrequencyStatus.js +4 -4
- package/src/components/Modal.js +5 -7
- package/src/components/Offer.js +3 -1
- package/src/components/OptinToggle.js +2 -2
- package/src/components/Select.js +2 -1
- package/src/components/TestWizard.js +22 -35
- package/src/components/Tooltip.js +2 -6
- package/src/components/UpsellModal.js +2 -2
- package/src/components/__tests__/FrequencyStatus.spec.js +1 -1
- package/src/components/__tests__/OG.fspec.js +6 -10
- package/src/components/__tests__/Offer.spec.js +17 -17
- package/src/components/__tests__/OptinButton.spec.js +1 -1
- package/src/components/__tests__/PrepaidButton.spec.js +1 -1
- package/src/components/__tests__/PrepaidSelect.spec.js +1 -1
- package/src/components/__tests__/PrepaidToggle.spec.js +1 -1
- package/src/components/__tests__/Price.spec.js +6 -6
- package/src/components/__tests__/Select.spec.js +4 -4
- package/src/components/__tests__/SubscriptionButton.spec.js +1 -1
- package/src/core/__tests__/actions.spec.js +1 -1
- package/src/core/__tests__/localStorage.spec.js +3 -3
- package/src/core/__tests__/middleware.spec.js +12 -12
- package/src/core/actions-preview.js +6 -6
- package/src/core/actions.js +8 -6
- package/src/core/api.js +5 -13
- package/src/core/connect.js +29 -27
- package/src/core/middleware.js +12 -12
- package/src/core/reducer.js +6 -6
- package/src/core/utils.ts +4 -4
- package/src/run-tests.js +1 -1
- package/src/shopify/__tests__/shopifyReducer.spec.js +6 -6
- package/src/shopify/shopifyMiddleware.ts +2 -2
- package/src/shopify/shopifyReducer.js +9 -7
- package/src/test-mode.js +2 -2
- package/tsconfig.json +1 -4
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import * as constants from '../constants';
|
|
25
25
|
import { api } from '../api';
|
|
26
26
|
|
|
27
|
-
describe('redux actions', function() {
|
|
27
|
+
describe('redux actions', function () {
|
|
28
28
|
it('setEnvironment should return dev payload given dev env', () => {
|
|
29
29
|
expect(setEnvironment('dev')).toEqual({
|
|
30
30
|
type: 'SET_ENVIRONMENT_DEV',
|
|
@@ -74,20 +74,20 @@ describe('saveState', () => {
|
|
|
74
74
|
setItemSpy = spyOn(Object.getPrototypeOf(localStorage), 'setItem');
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
it('should not save empty state', function() {
|
|
77
|
+
it('should not save empty state', function () {
|
|
78
78
|
['', false, {}, null, undefined].forEach(saveState);
|
|
79
79
|
expect(getItemSpy).not.toHaveBeenCalled();
|
|
80
80
|
expect(setItemSpy).not.toHaveBeenCalled();
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
it('should not save if same state', function() {
|
|
83
|
+
it('should not save if same state', function () {
|
|
84
84
|
getItemSpy.and.returnValue(JSON.stringify({ sessionId: 'yum' }));
|
|
85
85
|
saveState({ sessionId: 'yum' });
|
|
86
86
|
expect(getItemSpy).toHaveBeenCalledWith(STORE_ROOT);
|
|
87
87
|
expect(setItemSpy).not.toHaveBeenCalled();
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
it('should save if different state', function() {
|
|
90
|
+
it('should save if different state', function () {
|
|
91
91
|
const payload = { sessionId: 'yum' };
|
|
92
92
|
saveState(payload);
|
|
93
93
|
expect(getItemSpy).toHaveBeenCalledWith(STORE_ROOT);
|
|
@@ -45,29 +45,29 @@ describe('middleware', () => {
|
|
|
45
45
|
|
|
46
46
|
describe('conditionals', () => {
|
|
47
47
|
describe('expression a', () => {
|
|
48
|
-
beforeEach(function() {
|
|
48
|
+
beforeEach(function () {
|
|
49
49
|
this.underTest = conditionals[0].expressions[0];
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
it('should return true given type is constants.OPTIN_PRODUCT', function() {
|
|
52
|
+
it('should return true given type is constants.OPTIN_PRODUCT', function () {
|
|
53
53
|
expect(this.underTest({ type: constants.OPTIN_PRODUCT })).toBe(true);
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
it('should return false given type is not constants.OPTIN_PRODUCT', function() {
|
|
56
|
+
it('should return false given type is not constants.OPTIN_PRODUCT', function () {
|
|
57
57
|
expect(this.underTest({ type: 'not constants.OPTIN_PRODUCT' })).toBe(false);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
it('should return false given type is not defined', function() {
|
|
60
|
+
it('should return false given type is not defined', function () {
|
|
61
61
|
expect(this.underTest()).toBe(false);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
describe('expression b', () => {
|
|
66
|
-
beforeEach(function() {
|
|
66
|
+
beforeEach(function () {
|
|
67
67
|
this.underTest = conditionals[0].expressions[1];
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
it('should return false given type is not constants.PRODUCT_CHANGE_FREQUENCY and optedin does not contain same product', function() {
|
|
70
|
+
it('should return false given type is not constants.PRODUCT_CHANGE_FREQUENCY and optedin does not contain same product', function () {
|
|
71
71
|
const action = {
|
|
72
72
|
type: 'not constants.PRODUCT_CHANGE_FREQUENCY',
|
|
73
73
|
payload: {
|
|
@@ -83,7 +83,7 @@ describe('middleware', () => {
|
|
|
83
83
|
expect(this.underTest(action, state)).toBe(false);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
it('should return false given type is not constants.PRODUCT_CHANGE_FREQUENCY and optedin contains same product', function() {
|
|
86
|
+
it('should return false given type is not constants.PRODUCT_CHANGE_FREQUENCY and optedin contains same product', function () {
|
|
87
87
|
const action = {
|
|
88
88
|
type: 'not constants.PRODUCT_CHANGE_FREQUENCY',
|
|
89
89
|
payload: {
|
|
@@ -103,7 +103,7 @@ describe('middleware', () => {
|
|
|
103
103
|
expect(this.underTest(action, state)).toBe(false);
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
it('should return true given type is constants.PRODUCT_CHANGE_FREQUENCY', function() {
|
|
106
|
+
it('should return true given type is constants.PRODUCT_CHANGE_FREQUENCY', function () {
|
|
107
107
|
const action = {
|
|
108
108
|
type: constants.PRODUCT_CHANGE_FREQUENCY,
|
|
109
109
|
payload: {
|
|
@@ -125,19 +125,19 @@ describe('middleware', () => {
|
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
describe('expression c', () => {
|
|
128
|
-
beforeEach(function() {
|
|
128
|
+
beforeEach(function () {
|
|
129
129
|
this.underTest = conditionals[1].expressions[0];
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
it('should return true given type is constants.OPTOUT_PRODUCT', function() {
|
|
132
|
+
it('should return true given type is constants.OPTOUT_PRODUCT', function () {
|
|
133
133
|
expect(this.underTest({ type: constants.OPTOUT_PRODUCT })).toBe(true);
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
-
it('should return false given type is not constants.OPTOUT_PRODUCT', function() {
|
|
136
|
+
it('should return false given type is not constants.OPTOUT_PRODUCT', function () {
|
|
137
137
|
expect(this.underTest({ type: 'not constants.OPTOUT_PRODUCT' })).toBe(false);
|
|
138
138
|
});
|
|
139
139
|
|
|
140
|
-
it('should return false given type is not defined', function() {
|
|
140
|
+
it('should return false given type is not defined', function () {
|
|
141
141
|
expect(this.underTest()).toBe(false);
|
|
142
142
|
});
|
|
143
143
|
});
|
|
@@ -6,7 +6,7 @@ export const setPreviewStandardOffer = (isPreview, productId, offer) =>
|
|
|
6
6
|
async function setPreviewStandardOfferThunk(dispatch) {
|
|
7
7
|
await dispatch({
|
|
8
8
|
type: constants.SET_PREVIEW_STANDARD_OFFER,
|
|
9
|
-
payload: isPreview
|
|
9
|
+
payload: { isPreview, productId }
|
|
10
10
|
});
|
|
11
11
|
await dispatch({
|
|
12
12
|
type: constants.UNAUTHORIZED
|
|
@@ -78,7 +78,7 @@ export const mergeProductPlansToState = (state, newProductPlans) => {
|
|
|
78
78
|
|
|
79
79
|
export const setPreviewUpsellOffer = (isPreview, productId, offer) =>
|
|
80
80
|
async function setPreviewUpsellOfferThunk(dispatch, getState) {
|
|
81
|
-
await dispatch({ type: constants.SET_PREVIEW_UPSELL_OFFER, payload: isPreview });
|
|
81
|
+
await dispatch({ type: constants.SET_PREVIEW_UPSELL_OFFER, payload: { isPreview, productId } });
|
|
82
82
|
|
|
83
83
|
const { merchantId } = getState();
|
|
84
84
|
if (isPreview) {
|
|
@@ -142,7 +142,7 @@ export const setPreviewPrepaid = (isPreview, productId, offer) =>
|
|
|
142
142
|
|
|
143
143
|
await dispatch({
|
|
144
144
|
type: constants.SET_PREVIEW_PREPAID_OFFER,
|
|
145
|
-
payload: isPreview
|
|
145
|
+
payload: { isPreview, productId }
|
|
146
146
|
});
|
|
147
147
|
await dispatch({
|
|
148
148
|
type: constants.UNAUTHORIZED
|
|
@@ -264,15 +264,15 @@ export const setPreviewPrepaid = (isPreview, productId, offer) =>
|
|
|
264
264
|
};
|
|
265
265
|
|
|
266
266
|
export const setPreview = (value, oldValue, offer) =>
|
|
267
|
-
async function(dispatch, _getState) {
|
|
267
|
+
async function (dispatch, _getState) {
|
|
268
268
|
await dispatch({ type: constants.LOCAL_STORAGE_CLEAR });
|
|
269
269
|
await dispatch({
|
|
270
270
|
type: constants.SET_PREVIEW_STANDARD_OFFER,
|
|
271
|
-
payload: false
|
|
271
|
+
payload: { isPreview: false, productId: offer.product.id }
|
|
272
272
|
});
|
|
273
273
|
await dispatch({
|
|
274
274
|
type: constants.SET_PREVIEW_UPSELL_OFFER,
|
|
275
|
-
payload: false
|
|
275
|
+
payload: { isPreview: false, productId: offer.product.id }
|
|
276
276
|
});
|
|
277
277
|
|
|
278
278
|
switch (value) {
|
package/src/core/actions.js
CHANGED
|
@@ -256,18 +256,20 @@ export const createIu = (product, order, quantity, subscribed = false, initialFr
|
|
|
256
256
|
|
|
257
257
|
dispatch(requestAction);
|
|
258
258
|
|
|
259
|
-
return (
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
return (
|
|
260
|
+
previewUpsellOffer
|
|
261
|
+
? Promise.resolve({ legoUrl, product, order, quantity, offer })
|
|
262
|
+
: api.createOneTime(legoUrl, auth, product.id, order, quantity, offer)
|
|
262
263
|
)
|
|
263
264
|
.then(
|
|
264
265
|
item => {
|
|
265
266
|
dispatch(receiveCreateOneTime(item));
|
|
266
267
|
if (subscribed) {
|
|
267
268
|
dispatch(requestConvertOneTimeToSubscription(item, frequency));
|
|
268
|
-
return (
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
return (
|
|
270
|
+
previewUpsellOffer
|
|
271
|
+
? Promise.resolve({ item, frequency })
|
|
272
|
+
: api.convertOneTimeToSubscription(legoUrl, auth, item, frequency, offer)
|
|
271
273
|
).then(
|
|
272
274
|
response => dispatch(receiveConvertOneTime(response, product)),
|
|
273
275
|
err => dispatch(fetchResponseError(err))
|
package/src/core/api.js
CHANGED
|
@@ -2,7 +2,10 @@ import memoize from 'lodash.memoize';
|
|
|
2
2
|
|
|
3
3
|
const memoizeKey = (...args) => JSON.stringify(args);
|
|
4
4
|
|
|
5
|
-
export const withFetchJson =
|
|
5
|
+
export const withFetchJson =
|
|
6
|
+
cb =>
|
|
7
|
+
(...args) =>
|
|
8
|
+
fetch(...cb(...args)).then(res => res.json());
|
|
6
9
|
|
|
7
10
|
export const withHost = cb => {
|
|
8
11
|
return (host, ...extra) => {
|
|
@@ -134,18 +137,7 @@ export const parseFrequency = raw => {
|
|
|
134
137
|
|
|
135
138
|
export const isFrequencyValid = it => it.match(/^\d+_\d$/);
|
|
136
139
|
export const compareFrequencies = (a, b) =>
|
|
137
|
-
String.prototype.localeCompare.call(
|
|
138
|
-
a &&
|
|
139
|
-
a
|
|
140
|
-
.split('_')
|
|
141
|
-
.reverse()
|
|
142
|
-
.join('_'),
|
|
143
|
-
b &&
|
|
144
|
-
b
|
|
145
|
-
.split('_')
|
|
146
|
-
.reverse()
|
|
147
|
-
.join('_')
|
|
148
|
-
);
|
|
140
|
+
String.prototype.localeCompare.call(a && a.split('_').reverse().join('_'), b && b.split('_').reverse().join('_'));
|
|
149
141
|
|
|
150
142
|
export const parseFrequenciesList = value =>
|
|
151
143
|
[...new Set(value && value.split(/\s+/))].filter(isFrequencyValid).sort(compareFrequencies);
|
package/src/core/connect.js
CHANGED
|
@@ -21,41 +21,43 @@ export const createRecalcProps = (mapStateToProps, mapDispatchToProps) => obj =>
|
|
|
21
21
|
* TODO this component can be coded as regular connect function. Instead of making the component
|
|
22
22
|
* tied to stateChanged connect can accept mapStateToProps?, mapDispatchToProps?
|
|
23
23
|
*/
|
|
24
|
-
export const connect =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
export const connect =
|
|
25
|
+
(mapStateToProps, mapDispatchToProps = defaultMapDispatchToProps) =>
|
|
26
|
+
baseElement => {
|
|
27
|
+
const preparedDispatch =
|
|
28
|
+
typeof mapDispatchToProps === 'function'
|
|
29
|
+
? mapDispatchToProps
|
|
30
|
+
: dispatch => bindActionCreators(mapDispatchToProps, dispatch);
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
const recalcProps = createRecalcProps(mapStateToProps, preparedDispatch);
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
connectedCallback() {
|
|
38
|
-
if (super.connectedCallback) {
|
|
39
|
-
super.connectedCallback();
|
|
34
|
+
return class extends baseElement {
|
|
35
|
+
get store() {
|
|
36
|
+
return storeInstance;
|
|
40
37
|
}
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
connectedCallback() {
|
|
40
|
+
if (super.connectedCallback) {
|
|
41
|
+
super.connectedCallback();
|
|
42
|
+
}
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
44
|
+
this._storeUnsubscribe = resolveStore(this).subscribe(() => recalcProps(this));
|
|
45
|
+
recalcProps(this);
|
|
46
|
+
}
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
super.disconnectedCallback();
|
|
48
|
+
attributeChangedCallback(name, old, value) {
|
|
49
|
+
if (super.attributeChangedCallback) super.attributeChangedCallback(name, old, value);
|
|
50
|
+
if (this._storeUnsubscribe && old !== value) recalcProps(this);
|
|
55
51
|
}
|
|
56
|
-
|
|
52
|
+
|
|
53
|
+
disconnectedCallback() {
|
|
54
|
+
this._storeUnsubscribe();
|
|
55
|
+
if (super.disconnectedCallback) {
|
|
56
|
+
super.disconnectedCallback();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
57
60
|
};
|
|
58
|
-
};
|
|
59
61
|
/**
|
|
60
62
|
* This api will change asap
|
|
61
63
|
* @deprecated
|
package/src/core/middleware.js
CHANGED
|
@@ -9,18 +9,18 @@ export const dispatchEvent = (name, detail, el = document) =>
|
|
|
9
9
|
})
|
|
10
10
|
);
|
|
11
11
|
|
|
12
|
-
export const dispatchOptinChangedEvent =
|
|
13
|
-
|
|
14
|
-
} = {}) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
export const dispatchOptinChangedEvent =
|
|
13
|
+
optedIn =>
|
|
14
|
+
({ payload: { product: { id: productId, components } = {} } = {} } = {}) =>
|
|
15
|
+
setTimeout(
|
|
16
|
+
() =>
|
|
17
|
+
dispatchEvent('optin-changed', {
|
|
18
|
+
productId,
|
|
19
|
+
components,
|
|
20
|
+
optedIn
|
|
21
|
+
}),
|
|
22
|
+
0
|
|
23
|
+
);
|
|
24
24
|
|
|
25
25
|
export const conditionals = [
|
|
26
26
|
{
|
package/src/core/reducer.js
CHANGED
|
@@ -366,9 +366,9 @@ export const locale = (
|
|
|
366
366
|
upsellModalCancelLabel: 'Cancel',
|
|
367
367
|
defaultFrequencyCopy: '(Most Popular)',
|
|
368
368
|
frequencyPeriods: {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
369
|
+
1: 'day',
|
|
370
|
+
2: 'week',
|
|
371
|
+
3: 'month'
|
|
372
372
|
},
|
|
373
373
|
prepaidOptInLabel: 'Prepaid Subscription',
|
|
374
374
|
prepaidShipmentsLabel: 'Number of prepaid shipments'
|
|
@@ -408,7 +408,7 @@ export const config = (
|
|
|
408
408
|
export const previewStandardOffer = (state = false, action) => {
|
|
409
409
|
switch (action.type) {
|
|
410
410
|
case constants.SET_PREVIEW_STANDARD_OFFER:
|
|
411
|
-
return action.payload;
|
|
411
|
+
return action.payload.isPreview;
|
|
412
412
|
default:
|
|
413
413
|
return state;
|
|
414
414
|
}
|
|
@@ -417,7 +417,7 @@ export const previewStandardOffer = (state = false, action) => {
|
|
|
417
417
|
export const previewUpsellOffer = (state = false, action) => {
|
|
418
418
|
switch (action.type) {
|
|
419
419
|
case constants.SET_PREVIEW_UPSELL_OFFER:
|
|
420
|
-
return action.payload;
|
|
420
|
+
return action.payload.isPreview;
|
|
421
421
|
default:
|
|
422
422
|
return state;
|
|
423
423
|
}
|
|
@@ -426,7 +426,7 @@ export const previewUpsellOffer = (state = false, action) => {
|
|
|
426
426
|
export const previewPrepaidOffer = (state = false, action) => {
|
|
427
427
|
switch (action.type) {
|
|
428
428
|
case constants.SET_PREVIEW_PREPAID_OFFER:
|
|
429
|
-
return action.payload;
|
|
429
|
+
return action.payload.isPreview;
|
|
430
430
|
default:
|
|
431
431
|
return state;
|
|
432
432
|
}
|
package/src/core/utils.ts
CHANGED
|
@@ -149,10 +149,10 @@ export function getOrCreateHidden(parent, name, value) {
|
|
|
149
149
|
* @returns {[any, any[]]} - a two item array where the first item is the matching product and the second is the remaining items from the original state.
|
|
150
150
|
*/
|
|
151
151
|
export function getMatchingProductIfExists(state, product) {
|
|
152
|
-
const [[oldone], rest] = state.reduce(
|
|
153
|
-
[],
|
|
154
|
-
[]
|
|
155
|
-
|
|
152
|
+
const [[oldone], rest] = state.reduce(
|
|
153
|
+
(acc, val) => acc[isSameProduct(product, val) ? 0 : 1].push(val) && acc,
|
|
154
|
+
[[], []]
|
|
155
|
+
);
|
|
156
156
|
|
|
157
157
|
return [oldone || {}, rest || []];
|
|
158
158
|
}
|
package/src/run-tests.js
CHANGED
|
@@ -437,7 +437,7 @@ describe('config', () => {
|
|
|
437
437
|
);
|
|
438
438
|
expect(actual).toEqual({
|
|
439
439
|
prepaidSellingPlans: {
|
|
440
|
-
|
|
440
|
+
43017264201944: [
|
|
441
441
|
{
|
|
442
442
|
numberShipments: 4,
|
|
443
443
|
sellingPlan: '2146042072'
|
|
@@ -479,13 +479,13 @@ describe('config', () => {
|
|
|
479
479
|
const actual = config(
|
|
480
480
|
{
|
|
481
481
|
prepaidSellingPlans: {
|
|
482
|
-
|
|
482
|
+
43017264201946: [
|
|
483
483
|
{
|
|
484
484
|
numberShipments: 1,
|
|
485
485
|
sellingPlan: '2146042072'
|
|
486
486
|
}
|
|
487
487
|
],
|
|
488
|
-
|
|
488
|
+
43017264201944: [
|
|
489
489
|
{
|
|
490
490
|
numberShipments: 4,
|
|
491
491
|
sellingPlan: '2146042071'
|
|
@@ -504,19 +504,19 @@ describe('config', () => {
|
|
|
504
504
|
);
|
|
505
505
|
expect(actual).toEqual({
|
|
506
506
|
prepaidSellingPlans: {
|
|
507
|
-
|
|
507
|
+
43017264201944: [
|
|
508
508
|
{
|
|
509
509
|
numberShipments: 4,
|
|
510
510
|
sellingPlan: '2146042071'
|
|
511
511
|
}
|
|
512
512
|
],
|
|
513
|
-
|
|
513
|
+
43017264201946: [
|
|
514
514
|
{
|
|
515
515
|
numberShipments: 3,
|
|
516
516
|
sellingPlan: '2146042072'
|
|
517
517
|
}
|
|
518
518
|
],
|
|
519
|
-
|
|
519
|
+
43017264201945: [
|
|
520
520
|
{
|
|
521
521
|
numberShipments: 5,
|
|
522
522
|
sellingPlan: '2146042073'
|
|
@@ -39,7 +39,7 @@ type SetupCartPayload = ShopifyCart;
|
|
|
39
39
|
const DEFAULT_SHOPIFY_CART_AJAX_SECTIONS =
|
|
40
40
|
'[id^="shopify-section-"][id$=__cart-items], [id^="shopify-section-"][id$="__cart-footer"],#cart-live-region-text,#cart-icon-bubble';
|
|
41
41
|
const makeSyncProductId = offer =>
|
|
42
|
-
debounce(100, false, function(form) {
|
|
42
|
+
debounce(100, false, function (form) {
|
|
43
43
|
const { id } = Object.fromEntries([...new FormData(form).entries()]);
|
|
44
44
|
if (id) {
|
|
45
45
|
offer.setAttribute('product', id);
|
|
@@ -142,7 +142,7 @@ export function guessProductHandle(offer): string {
|
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
const getProduct = memoize(async function(handle: string): Promise<ShopifyProductEntity> {
|
|
145
|
+
const getProduct = memoize(async function (handle: string): Promise<ShopifyProductEntity> {
|
|
146
146
|
return (await fetch(`${PRODUCTS_URL}${handle}.js`)).json();
|
|
147
147
|
});
|
|
148
148
|
|
|
@@ -190,6 +190,10 @@ export const autoshipEligible = (state = {}, action) => {
|
|
|
190
190
|
};
|
|
191
191
|
}, state);
|
|
192
192
|
}
|
|
193
|
+
if (constants.SET_PREVIEW_STANDARD_OFFER === action.type) {
|
|
194
|
+
if (action.payload.isPreview !== true) return state;
|
|
195
|
+
return { ...state, ...{ [action.payload.productId]: true } };
|
|
196
|
+
}
|
|
193
197
|
return state;
|
|
194
198
|
};
|
|
195
199
|
|
|
@@ -246,13 +250,7 @@ export const config = (
|
|
|
246
250
|
action
|
|
247
251
|
) => {
|
|
248
252
|
if (constants.RECEIVE_PRODUCT_PLANS === action.type) {
|
|
249
|
-
const frequencies = [
|
|
250
|
-
...new Set(
|
|
251
|
-
Object.values(action.payload)
|
|
252
|
-
.map(Object.keys)
|
|
253
|
-
.flat()
|
|
254
|
-
)
|
|
255
|
-
];
|
|
253
|
+
const frequencies = [...new Set(Object.values(action.payload).map(Object.keys).flat())];
|
|
256
254
|
return {
|
|
257
255
|
...state,
|
|
258
256
|
frequencies
|
|
@@ -354,6 +352,10 @@ export const inStock = (state = {}, action) => {
|
|
|
354
352
|
if (constants.REQUEST_OFFER === action.type && action.payload.product === null) {
|
|
355
353
|
return { ...state };
|
|
356
354
|
}
|
|
355
|
+
if (constants.SET_PREVIEW_STANDARD_OFFER === action.type) {
|
|
356
|
+
if (action.payload.isPreview !== true) return state;
|
|
357
|
+
return { ...state, ...{ [action.payload.productId]: true } };
|
|
358
|
+
}
|
|
357
359
|
return state;
|
|
358
360
|
};
|
|
359
361
|
|
package/src/test-mode.js
CHANGED
|
@@ -14,11 +14,11 @@ export const enable = () => {
|
|
|
14
14
|
let keysCounter = 0;
|
|
15
15
|
document.addEventListener(
|
|
16
16
|
'keyup',
|
|
17
|
-
async function(e) {
|
|
17
|
+
async function (e) {
|
|
18
18
|
const key = e.which;
|
|
19
19
|
if (key === keys[keysCounter]) {
|
|
20
20
|
const currentkeys = keys[keysCounter];
|
|
21
|
-
setTimeout(function() {
|
|
21
|
+
setTimeout(function () {
|
|
22
22
|
if (keysCounter <= currentkeys) keysCounter = 0;
|
|
23
23
|
}, 5000);
|
|
24
24
|
keysCounter += 1;
|
package/tsconfig.json
CHANGED