@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.
- package/CHANGELOG.md +15 -0
- package/build.js +5 -0
- package/dist/bundle-report.html +221 -63
- package/dist/examples.js +385 -1897
- package/dist/examples.js.map +7 -1
- package/dist/offers.js +266 -214
- package/dist/offers.js.map +7 -1
- package/examples/index.html +3 -0
- package/examples/index.js +19 -6
- package/karma-functional.conf.js +12 -10
- package/karma.conf.js +20 -10
- package/package.json +10 -15
- package/src/__tests__/offers.spec.js +111 -0
- package/src/__tests__/test-mode.spec.js +16 -0
- package/src/components/FrequencyStatus.js +2 -2
- package/src/components/IncentiveText.js +1 -1
- package/src/components/Offer.js +21 -15
- package/src/components/OptinButton.js +2 -5
- package/src/components/OptinSelect.js +2 -2
- package/src/components/OptinToggle.js +1 -4
- package/src/components/OptoutButton.js +1 -4
- package/src/components/Price.js +54 -0
- package/src/components/SelectFrequency.js +4 -8
- package/src/components/UpsellButton.js +2 -5
- package/src/components/UpsellModal.js +6 -10
- package/src/components/__tests__/FrequencyStatus.spec.js +33 -38
- package/src/components/__tests__/IncentiveText.spec.js +1 -1
- package/src/components/__tests__/Modal.spec.js +1 -1
- package/src/components/__tests__/NextUpcomingOrder.spec.js +1 -1
- package/src/components/__tests__/OG.fspec.js +2 -2
- package/src/components/__tests__/Offer.spec.js +5 -7
- package/src/components/__tests__/OptinButton.spec.js +1 -1
- package/src/components/__tests__/OptinSelect.spec.js +1 -1
- package/src/components/__tests__/OptinStatus.spec.js +1 -1
- package/src/components/__tests__/Price.fspec.js +43 -0
- package/src/components/__tests__/Select.spec.js +1 -1
- package/src/components/__tests__/SelectFrequency.spec.js +17 -6
- package/src/components/__tests__/Text.spec.js +1 -1
- package/src/components/__tests__/Tooltip.spec.js +1 -1
- package/src/components/__tests__/UpsellButton.spec.js +4 -6
- package/src/components/__tests__/When.spec.js +1 -1
- package/src/core/__tests__/api.spec.js +10 -3
- package/src/core/__tests__/base.spec.js +8 -2
- package/src/core/__tests__/reducer.spec.js +1 -1
- package/src/core/actions.js +16 -10
- package/src/core/adapters.js +3 -3
- package/src/core/api.js +4 -1
- package/src/core/constants.js +1 -0
- package/src/core/localStorage.js +1 -1
- package/src/core/middleware.js +9 -7
- package/src/core/reducer.js +10 -0
- package/src/core/selectors.js +19 -33
- package/src/index.js +187 -153
- package/src/init-func-tests.js +1 -2
- package/src/init-test.js +3 -0
- package/src/test-mode.js +5 -3
- package/dist/index.html +0 -125
- package/dist/offers-preview-mode.bundle.js +0 -2
- package/dist/offers-preview-mode.bundle.js.map +0 -1
- package/dist/offers-test-mode.bundle.js +0 -100
- package/dist/offers-test-mode.bundle.js.map +0 -1
- package/src/_tests_/offers.spec.js +0 -18
- package/src/_tests_/test-mode.spec.js +0 -15
- package/webpack.config.js +0 -43
package/src/core/selectors.js
CHANGED
|
@@ -55,24 +55,19 @@ export const defaultFrequenciesSelector = state => state.defaultFrequencies || {
|
|
|
55
55
|
*/
|
|
56
56
|
export const makeOptedinSelector = memoize(
|
|
57
57
|
product =>
|
|
58
|
-
createSelector(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
153
|
+
store = getStore();
|
|
127
154
|
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
158
|
+
setStore(store);
|
|
135
159
|
|
|
136
|
-
|
|
137
|
-
|
|
160
|
+
if (merchantId) offers.setMerchantId(merchantId);
|
|
161
|
+
if (env) offers.setEnvironment(env);
|
|
162
|
+
if (authUrl) offers.setAuthUrl(authUrl);
|
|
138
163
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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;
|
package/src/init-func-tests.js
CHANGED
package/src/init-test.js
ADDED
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
|
-
|
|
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":""}
|