@ordergroove/offers 2.27.2-alpha-PR-637-7.13 → 2.27.3
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 +19 -0
- package/dist/bundle-report.html +8 -8
- package/dist/offers.js +26 -26
- package/dist/offers.js.map +2 -2
- package/package.json +3 -3
- package/src/components/Offer.js +6 -7
- package/src/components/Price.js +1 -6
- package/src/core/actions-preview.js +0 -23
- package/src/core/__tests__/actions-preview.spec.js +0 -73
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordergroove/offers",
|
|
3
|
-
"version": "2.27.
|
|
3
|
+
"version": "2.27.3",
|
|
4
4
|
"description": "offer state component",
|
|
5
5
|
"author": "Eugenio Lattanzio <eugenio63@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ordergroove/plush-toys#readme",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@ordergroove/auth": "^2.3.0",
|
|
37
|
-
"@ordergroove/offers-live-editor": "^0.
|
|
37
|
+
"@ordergroove/offers-live-editor": "^0.5.0",
|
|
38
38
|
"lit-element": "^2.1.0",
|
|
39
39
|
"lodash.memoize": "^4.1.2",
|
|
40
40
|
"logical-expression-parser": "1.0.0",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@ordergroove/offers-templates": "^0.4.12"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "506e488aef1ca8a90dc56d9af659d5dafa0e51d8"
|
|
49
49
|
}
|
package/src/components/Offer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { html, css } from 'lit-element';
|
|
2
2
|
import memoize from 'lodash.memoize';
|
|
3
3
|
import { connect } from '../core/connect';
|
|
4
|
-
import { setPreview
|
|
4
|
+
import { setPreview } from '../core/actions-preview';
|
|
5
5
|
import {
|
|
6
6
|
fetchOffer,
|
|
7
7
|
productHasChangedComponents,
|
|
@@ -149,11 +149,11 @@ export class Offer extends TemplateElement {
|
|
|
149
149
|
<og-price discount>
|
|
150
150
|
<span slot="prepend">Subscribe and get</span>
|
|
151
151
|
<span slot="append">off</span>
|
|
152
|
-
<og-text key="offerOptInLabel" slot="fallback"></og-text>
|
|
152
|
+
<og-text key="offerOptInLabel" slot="fallback"></og-text>
|
|
153
153
|
</og-price>
|
|
154
154
|
<og-price regular></og-price>
|
|
155
155
|
<og-price subscription></og-price>
|
|
156
|
-
|
|
156
|
+
|
|
157
157
|
</og-optin-button>
|
|
158
158
|
<og-tooltip placement="bottom">
|
|
159
159
|
<div slot="trigger">
|
|
@@ -217,7 +217,7 @@ export class Offer extends TemplateElement {
|
|
|
217
217
|
The product is in your next upcomming order
|
|
218
218
|
</og-when>
|
|
219
219
|
</og-when>
|
|
220
|
-
|
|
220
|
+
|
|
221
221
|
`;
|
|
222
222
|
}
|
|
223
223
|
|
|
@@ -299,7 +299,7 @@ export class Offer extends TemplateElement {
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
get isPreview() {
|
|
302
|
-
return this.preview;
|
|
302
|
+
return this.preview || window.og.previewMode;
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
render() {
|
|
@@ -343,8 +343,7 @@ export const ConnectedOffer = connect(mapStateToProps, {
|
|
|
343
343
|
optinProduct,
|
|
344
344
|
setFirstOrderPlaceDate,
|
|
345
345
|
setProductToSubscribe,
|
|
346
|
-
setPreview
|
|
347
|
-
setPlanPrices
|
|
346
|
+
setPreview
|
|
348
347
|
})(Offer);
|
|
349
348
|
|
|
350
349
|
export default ConnectedOffer;
|
package/src/components/Price.js
CHANGED
|
@@ -26,22 +26,17 @@ export class Price extends withProduct(TemplateElement) {
|
|
|
26
26
|
const currentPlan = plans[frequency] || [];
|
|
27
27
|
if (!currentPlan) return '';
|
|
28
28
|
const [regularPrice, discountRate, subscriptionPrice] = currentPlan;
|
|
29
|
-
|
|
30
29
|
if (subscriptionPrice === regularPrice) return '';
|
|
31
30
|
|
|
32
31
|
if (this.regular) {
|
|
33
32
|
return regularPrice;
|
|
34
33
|
}
|
|
35
|
-
if (this.discount)
|
|
36
|
-
return discountRate;
|
|
37
|
-
}
|
|
38
|
-
|
|
34
|
+
if (this.discount) return discountRate;
|
|
39
35
|
return subscriptionPrice;
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
render() {
|
|
43
39
|
const value = this.value;
|
|
44
|
-
|
|
45
40
|
if (value)
|
|
46
41
|
return html`
|
|
47
42
|
<slot name="prepend"></slot>
|
|
@@ -140,26 +140,3 @@ export const setPreview = (value, oldValue, ownProps) =>
|
|
|
140
140
|
default:
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
|
|
144
|
-
export const setPlanPrices = ([regularPrice, discountRate, subscribePrice], frequency = 'all', ownProps) =>
|
|
145
|
-
async function(dispatch, getState) {
|
|
146
|
-
const nextProductPlans = Object.assign(
|
|
147
|
-
{},
|
|
148
|
-
{ [ownProps.product.id]: {} },
|
|
149
|
-
// deep cloning productPlans
|
|
150
|
-
Object.fromEntries(Object.entries(getState()?.productPlans).map(([k, v]) => [k, Object.assign({}, v)])) || {}
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
if (frequency === 'all') {
|
|
154
|
-
['1_1', '1_2', '1_3', '2_1', '2_2', '2_3', '3_1', '3_2', '3_3'].forEach(freq => {
|
|
155
|
-
nextProductPlans[ownProps.product.id][freq] = [regularPrice, discountRate, subscribePrice];
|
|
156
|
-
});
|
|
157
|
-
} else {
|
|
158
|
-
nextProductPlans[ownProps.product.id][frequency] = [regularPrice, discountRate, subscribePrice];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
await dispatch({
|
|
162
|
-
type: constants.RECEIVE_PRODUCT_PLANS,
|
|
163
|
-
payload: nextProductPlans
|
|
164
|
-
});
|
|
165
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { setPlanPrices } from '../actions-preview';
|
|
2
|
-
import * as constants from '../constants';
|
|
3
|
-
|
|
4
|
-
describe('setPlanPrices', () => {
|
|
5
|
-
const mockState = {
|
|
6
|
-
productPlans: {
|
|
7
|
-
'mock-product-id': {
|
|
8
|
-
'3_1': [1, 2, 3]
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
const mockDispatch = jasmine.createSpy('dispatch');
|
|
13
|
-
const mockGetState = jasmine.createSpy('mockGetState').and.returnValue(mockState);
|
|
14
|
-
it('should update all preview plans to specified frequency', async () => {
|
|
15
|
-
await setPlanPrices(['mock1', 'mock2', 'mock3'], '3_1', { product: { id: 'mock-product-id' } })(
|
|
16
|
-
mockDispatch,
|
|
17
|
-
mockGetState
|
|
18
|
-
);
|
|
19
|
-
expect(mockDispatch).toHaveBeenCalledWith({
|
|
20
|
-
type: constants.RECEIVE_PRODUCT_PLANS,
|
|
21
|
-
payload: {
|
|
22
|
-
'mock-product-id': {
|
|
23
|
-
'3_1': ['mock1', 'mock2', 'mock3']
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should should not override baseState', async () => {
|
|
30
|
-
await setPlanPrices(['mock1', 'mock2', 'mock3'], '3_1', { product: { id: 'mock-product-id' } })(
|
|
31
|
-
mockDispatch,
|
|
32
|
-
mockGetState
|
|
33
|
-
);
|
|
34
|
-
expect(mockDispatch).toHaveBeenCalledWith({
|
|
35
|
-
type: constants.RECEIVE_PRODUCT_PLANS,
|
|
36
|
-
payload: {
|
|
37
|
-
'mock-product-id': {
|
|
38
|
-
'3_1': ['mock1', 'mock2', 'mock3']
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
expect(mockState).toEqual({
|
|
43
|
-
productPlans: {
|
|
44
|
-
'mock-product-id': {
|
|
45
|
-
'3_1': [1, 2, 3]
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should override all frequencies if all is given', async () => {
|
|
52
|
-
await setPlanPrices(['mock1', 'mock2', 'mock3'], 'all', { product: { id: 'mock-product-id' } })(
|
|
53
|
-
mockDispatch,
|
|
54
|
-
mockGetState
|
|
55
|
-
);
|
|
56
|
-
expect(mockDispatch).toHaveBeenCalledWith({
|
|
57
|
-
type: constants.RECEIVE_PRODUCT_PLANS,
|
|
58
|
-
payload: {
|
|
59
|
-
'mock-product-id': {
|
|
60
|
-
'1_1': ['mock1', 'mock2', 'mock3'],
|
|
61
|
-
'1_2': ['mock1', 'mock2', 'mock3'],
|
|
62
|
-
'1_3': ['mock1', 'mock2', 'mock3'],
|
|
63
|
-
'2_1': ['mock1', 'mock2', 'mock3'],
|
|
64
|
-
'2_2': ['mock1', 'mock2', 'mock3'],
|
|
65
|
-
'2_3': ['mock1', 'mock2', 'mock3'],
|
|
66
|
-
'3_1': ['mock1', 'mock2', 'mock3'],
|
|
67
|
-
'3_2': ['mock1', 'mock2', 'mock3'],
|
|
68
|
-
'3_3': ['mock1', 'mock2', 'mock3']
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|