@ordergroove/offers 2.24.2 → 2.25.2-alpha-PR-576-3.7
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 +38 -0
- package/dist/bundle-report.html +99 -98
- package/dist/examples.js +192 -84
- package/dist/examples.js.map +2 -2
- package/dist/offers.js +170 -152
- package/dist/offers.js.map +3 -3
- package/examples/index.js +20 -6
- package/package.json +5 -5
- package/schema.json +16 -10
- package/src/__tests__/offers.spec.js +100 -5
- package/src/components/Offer.js +12 -3
- package/src/components/OptinStatus.js +3 -3
- package/src/components/Price.js +54 -0
- package/src/components/Select.js +1 -1
- package/src/components/Tooltip.js +6 -3
- package/src/components/__tests__/OG.fspec.js +2 -2
- package/src/components/__tests__/Price.fspec.js +43 -0
- package/src/core/actions.js +7 -4
- package/src/core/constants.js +1 -0
- package/src/core/reducer.js +16 -5
- package/src/index.js +187 -150
- package/src/init-func-tests.js +1 -1
- package/src/init-test.js +2 -2
package/examples/index.js
CHANGED
|
@@ -5,6 +5,16 @@ import { getMarkup, getStyles } from '@ordergroove/offers-templates';
|
|
|
5
5
|
|
|
6
6
|
// runTests();
|
|
7
7
|
|
|
8
|
+
window.og_settings = {
|
|
9
|
+
// object were key is product id and value is an array of plan discount
|
|
10
|
+
product_discounts: {
|
|
11
|
+
UD729: {
|
|
12
|
+
'3_1': ['30.00', '10%', '$27.00'],
|
|
13
|
+
'1_2': ['30.00', '20%', '$24.00']
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
8
18
|
const frequencies = [
|
|
9
19
|
{
|
|
10
20
|
every: 1,
|
|
@@ -31,10 +41,11 @@ const settings = {
|
|
|
31
41
|
|
|
32
42
|
const textCopy = {
|
|
33
43
|
showTooltip: true,
|
|
34
|
-
offerOptInLabel: 'Subscribe and
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
offerOptInLabel: 'Subscribe and Save',
|
|
45
|
+
offerIncentiveText: 'Save {{ogIncentive DiscountPercent}} when you subscribe',
|
|
46
|
+
offerOptOutLabel: 'Deliver one-time only',
|
|
47
|
+
offerEveryLabel: 'Deliver every',
|
|
48
|
+
offerTooltipTrigger: '[?]',
|
|
38
49
|
offerTooltipContent: 'Seems this is a great subscription offering. Many fun details about this program exist.',
|
|
39
50
|
optinButtonLabel: '•',
|
|
40
51
|
optoutButtonLabel: '•',
|
|
@@ -325,7 +336,11 @@ Add item to order on
|
|
|
325
336
|
{
|
|
326
337
|
name: 'Tooltip',
|
|
327
338
|
selector: 'og-offer[location="tooltip-placement"]',
|
|
328
|
-
markup: [
|
|
339
|
+
markup: [
|
|
340
|
+
['top-left', 'top', 'top-right'],
|
|
341
|
+
['left', '', 'right'],
|
|
342
|
+
['bottom-left', 'bottom', 'bottom-right']
|
|
343
|
+
]
|
|
329
344
|
.map(options =>
|
|
330
345
|
options
|
|
331
346
|
.map(
|
|
@@ -359,7 +374,6 @@ function updateTemplate(target) {
|
|
|
359
374
|
|
|
360
375
|
const style = document.getElementById('offersGlobalCss');
|
|
361
376
|
style.innerHTML = '';
|
|
362
|
-
console.log('it.config', JSON.parse(data).config, getStyles(JSON.parse(data).config));
|
|
363
377
|
style.appendChild(document.createTextNode(getStyles(JSON.parse(data).config)));
|
|
364
378
|
|
|
365
379
|
document.getElementById('the-html').innerText = (JSON.parse(data).markup || '').trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordergroove/offers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.25.2-alpha-PR-576-3.7+adf67759",
|
|
4
4
|
"description": "offer state component",
|
|
5
5
|
"author": "Eugenio Lattanzio <eugenio63@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ordergroove/plush-toys#readme",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
}
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@ordergroove/auth": "^2.2.
|
|
37
|
-
"@ordergroove/offers-live-editor": "^0.4.
|
|
36
|
+
"@ordergroove/auth": "^2.2.1-alpha-PR-576-3.39+adf67759",
|
|
37
|
+
"@ordergroove/offers-live-editor": "^0.4.1",
|
|
38
38
|
"lit-element": "^2.1.0",
|
|
39
39
|
"lodash.memoize": "^4.1.2",
|
|
40
40
|
"logical-expression-parser": "1.0.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"throttle-debounce": "^2.1.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@ordergroove/offers-templates": "^0.4.
|
|
46
|
+
"@ordergroove/offers-templates": "^0.4.4"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "adf67759424245c191b298426b53cd997ea6b0b6"
|
|
49
49
|
}
|
package/schema.json
CHANGED
|
@@ -274,27 +274,32 @@
|
|
|
274
274
|
"properties": {
|
|
275
275
|
"defaultFrequencyCopy": {
|
|
276
276
|
"type": "string",
|
|
277
|
-
"default": "
|
|
277
|
+
"default": "(Most Popular)",
|
|
278
278
|
"title": "Default frequency copy"
|
|
279
279
|
},
|
|
280
280
|
"offerOptInLabel": {
|
|
281
281
|
"type": "string",
|
|
282
|
-
"default": "Subscribe and
|
|
283
|
-
"title": "
|
|
282
|
+
"default": "Subscribe and Save",
|
|
283
|
+
"title": "Subscription copy"
|
|
284
|
+
},
|
|
285
|
+
"offerIncentiveText": {
|
|
286
|
+
"type": "string",
|
|
287
|
+
"default": "Save {{ogIncentive DiscountPercent}} when you subscribe",
|
|
288
|
+
"title": "Subscription sub copy"
|
|
284
289
|
},
|
|
285
290
|
"offerEveryLabel": {
|
|
286
291
|
"type": "string",
|
|
287
|
-
"default": "
|
|
292
|
+
"default": "Deliver Every",
|
|
288
293
|
"title": "Subscribe frequency label"
|
|
289
294
|
},
|
|
290
295
|
"offerOptOutLabel": {
|
|
291
296
|
"type": "string",
|
|
292
|
-
"default": "
|
|
297
|
+
"default": "Deliver one-time only",
|
|
293
298
|
"title": "One-time option copy"
|
|
294
299
|
},
|
|
295
300
|
"showTooltip": {
|
|
296
301
|
"type": "boolean",
|
|
297
|
-
"default":
|
|
302
|
+
"default": true,
|
|
298
303
|
"title": "Add a tool tip"
|
|
299
304
|
}
|
|
300
305
|
},
|
|
@@ -364,7 +369,7 @@
|
|
|
364
369
|
},
|
|
365
370
|
"tooltipPlacement": {
|
|
366
371
|
"type": "string",
|
|
367
|
-
"default": "
|
|
372
|
+
"default": "bottom",
|
|
368
373
|
"enum": ["top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right", "right", "left"]
|
|
369
374
|
}
|
|
370
375
|
}
|
|
@@ -441,11 +446,12 @@
|
|
|
441
446
|
"offerType": "radio"
|
|
442
447
|
},
|
|
443
448
|
"textCopy": {
|
|
444
|
-
"defaultFrequencyCopy": "
|
|
445
|
-
"offerOptInLabel": "Subscribe and
|
|
449
|
+
"defaultFrequencyCopy": "(Most Popular)",
|
|
450
|
+
"offerOptInLabel": "Subscribe and Save",
|
|
451
|
+
"offerIncentiveText": "Save {{ogIncentive DiscountPercent}} when you subscribe",
|
|
446
452
|
"offerEveryLabel": "Ships Every: ",
|
|
447
453
|
"offerOptOutLabel": "One-time",
|
|
448
|
-
"showTooltip":
|
|
454
|
+
"showTooltip": true,
|
|
449
455
|
"upsellButtonLabel": "Add to upcoming subscription order and receive 20% off",
|
|
450
456
|
"upsellButtonContent": "Add to Next Order on ",
|
|
451
457
|
"upsellModalContent": "Subscribe to this product and have it conveniently delivered to you at the frequency you choose! Read the FAQ here. Promotion subject to change.",
|
|
@@ -1,16 +1,111 @@
|
|
|
1
|
-
import offers from '../index';
|
|
1
|
+
import { offers } from '../index';
|
|
2
|
+
import { api } from '../core/api';
|
|
2
3
|
|
|
3
4
|
describe('Offers', () => {
|
|
5
|
+
let register, fetchOfferSpy, mockStore;
|
|
4
6
|
// TODO revisit chunks
|
|
5
7
|
it('should have setPublicPath method as compatibility', () => {
|
|
6
8
|
offers.setPublicPath('yum-path');
|
|
7
9
|
});
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
register = spyOn(offers, 'register');
|
|
13
|
+
fetchOfferSpy = spyOn(api, 'fetchOffer');
|
|
14
|
+
const dispatch = jasmine.createSpy();
|
|
15
|
+
mockStore = {
|
|
16
|
+
getState() {
|
|
17
|
+
return { sessionId: 'xyz' };
|
|
18
|
+
},
|
|
19
|
+
dispatch
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
offers.isReady = false;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should warn if attempting to initialize twice', () => {
|
|
26
|
+
const warn = spyOn(console, 'warn');
|
|
27
|
+
|
|
11
28
|
offers.initialize('0e5de2bedc5e11e3a2e4bc764e106cf4', 'staging');
|
|
12
|
-
expect(
|
|
29
|
+
expect(warn).not.toHaveBeenCalled();
|
|
30
|
+
|
|
13
31
|
offers.initialize('0e5de2bedc5e11e3a2e4bc764e106cf4', 'staging');
|
|
14
|
-
expect(
|
|
32
|
+
expect(warn).toHaveBeenCalledWith('og.offers has been initialized already. Skipping.');
|
|
33
|
+
expect(register).toHaveBeenCalledTimes(1);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should warn if attempting to initialize twice', () => {
|
|
37
|
+
const resolveSettings = spyOn(offers, 'resolveSettings');
|
|
38
|
+
offers.initialize('0e5de2bedc5e11e3a2e4bc764e106cf4', 'staging');
|
|
39
|
+
expect(resolveSettings).toHaveBeenCalledWith(
|
|
40
|
+
'0e5de2bedc5e11e3a2e4bc764e106cf4',
|
|
41
|
+
'staging',
|
|
42
|
+
undefined,
|
|
43
|
+
offers.store
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('offers.resolveSettings', () => {
|
|
48
|
+
it('should fetch offer for single product in pdp', () => {
|
|
49
|
+
offers.resolveSettings('0e5de2bedc5e11e3a2e4bc764e106cf4', 'staging', { product: '123' }, mockStore);
|
|
50
|
+
expect(fetchOfferSpy).toHaveBeenCalledWith(
|
|
51
|
+
'https://staging.om.ordergroove.com',
|
|
52
|
+
'0e5de2bedc5e11e3a2e4bc764e106cf4',
|
|
53
|
+
'xyz',
|
|
54
|
+
'123',
|
|
55
|
+
'pdp'
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should fetch offer for each product in cart', () => {
|
|
60
|
+
offers.resolveSettings(
|
|
61
|
+
'0e5de2bedc5e11e3a2e4bc764e106cf4',
|
|
62
|
+
'staging',
|
|
63
|
+
{ cart: { products: ['123', '456'] } },
|
|
64
|
+
mockStore
|
|
65
|
+
);
|
|
66
|
+
expect(fetchOfferSpy).toHaveBeenCalledTimes(2);
|
|
67
|
+
|
|
68
|
+
expect(fetchOfferSpy.calls.argsFor(0)).toEqual([
|
|
69
|
+
'https://staging.om.ordergroove.com',
|
|
70
|
+
'0e5de2bedc5e11e3a2e4bc764e106cf4',
|
|
71
|
+
'xyz',
|
|
72
|
+
'123',
|
|
73
|
+
'pdp'
|
|
74
|
+
]);
|
|
75
|
+
expect(fetchOfferSpy.calls.argsFor(1)).toEqual([
|
|
76
|
+
'https://staging.om.ordergroove.com',
|
|
77
|
+
'0e5de2bedc5e11e3a2e4bc764e106cf4',
|
|
78
|
+
'xyz',
|
|
79
|
+
'456',
|
|
80
|
+
'pdp'
|
|
81
|
+
]);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should set product price and discounts', () => {
|
|
85
|
+
offers.resolveSettings(
|
|
86
|
+
'0e5de2bedc5e11e3a2e4bc764e106cf4',
|
|
87
|
+
'staging',
|
|
88
|
+
{
|
|
89
|
+
// object were key is product id and value is an array of plan discount
|
|
90
|
+
product_discounts: {
|
|
91
|
+
123: {
|
|
92
|
+
'2_2': ['30.00', '20%', '$24.00'],
|
|
93
|
+
'1_3': ['30.00', '10%', '$27.00']
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
mockStore
|
|
98
|
+
);
|
|
99
|
+
expect(mockStore.dispatch).toHaveBeenCalledTimes(1);
|
|
100
|
+
expect(mockStore.dispatch).toHaveBeenCalledWith({
|
|
101
|
+
type: 'RECEIVE_PRODUCT_PLANS',
|
|
102
|
+
payload: {
|
|
103
|
+
123: {
|
|
104
|
+
'2_2': ['30.00', '20%', '$24.00'],
|
|
105
|
+
'1_3': ['30.00', '10%', '$27.00']
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
15
110
|
});
|
|
16
111
|
});
|
package/src/components/Offer.js
CHANGED
|
@@ -134,15 +134,24 @@ export class Offer extends TemplateElement {
|
|
|
134
134
|
return `
|
|
135
135
|
<og-when test="regularEligible">
|
|
136
136
|
<div>
|
|
137
|
+
|
|
137
138
|
<og-optout-button>
|
|
138
139
|
<og-text key="offerOptOutLabel"></og-text>
|
|
139
140
|
</og-optout-button>
|
|
140
141
|
</div>
|
|
141
142
|
<div>
|
|
142
143
|
<og-optin-button>
|
|
143
|
-
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
<og-price discount>
|
|
147
|
+
<span slot="prepend">Subscribe and get</span>
|
|
148
|
+
<span slot="append">off</span>
|
|
149
|
+
</og-price>
|
|
150
|
+
<og-price regular></og-price>
|
|
151
|
+
<og-price subscription></og-price>
|
|
152
|
+
|
|
144
153
|
</og-optin-button>
|
|
145
|
-
<og-tooltip placement="
|
|
154
|
+
<og-tooltip placement="bottom">
|
|
146
155
|
<div slot="trigger">
|
|
147
156
|
<og-text key="offerTooltipTrigger"></og-text>
|
|
148
157
|
</div>
|
|
@@ -151,7 +160,7 @@ export class Offer extends TemplateElement {
|
|
|
151
160
|
</div>
|
|
152
161
|
</og-tooltip>
|
|
153
162
|
</div>
|
|
154
|
-
<div style="margin-left:
|
|
163
|
+
<div style="margin-left: 2.2em">
|
|
155
164
|
<og-text key="offerEveryLabel"></og-text>
|
|
156
165
|
<og-select-frequency>
|
|
157
166
|
<option value="3_1" selected>3 Days</option>
|
|
@@ -31,9 +31,9 @@ export class OptinStatus extends withProduct(TemplateElement) {
|
|
|
31
31
|
|
|
32
32
|
.btn {
|
|
33
33
|
position: relative;
|
|
34
|
-
width: 1.4em;
|
|
35
|
-
height: 1.4em;
|
|
36
|
-
margin: 0;
|
|
34
|
+
width: var(--og-radio-width, 1.4em);
|
|
35
|
+
height: var(--og-radio-height, 1.4em);
|
|
36
|
+
margin: var(--og-radio-margin, 0);
|
|
37
37
|
padding: 0;
|
|
38
38
|
border: 1px solid var(--og-primary-color, black);
|
|
39
39
|
background: #fff;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { html } from 'lit-element';
|
|
2
|
+
import { connect } from '../core/connect';
|
|
3
|
+
|
|
4
|
+
import { withProduct } from '../core/resolveProperties';
|
|
5
|
+
import { TemplateElement } from '../core/base';
|
|
6
|
+
import { makeProductFrequencySelector } from '../core/selectors';
|
|
7
|
+
|
|
8
|
+
export class Price extends withProduct(TemplateElement) {
|
|
9
|
+
static get properties() {
|
|
10
|
+
return {
|
|
11
|
+
...super.properties,
|
|
12
|
+
regular: { type: Boolean, reflect: true },
|
|
13
|
+
subscription: { type: Boolean, reflect: true },
|
|
14
|
+
discount: { type: Boolean, reflect: true },
|
|
15
|
+
frequency: { type: Object },
|
|
16
|
+
productPlans: { type: Object }
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get value() {
|
|
21
|
+
const frequency = this.frequency || (this.offer && this.offer.defaultFrequency);
|
|
22
|
+
const plans = this.productPlans[this.product.id] || {};
|
|
23
|
+
const currentPlan = plans[frequency] || [];
|
|
24
|
+
if (!currentPlan) return '';
|
|
25
|
+
const [regularPrice, discountRate, subscriptionPrice] = currentPlan;
|
|
26
|
+
if (subscriptionPrice === regularPrice) return '';
|
|
27
|
+
|
|
28
|
+
if (this.regular) {
|
|
29
|
+
return regularPrice;
|
|
30
|
+
}
|
|
31
|
+
if (this.discount) return discountRate;
|
|
32
|
+
return subscriptionPrice;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
render() {
|
|
36
|
+
const value = this.value;
|
|
37
|
+
if (value)
|
|
38
|
+
return html`
|
|
39
|
+
<slot name="prepend"></slot>
|
|
40
|
+
${value}
|
|
41
|
+
<slot name="append"></slot>
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
return html`
|
|
45
|
+
<slot></slot>
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const mapStateToProps = (state, ownProps) => ({
|
|
50
|
+
productPlans: state.productPlans,
|
|
51
|
+
frequency: makeProductFrequencySelector(ownProps.product)(state)
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export default connect(mapStateToProps)(Price);
|
package/src/components/Select.js
CHANGED
|
@@ -3,7 +3,7 @@ import { LitElement, html, css } from 'lit-element';
|
|
|
3
3
|
export class Tooltip extends LitElement {
|
|
4
4
|
static get properties() {
|
|
5
5
|
return {
|
|
6
|
-
placement: { type: String, default: '
|
|
6
|
+
placement: { type: String, default: 'bottom' }
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -16,6 +16,7 @@ export class Tooltip extends LitElement {
|
|
|
16
16
|
:host {
|
|
17
17
|
display: inline-block;
|
|
18
18
|
position: relative;
|
|
19
|
+
z-index: 9;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
.trigger {
|
|
@@ -33,12 +34,14 @@ export class Tooltip extends LitElement {
|
|
|
33
34
|
display: block;
|
|
34
35
|
width: 200px;
|
|
35
36
|
opacity: 0;
|
|
36
|
-
padding: 0.5em;
|
|
37
|
+
padding: var(--og-tooltip-padding, 0.5em);
|
|
38
|
+
text-align: var(--og-tooltip-text-align, left);
|
|
37
39
|
pointer-events: none;
|
|
38
40
|
position: absolute;
|
|
39
41
|
transform: translateY(10px);
|
|
40
42
|
transition: transform 0.25s ease-out;
|
|
41
43
|
z-index: 99999;
|
|
44
|
+
border-radius: var(--og-tooltip-border-radius, 0);
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
.content:after {
|
|
@@ -189,7 +192,7 @@ export class Tooltip extends LitElement {
|
|
|
189
192
|
${this.trigger}
|
|
190
193
|
</slot>
|
|
191
194
|
</span>
|
|
192
|
-
<div class="content ${this.placement || '
|
|
195
|
+
<div class="content ${this.placement || 'bottom'}">
|
|
193
196
|
<slot name="content">
|
|
194
197
|
${this.content}
|
|
195
198
|
</slot>
|
|
@@ -2,10 +2,10 @@ const og = window.og;
|
|
|
2
2
|
describe('og.offers', function() {
|
|
3
3
|
it('should define og namespace', () => {
|
|
4
4
|
expect(og).toEqual(jasmine.any(Object));
|
|
5
|
-
expect(og.offers).toEqual(jasmine.any(
|
|
5
|
+
expect(og.offers).toEqual(jasmine.any(Object));
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
it('
|
|
8
|
+
it('should define register() method', () => {
|
|
9
9
|
expect(og.offers.register).toEqual(jasmine.any(Function));
|
|
10
10
|
});
|
|
11
11
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const og = window.og;
|
|
2
|
+
|
|
3
|
+
async function simulateChange(element, value) {
|
|
4
|
+
const evt = new Event('change', { bubbles: true });
|
|
5
|
+
element.value = value;
|
|
6
|
+
element.dispatchEvent(evt, { target: { value } });
|
|
7
|
+
await new Promise(r => setTimeout(r, 1));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
describe('Select Frequency', function() {
|
|
11
|
+
let element;
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
og.offers.clear();
|
|
14
|
+
document.body.innerHTML = `
|
|
15
|
+
<og-offer product="123" preview-standard-offer>
|
|
16
|
+
<og-select-frequency default-text=" (recomended)">
|
|
17
|
+
<option value="optedOut">Buy one time</option>
|
|
18
|
+
<option value="2w" selected="selected">2 weeks</option>
|
|
19
|
+
<option value="1m">1 month </option>
|
|
20
|
+
</og-select-frequency>
|
|
21
|
+
</og-offer>
|
|
22
|
+
`;
|
|
23
|
+
element = document.querySelector('og-select-frequency');
|
|
24
|
+
await element.updateComplete;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('it should have default frequency as value', async () => {
|
|
28
|
+
const htmlSelectElement = element.shadowRoot.querySelector('og-select').shadowRoot.querySelector('select');
|
|
29
|
+
expect(htmlSelectElement.value).toEqual('2_2');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should append recomended text to default frequency', async () => {
|
|
33
|
+
const htmlSelectElement = element.shadowRoot.querySelector('og-select').shadowRoot.querySelector('select');
|
|
34
|
+
expect(htmlSelectElement.innerText).toEqual('Buy one time\n2 weeks (recomended)\n1 month');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should not append recomended text to clicked frequency', async () => {
|
|
38
|
+
const htmlSelectElement = element.shadowRoot.querySelector('og-select').shadowRoot.querySelector('select');
|
|
39
|
+
await simulateChange(htmlSelectElement, '1_3');
|
|
40
|
+
expect(htmlSelectElement.value).toEqual('1_3');
|
|
41
|
+
expect(htmlSelectElement.innerText).toEqual('Buy one time\n2 weeks (recomended)\n1 month');
|
|
42
|
+
});
|
|
43
|
+
});
|
package/src/core/actions.js
CHANGED
|
@@ -121,11 +121,14 @@ export const fetchOrders = (status = 1, ordering = 'place') =>
|
|
|
121
121
|
.then(
|
|
122
122
|
// eslint-disable-next-line camelcase
|
|
123
123
|
response => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
if (response.results) {
|
|
125
|
+
dispatch(receiveOrders(response));
|
|
126
|
+
const nextOrderId = (response.results[0] || {}).public_id;
|
|
127
|
+
if (nextOrderId) {
|
|
128
|
+
return api.fetchItems(legoUrl, auth, nextOrderId).then(res => dispatch(receiveItems(res)));
|
|
129
|
+
}
|
|
128
130
|
}
|
|
131
|
+
dispatch(unauthorized(response.detail));
|
|
129
132
|
return null;
|
|
130
133
|
},
|
|
131
134
|
err => dispatch(unauthorized(err))
|
package/src/core/constants.js
CHANGED
|
@@ -36,3 +36,4 @@ export const LOCAL_STORAGE_CHANGE = 'LOCAL_STORAGE_CHANGE';
|
|
|
36
36
|
export const LOCAL_STORAGE_CLEAR = 'LOCAL_STORAGE_CLEAR';
|
|
37
37
|
export const SET_FIRST_ORDER_PLACE_DATE = 'SET_FIRST_ORDER_PLACE_DATE';
|
|
38
38
|
export const SET_PRODUCT_TO_SUBSCRIBE = 'SET_PRODUCT_TO_SUBSCRIBE';
|
|
39
|
+
export const RECEIVE_PRODUCT_PLANS = 'RECEIVE_PRODUCT_PLANS';
|
package/src/core/reducer.js
CHANGED
|
@@ -332,10 +332,11 @@ export const environment = (state = {}, action) => {
|
|
|
332
332
|
|
|
333
333
|
export const locale = (
|
|
334
334
|
state = {
|
|
335
|
-
offerOptInLabel: 'Subscribe',
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
335
|
+
offerOptInLabel: 'Subscribe and Save',
|
|
336
|
+
offerIncentiveText: 'Save {{ogIncentive DiscountPercent}} when you subscribe',
|
|
337
|
+
offerOptOutLabel: 'Deliver one-time only',
|
|
338
|
+
offerEveryLabel: 'Delivery Every',
|
|
339
|
+
offerTooltipTrigger: '[?]',
|
|
339
340
|
offerTooltipContent: 'Seems this is a great subscription offering. Many fun details about this program exist.',
|
|
340
341
|
optinButtonLabel: '•',
|
|
341
342
|
optoutButtonLabel: '•',
|
|
@@ -350,7 +351,7 @@ export const locale = (
|
|
|
350
351
|
upsellModalTitle: 'Impulse Upsell',
|
|
351
352
|
upsellModalConfirmLabel: 'Ok',
|
|
352
353
|
upsellModalCancelLabel: 'Cancel',
|
|
353
|
-
defaultFrequencyCopy: '(
|
|
354
|
+
defaultFrequencyCopy: '(Most Popular)',
|
|
354
355
|
frequencyPeriods: {
|
|
355
356
|
'1': 'day',
|
|
356
357
|
'2': 'week',
|
|
@@ -443,7 +444,17 @@ export const templates = (state = [], action) => {
|
|
|
443
444
|
}
|
|
444
445
|
};
|
|
445
446
|
|
|
447
|
+
export const productPlans = (state = {}, action) => {
|
|
448
|
+
switch (action.type) {
|
|
449
|
+
case constants.RECEIVE_PRODUCT_PLANS:
|
|
450
|
+
return { ...action.payload };
|
|
451
|
+
default:
|
|
452
|
+
return state;
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
|
|
446
456
|
export default combineReducers({
|
|
457
|
+
productPlans,
|
|
447
458
|
environment,
|
|
448
459
|
optedin,
|
|
449
460
|
optedout,
|