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