thm-p3-configurator 0.0.355 → 0.0.357
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.
|
@@ -51,6 +51,8 @@ const DecimalInput = _ref => {
|
|
|
51
51
|
value,
|
|
52
52
|
name,
|
|
53
53
|
onClick = () => {},
|
|
54
|
+
onBlur = () => {},
|
|
55
|
+
onKeyDown = () => {},
|
|
54
56
|
isDisabled = false,
|
|
55
57
|
onChange = () => {},
|
|
56
58
|
isRequired = true,
|
|
@@ -93,6 +95,8 @@ const DecimalInput = _ref => {
|
|
|
93
95
|
value: displayValue,
|
|
94
96
|
disabled: isDisabled,
|
|
95
97
|
onChange: e => handleChange(e.target.value),
|
|
98
|
+
onBlur: onBlur,
|
|
99
|
+
onKeyDown: onKeyDown,
|
|
96
100
|
required: isRequired,
|
|
97
101
|
className: "".concat((0, _helpers__.withStyle)('form-control'), " ").concat(errorMessage ? (0, _helpers__.withStyle)('is-invalid') : '')
|
|
98
102
|
}), errorMessage && /*#__PURE__*/_react.default.createElement(_ErrorMessage.default, {
|
|
@@ -158,6 +158,7 @@ const parseDiscountValue = value => {
|
|
|
158
158
|
return Math.min(100, Math.max(0, parseInt(sanitized, 10)));
|
|
159
159
|
};
|
|
160
160
|
const formatDiscountDraft = value => value === null || value === undefined ? '' : value.toString();
|
|
161
|
+
const formatMontageRateDraft = value => value === null || value === undefined ? '' : value.toString();
|
|
161
162
|
const DeferredDiscountInput = _ref => {
|
|
162
163
|
let {
|
|
163
164
|
articleNumber,
|
|
@@ -201,6 +202,44 @@ const DeferredDiscountInput = _ref => {
|
|
|
201
202
|
}
|
|
202
203
|
}));
|
|
203
204
|
};
|
|
205
|
+
const DeferredMontageRateInput = _ref2 => {
|
|
206
|
+
let {
|
|
207
|
+
value,
|
|
208
|
+
isDisabled = false,
|
|
209
|
+
onCommit
|
|
210
|
+
} = _ref2;
|
|
211
|
+
const [draftValue, setDraftValue] = (0, _react.useState)(formatMontageRateDraft(value));
|
|
212
|
+
const isEditingRef = (0, _react.useRef)(false);
|
|
213
|
+
(0, _react.useEffect)(() => {
|
|
214
|
+
if (!isEditingRef.current) {
|
|
215
|
+
setDraftValue(formatMontageRateDraft(value));
|
|
216
|
+
}
|
|
217
|
+
}, [value]);
|
|
218
|
+
return /*#__PURE__*/_react.default.createElement(_DecimalInput.default, {
|
|
219
|
+
label: "Montage tarief",
|
|
220
|
+
className: "mb-0",
|
|
221
|
+
name: "montage-rate",
|
|
222
|
+
placeholder: "0.0",
|
|
223
|
+
value: draftValue,
|
|
224
|
+
min: 0,
|
|
225
|
+
step: "0.1",
|
|
226
|
+
isRequired: false,
|
|
227
|
+
isDisabled: isDisabled,
|
|
228
|
+
onChange: nextValue => {
|
|
229
|
+
isEditingRef.current = true;
|
|
230
|
+
setDraftValue(nextValue);
|
|
231
|
+
},
|
|
232
|
+
onBlur: () => {
|
|
233
|
+
isEditingRef.current = false;
|
|
234
|
+
onCommit(draftValue);
|
|
235
|
+
},
|
|
236
|
+
onKeyDown: event => {
|
|
237
|
+
if (event.key === 'Enter') {
|
|
238
|
+
event.currentTarget.blur();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
};
|
|
204
243
|
|
|
205
244
|
// ============================================================================
|
|
206
245
|
// MAIN COMPONENT
|
|
@@ -263,7 +302,7 @@ const ProductCartTable = () => {
|
|
|
263
302
|
});
|
|
264
303
|
}
|
|
265
304
|
};
|
|
266
|
-
const
|
|
305
|
+
const handleMontageRateCommit = value => {
|
|
267
306
|
if (value === null || value === undefined) {
|
|
268
307
|
dispatch({
|
|
269
308
|
type: _OrderSessionContext.orderSessionActions.SET_MONTAGE_RATE,
|
|
@@ -276,9 +315,7 @@ const ProductCartTable = () => {
|
|
|
276
315
|
|
|
277
316
|
// Permit typing both comma and dot decimals
|
|
278
317
|
const sanitized = value.toString().replace(/[^0-9.,-]/g, '').replace(',', '.');
|
|
279
|
-
|
|
280
|
-
// Allow a lone "0." or "0," while typing
|
|
281
|
-
if (sanitized === '' || sanitized === '0.' || sanitized === '0,') {
|
|
318
|
+
if (sanitized === '' || sanitized === '-' || sanitized === '.' || sanitized === ',') {
|
|
282
319
|
dispatch({
|
|
283
320
|
type: _OrderSessionContext.orderSessionActions.SET_MONTAGE_RATE,
|
|
284
321
|
payload: {
|
|
@@ -617,17 +654,10 @@ const ProductCartTable = () => {
|
|
|
617
654
|
}));
|
|
618
655
|
const renderMontageRateInput = () => isThc ? null : /*#__PURE__*/_react.default.createElement("div", {
|
|
619
656
|
className: (0, _helpers__.withStyle)('d-flex flex-column align-items-end justify-content-end gap-1')
|
|
620
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
621
|
-
|
|
622
|
-
className: "mb-0",
|
|
623
|
-
name: "montage-rate",
|
|
624
|
-
placeholder: "0.0",
|
|
625
|
-
value: montageRate === null || montageRate === undefined ? '' : montageRate.toString(),
|
|
626
|
-
min: 0,
|
|
627
|
-
step: "0.1",
|
|
628
|
-
isRequired: false,
|
|
657
|
+
}, /*#__PURE__*/_react.default.createElement(DeferredMontageRateInput, {
|
|
658
|
+
value: montageRate,
|
|
629
659
|
isDisabled: isMontageTariffFixed,
|
|
630
|
-
|
|
660
|
+
onCommit: handleMontageRateCommit
|
|
631
661
|
}), montageHourlyExcl !== null && /*#__PURE__*/_react.default.createElement("span", {
|
|
632
662
|
className: (0, _helpers__.withStyle)('small text-muted')
|
|
633
663
|
}, "Uurprijs: ", (0, _helpers__.formatPrice)(montageHourlyExcl)));
|
|
@@ -193,9 +193,6 @@ const MyBranchesSelect = _ref5 => {
|
|
|
193
193
|
const SingleOrderModalContent = _ref6 => {
|
|
194
194
|
let {
|
|
195
195
|
setSelectedBranchId,
|
|
196
|
-
isLocation,
|
|
197
|
-
authSession,
|
|
198
|
-
selectedBranch,
|
|
199
196
|
dispatch,
|
|
200
197
|
isTMGOrganization,
|
|
201
198
|
formula
|
|
@@ -230,17 +227,6 @@ const SingleOrderModalContent = _ref6 => {
|
|
|
230
227
|
label: "".concat(branch === null || branch === void 0 ? void 0 : branch.naamVestiging, " - ").concat(branch === null || branch === void 0 ? void 0 : branch.name),
|
|
231
228
|
value: branch === null || branch === void 0 ? void 0 : branch.entityId
|
|
232
229
|
}));
|
|
233
|
-
(0, _react.useEffect)(() => {
|
|
234
|
-
if (isLocation && !selectedBranch && !isTMGOrganization) {
|
|
235
|
-
var _authSession$branch;
|
|
236
|
-
dispatch({
|
|
237
|
-
type: _OrderSessionContext.orderSessionActions.SET_SELECTED_BRANCH,
|
|
238
|
-
payload: {
|
|
239
|
-
branchId: authSession === null || authSession === void 0 || (_authSession$branch = authSession.branch) === null || _authSession$branch === void 0 ? void 0 : _authSession$branch.entityId
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
}, [dispatch, isLocation, authSession, selectedBranch, isTMGOrganization]);
|
|
244
230
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, formula === _constants__.CONFIGURATOR_FORMULAS.TMG && /*#__PURE__*/_react.default.createElement(_DropdownInput.default, {
|
|
245
231
|
options: singleOrderBranchTypes === null || singleOrderBranchTypes === void 0 ? void 0 : singleOrderBranchTypes.map(branchType => ({
|
|
246
232
|
label: branchType === null || branchType === void 0 ? void 0 : branchType.title,
|
|
@@ -355,8 +341,8 @@ const InternalBranchSelectorModal = () => {
|
|
|
355
341
|
setIsDismissed(false);
|
|
356
342
|
}, [isSingleOrderPage]);
|
|
357
343
|
const isLocation = _react.default.useMemo(() => {
|
|
358
|
-
var _authSession$
|
|
359
|
-
const orgTypes = (authSession === null || authSession === void 0 || (_authSession$
|
|
344
|
+
var _authSession$branch;
|
|
345
|
+
const orgTypes = (authSession === null || authSession === void 0 || (_authSession$branch = authSession.branch) === null || _authSession$branch === void 0 ? void 0 : _authSession$branch.organisatietype) || [];
|
|
360
346
|
return orgTypes.some(typeId => {
|
|
361
347
|
var _branchTypes$byId;
|
|
362
348
|
return (branchTypes === null || branchTypes === void 0 || (_branchTypes$byId = branchTypes.byId) === null || _branchTypes$byId === void 0 || (_branchTypes$byId = _branchTypes$byId[typeId]) === null || _branchTypes$byId === void 0 ? void 0 : _branchTypes$byId.title) === _constants__.LOCATION_TYPE;
|
|
@@ -466,9 +452,6 @@ const InternalBranchSelectorModal = () => {
|
|
|
466
452
|
onClose: () => setIsDismissed(true)
|
|
467
453
|
}, isSingleOrderPage ? /*#__PURE__*/_react.default.createElement(SingleOrderModalContent, {
|
|
468
454
|
setSelectedBranchId: _setSelectedBranchId,
|
|
469
|
-
isLocation: isLocation,
|
|
470
|
-
authSession: authSession,
|
|
471
|
-
selectedBranch: selectedBranch,
|
|
472
455
|
dispatch: dispatch,
|
|
473
456
|
isTMGOrganization: isTMGOrganization,
|
|
474
457
|
formula: formula
|