@thecb/components 7.11.0-beta.0 → 7.11.0-beta.2
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/index.cjs.js +19 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +19 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/partial-amount-form/PartialAmountForm.js +14 -1
- package/src/components/molecules/partial-amount-form/PartialAmountForm.state.js +4 -1
package/dist/index.cjs.js
CHANGED
|
@@ -46508,6 +46508,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46508
46508
|
maximum = _ref.maximum,
|
|
46509
46509
|
_ref$minimum = _ref.minimum,
|
|
46510
46510
|
minimum = _ref$minimum === void 0 ? 1 : _ref$minimum,
|
|
46511
|
+
blockPartialPaymentOverpay = _ref.blockPartialPaymentOverpay,
|
|
46511
46512
|
clearOnDismount = _ref.clearOnDismount,
|
|
46512
46513
|
fields = _ref.fields,
|
|
46513
46514
|
actions = _ref.actions,
|
|
@@ -46523,6 +46524,19 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46523
46524
|
}
|
|
46524
46525
|
|
|
46525
46526
|
var amountErrors = (_amountErrors = {}, _defineProperty(_amountErrors, required.error, "Amount is required"), _defineProperty(_amountErrors, numberGreaterThanOrEqualTo.error, "There is a minimum payment of ".concat(displayCurrency(minimum))), _defineProperty(_amountErrors, numberLessThanOrEqualTo.error, "There is a maximum payment of ".concat(displayCurrency(maximum))), _amountErrors);
|
|
46527
|
+
|
|
46528
|
+
var getPartialAmountFormErrors = function getPartialAmountFormErrors(maximum, itemAmount) {
|
|
46529
|
+
var errorMessages = amountErrors;
|
|
46530
|
+
|
|
46531
|
+
if (blockPartialPaymentOverpay) {
|
|
46532
|
+
var maxAmount = !maximum || itemAmount < maximum ? itemAmount : maximum;
|
|
46533
|
+
var maxAmountError = "There is a maximum payment of ".concat(displayCurrency(maxAmount));
|
|
46534
|
+
errorMessages[numberLessThanOrEqualTo.error] = maxAmountError;
|
|
46535
|
+
}
|
|
46536
|
+
|
|
46537
|
+
return errorMessages;
|
|
46538
|
+
};
|
|
46539
|
+
|
|
46526
46540
|
var lineItemsNew = Array.isArray(lineItems) ? lineItems : [];
|
|
46527
46541
|
return /*#__PURE__*/React__default.createElement(FormContainer$1, {
|
|
46528
46542
|
variant: variant,
|
|
@@ -46541,7 +46555,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46541
46555
|
field: fields[li.id],
|
|
46542
46556
|
fieldActions: actions.fields[li.id],
|
|
46543
46557
|
showErrors: showErrors,
|
|
46544
|
-
errorMessages:
|
|
46558
|
+
errorMessages: getPartialAmountFormErrors(maximum, li.amount),
|
|
46545
46559
|
style: {
|
|
46546
46560
|
textAlign: "right"
|
|
46547
46561
|
},
|
|
@@ -46562,6 +46576,9 @@ var createPartialAmountFormState = function createPartialAmountFormState(lineIte
|
|
|
46562
46576
|
var minimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
46563
46577
|
var blockPartialPaymentOverpay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
46564
46578
|
var formConfig = lineItems.reduce(function (acc, item) {
|
|
46579
|
+
console.log("maximum is", maximum);
|
|
46580
|
+
console.log("item amount is", item.amount);
|
|
46581
|
+
console.log("block payment overpay", blockPartialPaymentOverpay);
|
|
46565
46582
|
var paymentMax = maximum;
|
|
46566
46583
|
|
|
46567
46584
|
if (blockPartialPaymentOverpay) {
|
|
@@ -46575,7 +46592,7 @@ var createPartialAmountFormState = function createPartialAmountFormState(lineIte
|
|
|
46575
46592
|
}, []))];
|
|
46576
46593
|
|
|
46577
46594
|
if (!!maximum || blockPartialPaymentOverpay) {
|
|
46578
|
-
validators.push(validateSum(numberLessThanOrEqualTo(
|
|
46595
|
+
validators.push(validateSum(numberLessThanOrEqualTo(paymentMax), lineItems.filter(function (lineItem) {
|
|
46579
46596
|
return lineItem != item;
|
|
46580
46597
|
}).reduce(function (acc, curr) {
|
|
46581
46598
|
return [].concat(_toConsumableArray(acc), [curr.id]);
|