@thecb/components 7.11.0-beta.1 → 7.11.0-beta.3
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 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +19 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/partial-amount-form/PartialAmountForm.js +17 -1
- package/src/components/molecules/partial-amount-form/PartialAmountForm.state.js +1 -0
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,22 @@ 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
|
+
console.log("item amount in form is", itemAmount);
|
|
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);
|
|
46528
|
+
errorMessages[numberLessThanOrEqualTo.error] = maxAmountError;
|
|
46529
|
+
}
|
|
46530
|
+
|
|
46531
|
+
console.log("error messages are", errorMessages);
|
|
46532
|
+
return errorMessages;
|
|
46533
|
+
};
|
|
46534
|
+
|
|
46518
46535
|
var lineItemsNew = Array.isArray(lineItems) ? lineItems : [];
|
|
46519
46536
|
return /*#__PURE__*/React.createElement(FormContainer$1, {
|
|
46520
46537
|
variant: variant,
|
|
@@ -46533,7 +46550,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
|
|
|
46533
46550
|
field: fields[li.id],
|
|
46534
46551
|
fieldActions: actions.fields[li.id],
|
|
46535
46552
|
showErrors: showErrors,
|
|
46536
|
-
errorMessages:
|
|
46553
|
+
errorMessages: getPartialAmountFormErrors(maximum, li.amount),
|
|
46537
46554
|
style: {
|
|
46538
46555
|
textAlign: "right"
|
|
46539
46556
|
},
|
|
@@ -46563,6 +46580,7 @@ var createPartialAmountFormState = function createPartialAmountFormState(lineIte
|
|
|
46563
46580
|
paymentMax = !maximum || item.amount < maximum ? item.amount : maximum;
|
|
46564
46581
|
}
|
|
46565
46582
|
|
|
46583
|
+
console.log("payment max is", paymentMax);
|
|
46566
46584
|
var validators = [required(), validateSum(numberGreaterThanOrEqualTo(minimum), lineItems.filter(function (lineItem) {
|
|
46567
46585
|
return lineItem != item;
|
|
46568
46586
|
}).reduce(function (acc, curr) {
|