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