@ordergroove/offers 2.27.8-alpha-PR-645-16.30 → 2.27.8
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 +11 -0
- package/dist/bundle-report.html +12 -12
- package/dist/examples.js +8 -7
- package/dist/examples.js.map +2 -2
- package/dist/offers.js +46 -50
- package/dist/offers.js.map +2 -2
- package/package.json +3 -3
- package/src/components/OptinSelect.js +2 -15
- package/src/shopify/__tests__/shopifyReducer.spec.js +22 -19
- package/src/shopify/shopifyMiddleware.ts +0 -1
- package/src/shopify/shopifyReducer.js +7 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordergroove/offers",
|
|
3
|
-
"version": "2.27.8
|
|
3
|
+
"version": "2.27.8",
|
|
4
4
|
"description": "offer state component",
|
|
5
5
|
"author": "Eugenio Lattanzio <eugenio63@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ordergroove/plush-toys#readme",
|
|
@@ -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.14"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "2b681b995370886dcc2fc613c5e059062a51f152"
|
|
49
49
|
}
|
|
@@ -54,12 +54,7 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
|
|
|
54
54
|
let options;
|
|
55
55
|
if (this.frequencies?.length) {
|
|
56
56
|
options = [
|
|
57
|
-
|
|
58
|
-
value: 'optedOut',
|
|
59
|
-
text: html`
|
|
60
|
-
<og-text key="offerOptOutLabel"></og-text>
|
|
61
|
-
`
|
|
62
|
-
},
|
|
57
|
+
...([childOptions.find(option => option.value === 'optedOut')] || []),
|
|
63
58
|
...this.frequencies.map((value, ix) => ({
|
|
64
59
|
value,
|
|
65
60
|
text:
|
|
@@ -69,15 +64,7 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
|
|
|
69
64
|
}))
|
|
70
65
|
];
|
|
71
66
|
} else {
|
|
72
|
-
options =
|
|
73
|
-
{
|
|
74
|
-
value: 'optedOut',
|
|
75
|
-
text: html`
|
|
76
|
-
<og-text key="offerOptOutLabel"></og-text>
|
|
77
|
-
`
|
|
78
|
-
},
|
|
79
|
-
...childOptions
|
|
80
|
-
];
|
|
67
|
+
options = childOptions;
|
|
81
68
|
}
|
|
82
69
|
|
|
83
70
|
return html`
|
|
@@ -337,29 +337,32 @@ describe('offerId', () => {
|
|
|
337
337
|
|
|
338
338
|
describe('optedin', () => {
|
|
339
339
|
it('should return optins given action SETUP_CART', () => {
|
|
340
|
-
const actual = optedin(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
340
|
+
const actual = optedin(
|
|
341
|
+
{},
|
|
342
|
+
{
|
|
343
|
+
type: constants.SETUP_CART,
|
|
344
|
+
payload: {
|
|
345
|
+
items: [
|
|
346
|
+
{
|
|
347
|
+
key: 'yum item key 1',
|
|
348
|
+
selling_plan_allocation: {
|
|
349
|
+
selling_plan: {
|
|
350
|
+
id: 'yum selling plan id 1'
|
|
351
|
+
}
|
|
349
352
|
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
key: 'yum item key 2',
|
|
356
|
+
selling_plan_allocation: {
|
|
357
|
+
selling_plan: {
|
|
358
|
+
id: 'yum selling plan id 2'
|
|
359
|
+
}
|
|
357
360
|
}
|
|
358
361
|
}
|
|
359
|
-
|
|
360
|
-
|
|
362
|
+
]
|
|
363
|
+
}
|
|
361
364
|
}
|
|
362
|
-
|
|
365
|
+
);
|
|
363
366
|
|
|
364
367
|
expect(actual).toEqual([
|
|
365
368
|
{
|
|
@@ -165,16 +165,13 @@ export const offerId = (state = '', action) => 'native-shopify-offer';
|
|
|
165
165
|
export const optedin = (state = [], action) => {
|
|
166
166
|
if (constants.SETUP_CART === action.type) {
|
|
167
167
|
const cart = action.payload;
|
|
168
|
-
return cart.items.reduce(
|
|
169
|
-
|
|
170
|
-
cur.selling_plan_allocation
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
return acc;
|
|
177
|
-
}, state);
|
|
168
|
+
return cart.items.reduce(
|
|
169
|
+
(acc, cur) =>
|
|
170
|
+
cur.selling_plan_allocation
|
|
171
|
+
? [...acc, { id: cur.key, frequency: `${cur.selling_plan_allocation.selling_plan.id}` }]
|
|
172
|
+
: acc,
|
|
173
|
+
[]
|
|
174
|
+
);
|
|
178
175
|
}
|
|
179
176
|
if (constants.RECEIVE_OFFER === action.type) {
|
|
180
177
|
const { autoship, autoship_by_default, in_stock, offer: offerEl } = action.payload;
|
|
@@ -189,20 +186,6 @@ export const optedin = (state = [], action) => {
|
|
|
189
186
|
state
|
|
190
187
|
);
|
|
191
188
|
}
|
|
192
|
-
|
|
193
|
-
if (constants.SETUP_PRODUCT === action.type) {
|
|
194
|
-
const productIds = action.payload.variants.map(variant => variant.id).map(id => `${id}`);
|
|
195
|
-
const sellingPlanGroup = getOGSellingPlanGroup(action.payload);
|
|
196
|
-
const frequencies = sellingPlanGroup?.selling_plans?.map(({ id }) => `${id}`);
|
|
197
|
-
return state.map(cur => {
|
|
198
|
-
// if the product is in the list of variants and its frequency isn't a valid selling plan, replace with the first valid selling plan
|
|
199
|
-
cur.frequency =
|
|
200
|
-
productIds.some(id => id === cur.id) && !frequencies.some(freq => freq === cur.frequency)
|
|
201
|
-
? frequencies[0]
|
|
202
|
-
: cur.frequency;
|
|
203
|
-
return cur;
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
189
|
return coreOptedin(state, action);
|
|
207
190
|
};
|
|
208
191
|
|