@ordergroove/offers 2.46.0 → 2.46.1-alpha-PR-1280-4.55
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/dist/bundle-report.html +31 -31
- package/dist/offers.js +72 -72
- package/dist/offers.js.map +4 -4
- package/package.json +2 -2
- package/src/components/Offer.js +3 -1
- package/src/components/Price.js +31 -11
- package/src/components/__tests__/Price.spec.js +74 -1
- package/src/core/__tests__/experiments.spec.js +16 -3
- package/src/core/__tests__/reducer.spec.js +152 -1
- package/src/core/__tests__/selectors.spec.js +405 -1
- package/src/core/adapters.js +2 -0
- package/src/core/constants.js +7 -0
- package/src/core/experiments.js +3 -2
- package/src/core/reducer.ts +41 -9
- package/src/core/selectors.ts +66 -1
- package/src/core/types/api.ts +19 -1
- package/src/core/types/reducer.ts +14 -1
- package/src/shopify/__tests__/productPlan.spec.js +3 -3
- package/src/shopify/__tests__/shopifyMiddleware.spec.js +223 -6
- package/src/shopify/__tests__/shopifyReducer.spec.js +90 -17
- package/src/shopify/reducers/productPlans.ts +2 -1
- package/src/shopify/shopifyMiddleware.ts +44 -7
- package/src/shopify/shopifyReducer.ts +21 -0
- package/src/shopify/types/productPlan.ts +1 -0
|
@@ -36,6 +36,7 @@ import type {
|
|
|
36
36
|
OfferElement,
|
|
37
37
|
OptedInState,
|
|
38
38
|
OptInItem,
|
|
39
|
+
PriceState,
|
|
39
40
|
ReceiveOfferPayload,
|
|
40
41
|
SetupProductPayload
|
|
41
42
|
} from '../core/types/reducer';
|
|
@@ -289,6 +290,25 @@ export const optedin = (state: OptedInState = [], action): OptedInState => {
|
|
|
289
290
|
return coreOptedin(state, action);
|
|
290
291
|
};
|
|
291
292
|
|
|
293
|
+
export const price = (state: PriceState = {}, action): PriceState => {
|
|
294
|
+
if (constants.SETUP_PRODUCT === action.type) {
|
|
295
|
+
const {
|
|
296
|
+
payload: { product }
|
|
297
|
+
} = action as { payload: SetupProductPayload };
|
|
298
|
+
return (
|
|
299
|
+
product.variants?.reduce(
|
|
300
|
+
(acc, cur) => ({
|
|
301
|
+
...acc,
|
|
302
|
+
[cur.id]: { value: cur.price }
|
|
303
|
+
}),
|
|
304
|
+
state
|
|
305
|
+
) || state
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return state;
|
|
310
|
+
};
|
|
311
|
+
|
|
292
312
|
export const productOffer = (state = {}, _action) => state;
|
|
293
313
|
|
|
294
314
|
export const productPlans = (state = {}, action) => {
|
|
@@ -352,6 +372,7 @@ const reducer = combineReducers({
|
|
|
352
372
|
optedout,
|
|
353
373
|
previewStandardOffer,
|
|
354
374
|
previewUpsellOffer,
|
|
375
|
+
price,
|
|
355
376
|
productOffer,
|
|
356
377
|
productPlans,
|
|
357
378
|
productToSubscribe,
|