@ordergroove/offers 2.30.8 → 2.30.9-alpha-PR-723-4.41
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/README.md +10 -10
- package/dist/bundle-report.html +5 -5
- package/dist/examples.js +1 -1
- package/dist/examples.js.map +1 -1
- package/dist/offers.js +28 -28
- package/dist/offers.js.map +2 -2
- package/package.json +3 -3
- package/src/core/__tests__/descriptors.spec.js +20 -0
- package/src/core/descriptors.js +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordergroove/offers",
|
|
3
|
-
"version": "2.30.
|
|
3
|
+
"version": "2.30.9-alpha-PR-723-4.41+30d297f1",
|
|
4
4
|
"description": "offer state component",
|
|
5
5
|
"author": "Eugenio Lattanzio <eugenio63@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ordergroove/plush-toys#readme",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"throttle-debounce": "^2.1.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@ordergroove/offers-templates": "^0.5.
|
|
48
|
+
"@ordergroove/offers-templates": "^0.5.4-alpha-PR-723-4.58+30d297f1"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "30d297f1b9da4c83331549fd497445f21304581c"
|
|
51
51
|
}
|
|
@@ -284,3 +284,23 @@ describe('prepaidSubscribed', () => {
|
|
|
284
284
|
expect(descriptors.prepaidSubscribed(getPrepaidOptedinState('otherProduct', 3), ownProps)).toBe(false);
|
|
285
285
|
});
|
|
286
286
|
});
|
|
287
|
+
|
|
288
|
+
function getPrepaidOptionsState(options) {
|
|
289
|
+
return {
|
|
290
|
+
config: {
|
|
291
|
+
prepaidSellingPlans: {
|
|
292
|
+
[productId]: options
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
describe('hasPrepaidOptions', () => {
|
|
299
|
+
it('returns false when empty array', () => {
|
|
300
|
+
expect(descriptors.hasPrepaidOptions(getPrepaidOptionsState([]), ownProps)).toBe(false);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it('returns true when non-empty array', () => {
|
|
304
|
+
expect(descriptors.hasPrepaidOptions(getPrepaidOptionsState([{ numberShipments: 3 }]), ownProps)).toBe(true);
|
|
305
|
+
});
|
|
306
|
+
});
|
package/src/core/descriptors.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
makeSubscribedSelector,
|
|
3
|
+
makeOptedoutSelector,
|
|
4
|
+
makePrepaidSubscribedSelector,
|
|
5
|
+
makeProductPrepaidShipmentOptionsSelector
|
|
6
|
+
} from './selectors';
|
|
2
7
|
|
|
3
8
|
export const inStock = (state, ownProps) => (state.inStock || {})[(ownProps.product || {}).id];
|
|
4
9
|
export const eligible = (state, ownProps) => (state.autoshipEligible || {})[(ownProps.product || {}).id] || false;
|
|
@@ -23,6 +28,8 @@ export const prepaidEligible = (state, ownProps) => {
|
|
|
23
28
|
export const subscribed = (state, ownProps) => makeSubscribedSelector(ownProps.product)(state);
|
|
24
29
|
export const optedout = (state, ownProps) => makeOptedoutSelector(ownProps.product)(state);
|
|
25
30
|
export const prepaidSubscribed = (state, ownProps) => makePrepaidSubscribedSelector(ownProps.product)(state);
|
|
31
|
+
export const hasPrepaidOptions = (state, ownProps) =>
|
|
32
|
+
makeProductPrepaidShipmentOptionsSelector(ownProps.product.id)(state).length > 0;
|
|
26
33
|
|
|
27
34
|
export const hasUpcomingOrder = state => !!(state.nextUpcomingOrder && state.nextUpcomingOrder.public_id);
|
|
28
35
|
|