@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.esm.js
CHANGED
|
@@ -46500,6 +46500,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46500
46500
|
maximum = _ref.maximum,
|
|
46501
46501
|
_ref$minimum = _ref.minimum,
|
|
46502
46502
|
minimum = _ref$minimum === void 0 ? 1 : _ref$minimum,
|
|
46503
|
+
blockPartialPaymentOverpay = _ref.blockPartialPaymentOverpay,
|
|
46503
46504
|
clearOnDismount = _ref.clearOnDismount,
|
|
46504
46505
|
fields = _ref.fields,
|
|
46505
46506
|
actions = _ref.actions,
|
|
@@ -46515,6 +46516,19 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46515
46516
|
}
|
|
46516
46517
|
|
|
46517
46518
|
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);
|
|
46519
|
+
|
|
46520
|
+
var getPartialAmountFormErrors = function getPartialAmountFormErrors(maximum, itemAmount) {
|
|
46521
|
+
var errorMessages = amountErrors;
|
|
46522
|
+
|
|
46523
|
+
if (blockPartialPaymentOverpay) {
|
|
46524
|
+
var maxAmount = !maximum || itemAmount < maximum ? itemAmount : maximum;
|
|
46525
|
+
var maxAmountError = "There is a maximum payment of ".concat(displayCurrency(maxAmount));
|
|
46526
|
+
errorMessages[numberLessThanOrEqualTo.error] = maxAmountError;
|
|
46527
|
+
}
|
|
46528
|
+
|
|
46529
|
+
return errorMessages;
|
|
46530
|
+
};
|
|
46531
|
+
|
|
46518
46532
|
var lineItemsNew = Array.isArray(lineItems) ? lineItems : [];
|
|
46519
46533
|
return /*#__PURE__*/React.createElement(FormContainer$1, {
|
|
46520
46534
|
variant: variant,
|
|
@@ -46533,7 +46547,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46533
46547
|
field: fields[li.id],
|
|
46534
46548
|
fieldActions: actions.fields[li.id],
|
|
46535
46549
|
showErrors: showErrors,
|
|
46536
|
-
errorMessages:
|
|
46550
|
+
errorMessages: getPartialAmountFormErrors(maximum, li.amount),
|
|
46537
46551
|
style: {
|
|
46538
46552
|
textAlign: "right"
|
|
46539
46553
|
},
|
|
@@ -46554,6 +46568,9 @@ var createPartialAmountFormState = function createPartialAmountFormState(lineIte
|
|
|
46554
46568
|
var minimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
46555
46569
|
var blockPartialPaymentOverpay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
46556
46570
|
var formConfig = lineItems.reduce(function (acc, item) {
|
|
46571
|
+
console.log("maximum is", maximum);
|
|
46572
|
+
console.log("item amount is", item.amount);
|
|
46573
|
+
console.log("block payment overpay", blockPartialPaymentOverpay);
|
|
46557
46574
|
var paymentMax = maximum;
|
|
46558
46575
|
|
|
46559
46576
|
if (blockPartialPaymentOverpay) {
|
|
@@ -46567,7 +46584,7 @@ var createPartialAmountFormState = function createPartialAmountFormState(lineIte
|
|
|
46567
46584
|
}, []))];
|
|
46568
46585
|
|
|
46569
46586
|
if (!!maximum || blockPartialPaymentOverpay) {
|
|
46570
|
-
validators.push(validateSum(numberLessThanOrEqualTo(
|
|
46587
|
+
validators.push(validateSum(numberLessThanOrEqualTo(paymentMax), lineItems.filter(function (lineItem) {
|
|
46571
46588
|
return lineItem != item;
|
|
46572
46589
|
}).reduce(function (acc, curr) {
|
|
46573
46590
|
return [].concat(_toConsumableArray(acc), [curr.id]);
|