@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 CHANGED
@@ -46508,6 +46508,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
46508
46508
  maximum = _ref.maximum,
46509
46509
  _ref$minimum = _ref.minimum,
46510
46510
  minimum = _ref$minimum === void 0 ? 1 : _ref$minimum,
46511
+ blockPartialPaymentOverpay = _ref.blockPartialPaymentOverpay,
46511
46512
  clearOnDismount = _ref.clearOnDismount,
46512
46513
  fields = _ref.fields,
46513
46514
  actions = _ref.actions,
@@ -46523,6 +46524,22 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
46523
46524
  }
46524
46525
 
46525
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
+
46528
+ var getPartialAmountFormErrors = function getPartialAmountFormErrors(maximum, itemAmount) {
46529
+ var errorMessages = amountErrors;
46530
+
46531
+ if (blockPartialPaymentOverpay) {
46532
+ console.log("item amount in form is", itemAmount);
46533
+ var maxAmount = !maximum || itemAmount < maximum ? itemAmount : maximum;
46534
+ var maxAmountError = "There is a maximum payment of ".concat(displayCurrency(maxAmount));
46535
+ console.log("max amount in form is", maxAmount);
46536
+ errorMessages[numberLessThanOrEqualTo.error] = maxAmountError;
46537
+ }
46538
+
46539
+ console.log("error messages are", errorMessages);
46540
+ return errorMessages;
46541
+ };
46542
+
46526
46543
  var lineItemsNew = Array.isArray(lineItems) ? lineItems : [];
46527
46544
  return /*#__PURE__*/React__default.createElement(FormContainer$1, {
46528
46545
  variant: variant,
@@ -46541,7 +46558,7 @@ var PartialAmountForm = function PartialAmountForm(_ref) {
46541
46558
  field: fields[li.id],
46542
46559
  fieldActions: actions.fields[li.id],
46543
46560
  showErrors: showErrors,
46544
- errorMessages: amountErrors,
46561
+ errorMessages: getPartialAmountFormErrors(maximum, li.amount),
46545
46562
  style: {
46546
46563
  textAlign: "right"
46547
46564
  },
@@ -46571,6 +46588,7 @@ var createPartialAmountFormState = function createPartialAmountFormState(lineIte
46571
46588
  paymentMax = !maximum || item.amount < maximum ? item.amount : maximum;
46572
46589
  }
46573
46590
 
46591
+ console.log("payment max is", paymentMax);
46574
46592
  var validators = [required(), validateSum(numberGreaterThanOrEqualTo(minimum), lineItems.filter(function (lineItem) {
46575
46593
  return lineItem != item;
46576
46594
  }).reduce(function (acc, curr) {