@thecb/components 7.11.0-beta.5 → 7.11.0-beta.7
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 +9 -17
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -17
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/partial-amount-form/PartialAmountForm.js +3 -5
- package/src/components/molecules/partial-amount-form/PartialAmountForm.state.js +5 -9
package/dist/index.esm.js
CHANGED
|
@@ -46517,14 +46517,12 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46517
46517
|
|
|
46518
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
46519
|
|
|
46520
|
-
var getPartialAmountFormErrors = function getPartialAmountFormErrors(
|
|
46520
|
+
var getPartialAmountFormErrors = function getPartialAmountFormErrors(itemAmount) {
|
|
46521
46521
|
var errorMessages = amountErrors;
|
|
46522
46522
|
|
|
46523
46523
|
if (blockPartialPaymentOverpay) {
|
|
46524
46524
|
console.log("item amount in form is", itemAmount);
|
|
46525
|
-
var
|
|
46526
|
-
var maxAmountError = "There is a maximum payment of ".concat(displayCurrency(maxAmount));
|
|
46527
|
-
console.log("max amount in form is", maxAmount);
|
|
46525
|
+
var maxAmountError = "There is a maximum payment of ".concat(displayCurrency(itemAmount));
|
|
46528
46526
|
return _objectSpread2(_objectSpread2({}, errorMessages), {}, _defineProperty({}, numberLessThanOrEqualTo.error, maxAmountError));
|
|
46529
46527
|
}
|
|
46530
46528
|
|
|
@@ -46550,7 +46548,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46550
46548
|
field: fields[li.id],
|
|
46551
46549
|
fieldActions: actions.fields[li.id],
|
|
46552
46550
|
showErrors: showErrors,
|
|
46553
|
-
errorMessages: getPartialAmountFormErrors(
|
|
46551
|
+
errorMessages: getPartialAmountFormErrors(li.amount),
|
|
46554
46552
|
style: {
|
|
46555
46553
|
textAlign: "right"
|
|
46556
46554
|
},
|
|
@@ -46570,34 +46568,28 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46570
46568
|
var createPartialAmountFormState = function createPartialAmountFormState(lineItems, maximum) {
|
|
46571
46569
|
var minimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
46572
46570
|
var blockPartialPaymentOverpay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
46573
|
-
|
|
46574
|
-
var getPaymentMax = function getPaymentMax(maximum, itemAmount) {
|
|
46575
|
-
if (blockPartialPaymentOverpay) {
|
|
46576
|
-
return !maximum || itemAmount < maximum ? itemAmount : maximum;
|
|
46577
|
-
}
|
|
46578
|
-
|
|
46579
|
-
return maximum;
|
|
46580
|
-
};
|
|
46581
|
-
|
|
46582
46571
|
var formConfig = lineItems.reduce(function (acc, item) {
|
|
46583
46572
|
console.log("maximum is", maximum);
|
|
46584
46573
|
console.log("item amount is", item.amount);
|
|
46585
46574
|
console.log("block payment overpay", blockPartialPaymentOverpay);
|
|
46586
|
-
console.log("payment max is", paymentMax);
|
|
46587
46575
|
var validators = [required(), validateSum(numberGreaterThanOrEqualTo(minimum), lineItems.filter(function (lineItem) {
|
|
46588
46576
|
return lineItem != item;
|
|
46589
46577
|
}).reduce(function (acc, curr) {
|
|
46590
46578
|
return [].concat(_toConsumableArray(acc), [curr.id]);
|
|
46591
46579
|
}, []))];
|
|
46592
46580
|
|
|
46593
|
-
if (!!maximum
|
|
46594
|
-
validators.push(validateSum(numberLessThanOrEqualTo(
|
|
46581
|
+
if (!!maximum) {
|
|
46582
|
+
validators.push(validateSum(numberLessThanOrEqualTo(maximum), lineItems.filter(function (lineItem) {
|
|
46595
46583
|
return lineItem != item;
|
|
46596
46584
|
}).reduce(function (acc, curr) {
|
|
46597
46585
|
return [].concat(_toConsumableArray(acc), [curr.id]);
|
|
46598
46586
|
}, [])));
|
|
46599
46587
|
}
|
|
46600
46588
|
|
|
46589
|
+
if (blockPartialPaymentOverpay) {
|
|
46590
|
+
validators.push(numberLessThanOrEqualTo(item.amount));
|
|
46591
|
+
}
|
|
46592
|
+
|
|
46601
46593
|
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, item.id, {
|
|
46602
46594
|
validators: validators,
|
|
46603
46595
|
constraints: [onlyNaturals()],
|