@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.cjs.js
CHANGED
|
@@ -46525,14 +46525,12 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46525
46525
|
|
|
46526
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
46527
|
|
|
46528
|
-
var getPartialAmountFormErrors = function getPartialAmountFormErrors(
|
|
46528
|
+
var getPartialAmountFormErrors = function getPartialAmountFormErrors(itemAmount) {
|
|
46529
46529
|
var errorMessages = amountErrors;
|
|
46530
46530
|
|
|
46531
46531
|
if (blockPartialPaymentOverpay) {
|
|
46532
46532
|
console.log("item amount in form is", itemAmount);
|
|
46533
|
-
var
|
|
46534
|
-
var maxAmountError = "There is a maximum payment of ".concat(displayCurrency(maxAmount));
|
|
46535
|
-
console.log("max amount in form is", maxAmount);
|
|
46533
|
+
var maxAmountError = "There is a maximum payment of ".concat(displayCurrency(itemAmount));
|
|
46536
46534
|
return _objectSpread2(_objectSpread2({}, errorMessages), {}, _defineProperty({}, numberLessThanOrEqualTo.error, maxAmountError));
|
|
46537
46535
|
}
|
|
46538
46536
|
|
|
@@ -46558,7 +46556,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46558
46556
|
field: fields[li.id],
|
|
46559
46557
|
fieldActions: actions.fields[li.id],
|
|
46560
46558
|
showErrors: showErrors,
|
|
46561
|
-
errorMessages: getPartialAmountFormErrors(
|
|
46559
|
+
errorMessages: getPartialAmountFormErrors(li.amount),
|
|
46562
46560
|
style: {
|
|
46563
46561
|
textAlign: "right"
|
|
46564
46562
|
},
|
|
@@ -46578,34 +46576,28 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46578
46576
|
var createPartialAmountFormState = function createPartialAmountFormState(lineItems, maximum) {
|
|
46579
46577
|
var minimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
46580
46578
|
var blockPartialPaymentOverpay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
46581
|
-
|
|
46582
|
-
var getPaymentMax = function getPaymentMax(maximum, itemAmount) {
|
|
46583
|
-
if (blockPartialPaymentOverpay) {
|
|
46584
|
-
return !maximum || itemAmount < maximum ? itemAmount : maximum;
|
|
46585
|
-
}
|
|
46586
|
-
|
|
46587
|
-
return maximum;
|
|
46588
|
-
};
|
|
46589
|
-
|
|
46590
46579
|
var formConfig = lineItems.reduce(function (acc, item) {
|
|
46591
46580
|
console.log("maximum is", maximum);
|
|
46592
46581
|
console.log("item amount is", item.amount);
|
|
46593
46582
|
console.log("block payment overpay", blockPartialPaymentOverpay);
|
|
46594
|
-
console.log("payment max is", paymentMax);
|
|
46595
46583
|
var validators = [required(), validateSum(numberGreaterThanOrEqualTo(minimum), lineItems.filter(function (lineItem) {
|
|
46596
46584
|
return lineItem != item;
|
|
46597
46585
|
}).reduce(function (acc, curr) {
|
|
46598
46586
|
return [].concat(_toConsumableArray(acc), [curr.id]);
|
|
46599
46587
|
}, []))];
|
|
46600
46588
|
|
|
46601
|
-
if (!!maximum
|
|
46602
|
-
validators.push(validateSum(numberLessThanOrEqualTo(
|
|
46589
|
+
if (!!maximum) {
|
|
46590
|
+
validators.push(validateSum(numberLessThanOrEqualTo(maximum), lineItems.filter(function (lineItem) {
|
|
46603
46591
|
return lineItem != item;
|
|
46604
46592
|
}).reduce(function (acc, curr) {
|
|
46605
46593
|
return [].concat(_toConsumableArray(acc), [curr.id]);
|
|
46606
46594
|
}, [])));
|
|
46607
46595
|
}
|
|
46608
46596
|
|
|
46597
|
+
if (blockPartialPaymentOverpay) {
|
|
46598
|
+
validators.push(numberLessThanOrEqualTo(item.amount));
|
|
46599
|
+
}
|
|
46600
|
+
|
|
46609
46601
|
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, item.id, {
|
|
46610
46602
|
validators: validators,
|
|
46611
46603
|
constraints: [onlyNaturals()],
|