thm-p3-configurator 0.0.46 → 0.0.47
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/src/shared/__components__/Form/NumericInput.js +9 -8
- package/dist/src/shared/__containers__/DiscountProductsSelector.js +47 -14
- package/dist/src/shared/__containers__/internal/InternalDiscountCodeSelector.js +5 -0
- package/dist/src/shared/__context__/OrderSessionContext.js +15 -0
- package/package.json +1 -1
|
@@ -63,6 +63,7 @@ _reactNumericInput.default.style.plus.background = MAIN_THEME;
|
|
|
63
63
|
_reactNumericInput.default.style.minus.background = MAIN_THEME;
|
|
64
64
|
const NumericInput = _ref => {
|
|
65
65
|
let {
|
|
66
|
+
value: propValue,
|
|
66
67
|
defaultValue,
|
|
67
68
|
onChange,
|
|
68
69
|
min = 1,
|
|
@@ -73,11 +74,14 @@ const NumericInput = _ref => {
|
|
|
73
74
|
name,
|
|
74
75
|
label
|
|
75
76
|
} = _ref;
|
|
76
|
-
const [
|
|
77
|
+
const [internalValue, setInternalValue] = (0, _react.useState)(defaultValue);
|
|
77
78
|
const inputRef = (0, _react.useRef)();
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const value = propValue !== undefined ? propValue : internalValue;
|
|
80
|
+
const handleChange = newValue => {
|
|
81
|
+
if (propValue === undefined) {
|
|
82
|
+
setInternalValue(newValue);
|
|
83
|
+
}
|
|
84
|
+
onChange(newValue);
|
|
81
85
|
};
|
|
82
86
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, label && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, ' ', /*#__PURE__*/_react.default.createElement("label", {
|
|
83
87
|
htmlFor: name,
|
|
@@ -94,10 +98,7 @@ const NumericInput = _ref => {
|
|
|
94
98
|
maxLength: 4,
|
|
95
99
|
required: isRequired,
|
|
96
100
|
onChange: handleChange,
|
|
97
|
-
disabled: isDisabled
|
|
98
|
-
// Inline styling to override libray
|
|
99
|
-
,
|
|
100
|
-
|
|
101
|
+
disabled: isDisabled,
|
|
101
102
|
style: {
|
|
102
103
|
wrap: {
|
|
103
104
|
width: '6.5rem',
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.weak-map.js");
|
|
3
4
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
4
5
|
require("core-js/modules/esnext.iterator.find.js");
|
|
5
6
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
6
7
|
require("core-js/modules/esnext.iterator.map.js");
|
|
7
8
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
+
require("core-js/modules/es.weak-map.js");
|
|
8
10
|
Object.defineProperty(exports, "__esModule", {
|
|
9
11
|
value: true
|
|
10
12
|
});
|
|
@@ -14,7 +16,7 @@ require("core-js/modules/esnext.iterator.find.js");
|
|
|
14
16
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
15
17
|
require("core-js/modules/esnext.iterator.map.js");
|
|
16
18
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
17
|
-
var _react =
|
|
19
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
18
20
|
var _queries = require("../__api__/queries");
|
|
19
21
|
var _NumericInput = _interopRequireDefault(require("../__components__/Form/NumericInput"));
|
|
20
22
|
var _FormulaContext = require("../__context__/FormulaContext");
|
|
@@ -25,6 +27,31 @@ function _interopRequireDefault(e) {
|
|
|
25
27
|
default: e
|
|
26
28
|
};
|
|
27
29
|
}
|
|
30
|
+
function _getRequireWildcardCache(e) {
|
|
31
|
+
if ("function" != typeof WeakMap) return null;
|
|
32
|
+
var r = new WeakMap(),
|
|
33
|
+
t = new WeakMap();
|
|
34
|
+
return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
|
|
35
|
+
return e ? t : r;
|
|
36
|
+
})(e);
|
|
37
|
+
}
|
|
38
|
+
function _interopRequireWildcard(e, r) {
|
|
39
|
+
if (!r && e && e.__esModule) return e;
|
|
40
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return {
|
|
41
|
+
default: e
|
|
42
|
+
};
|
|
43
|
+
var t = _getRequireWildcardCache(r);
|
|
44
|
+
if (t && t.has(e)) return t.get(e);
|
|
45
|
+
var n = {
|
|
46
|
+
__proto__: null
|
|
47
|
+
},
|
|
48
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
49
|
+
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
50
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
51
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
|
|
52
|
+
}
|
|
53
|
+
return n.default = e, t && t.set(e, n), n;
|
|
54
|
+
}
|
|
28
55
|
const DiscountProductsSelector = () => {
|
|
29
56
|
const [{
|
|
30
57
|
licensePlate,
|
|
@@ -34,7 +61,8 @@ const DiscountProductsSelector = () => {
|
|
|
34
61
|
executionAnswer2,
|
|
35
62
|
priceCalculationDate,
|
|
36
63
|
discountCode,
|
|
37
|
-
selectedDiscountedProducts
|
|
64
|
+
selectedDiscountedProducts,
|
|
65
|
+
discountsInitialized
|
|
38
66
|
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
39
67
|
const formula = (0, _FormulaContext.useFormula)();
|
|
40
68
|
const {
|
|
@@ -49,6 +77,22 @@ const DiscountProductsSelector = () => {
|
|
|
49
77
|
priceCalculationDate,
|
|
50
78
|
discountCode
|
|
51
79
|
});
|
|
80
|
+
(0, _react.useEffect)(() => {
|
|
81
|
+
if (!discountsInitialized && (discountProducts === null || discountProducts === void 0 ? void 0 : discountProducts.length) > 0) {
|
|
82
|
+
discountProducts.forEach(product => {
|
|
83
|
+
dispatch({
|
|
84
|
+
type: _OrderSessionContext.orderSessionActions.ADD_DISCOUNTED_PRODUCT,
|
|
85
|
+
payload: {
|
|
86
|
+
articleNumber: product === null || product === void 0 ? void 0 : product.articleNumber,
|
|
87
|
+
quantity: 1
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
dispatch({
|
|
92
|
+
type: _OrderSessionContext.orderSessionActions.DISCOUNTS_INITIALIZED
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}, [discountProducts, discountsInitialized, dispatch]);
|
|
52
96
|
const handleProductUpdated = _ref => {
|
|
53
97
|
let {
|
|
54
98
|
articleNumber,
|
|
@@ -74,17 +118,6 @@ const DiscountProductsSelector = () => {
|
|
|
74
118
|
if (!(discountProducts !== null && discountProducts !== void 0 && discountProducts.length)) {
|
|
75
119
|
return null;
|
|
76
120
|
}
|
|
77
|
-
if (selectedDiscountedProducts.length === 0 && discountProducts.length > 0) {
|
|
78
|
-
discountProducts.forEach(product => {
|
|
79
|
-
dispatch({
|
|
80
|
-
type: _OrderSessionContext.orderSessionActions.ADD_DISCOUNTED_PRODUCT,
|
|
81
|
-
payload: {
|
|
82
|
-
articleNumber: product === null || product === void 0 ? void 0 : product.articleNumber,
|
|
83
|
-
quantity: 1
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
121
|
return /*#__PURE__*/_react.default.createElement("ol", null, discountProducts === null || discountProducts === void 0 ? void 0 : discountProducts.map(product => {
|
|
89
122
|
const selectedProductAmount = selectedDiscountedProducts.find(selectedProduct => (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.articleNumber) === (product === null || product === void 0 ? void 0 : product.articleNumber));
|
|
90
123
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
@@ -92,7 +125,7 @@ const DiscountProductsSelector = () => {
|
|
|
92
125
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
93
126
|
className: (0, _helpers__.withStyle)('d-flex justify-content-between align-items-center mb-1')
|
|
94
127
|
}, ' ', product === null || product === void 0 ? void 0 : product.name, " (", !(product !== null && product !== void 0 && product.price) ? 'Gratis' : (0, _helpers__.formatPrice)(product.price), ")", /*#__PURE__*/_react.default.createElement(_NumericInput.default, {
|
|
95
|
-
|
|
128
|
+
value: (selectedProductAmount === null || selectedProductAmount === void 0 ? void 0 : selectedProductAmount.quantity) || 0,
|
|
96
129
|
isDisabled: false,
|
|
97
130
|
onChange: quantity => handleProductUpdated({
|
|
98
131
|
quantity,
|
|
@@ -48,6 +48,11 @@ const InternalDiscountCodeSelector = () => {
|
|
|
48
48
|
discountCode: codeOption === null || codeOption === void 0 ? void 0 : codeOption.value
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
+
if (!codeOption) {
|
|
52
|
+
dispatch({
|
|
53
|
+
type: _OrderSessionContext.orderSessionActions.DISCOUNTS_REMOVED
|
|
54
|
+
});
|
|
55
|
+
}
|
|
51
56
|
};
|
|
52
57
|
if (isLoadingDiscounts || !Array.isArray(discounts)) return null;
|
|
53
58
|
const selectedDiscountCode = discounts.find(discount => (discount === null || discount === void 0 ? void 0 : discount.code) === discountCode);
|
|
@@ -114,6 +114,7 @@ const INITIAL_ORDER_SESSION_STATE = {
|
|
|
114
114
|
selectedCableset: null,
|
|
115
115
|
selectedCombiset: null,
|
|
116
116
|
selectedDiscountedProducts: [],
|
|
117
|
+
discountsInitialized: false,
|
|
117
118
|
selectedBoardComputer: null,
|
|
118
119
|
isBoardComputerDeselected: false,
|
|
119
120
|
selectedBranch: null,
|
|
@@ -164,6 +165,8 @@ const orderSessionActions = exports.orderSessionActions = {
|
|
|
164
165
|
SET_SELECTED_CABLESET: 'SET_SELECTED_CABLESET',
|
|
165
166
|
SET_SELECTED_COMBISET: 'SET_SELECTED_COMBISET',
|
|
166
167
|
ADD_DISCOUNTED_PRODUCT: 'ADD_DISCOUNTED_PRODUCT',
|
|
168
|
+
DISCOUNTS_INITIALIZED: 'DISCOUNTS_INITIALIZED',
|
|
169
|
+
DISCOUNTS_REMOVED: 'DISCOUNTS_REMOVED',
|
|
167
170
|
REMOVE_DISCOUNTED_PRODUCT: 'REMOVE_DISCOUNTED_PRODUCT',
|
|
168
171
|
ADD_EXTRA: 'ADD_EXTRA',
|
|
169
172
|
REMOVE_EXTRA: 'REMOVE_EXTRA',
|
|
@@ -694,6 +697,18 @@ const orderSessionReducer = (state, action) => {
|
|
|
694
697
|
selectedDiscountedProducts: ((_state$selectedDiscou = state === null || state === void 0 ? void 0 : state.selectedDiscountedProducts) !== null && _state$selectedDiscou !== void 0 ? _state$selectedDiscou : []).filter(product => (product === null || product === void 0 ? void 0 : product.articleNumber) !== articleNumber)
|
|
695
698
|
});
|
|
696
699
|
}
|
|
700
|
+
case orderSessionActions.DISCOUNTS_INITIALIZED:
|
|
701
|
+
{
|
|
702
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
703
|
+
discountsInitialized: true
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
case orderSessionActions.DISCOUNTS_REMOVED:
|
|
707
|
+
{
|
|
708
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
709
|
+
discountsInitialized: false
|
|
710
|
+
});
|
|
711
|
+
}
|
|
697
712
|
case orderSessionActions.ADD_DISCOUNTED_PRODUCT:
|
|
698
713
|
{
|
|
699
714
|
var _state$selectedDiscou3;
|