@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "7.11.0-beta.6",
3
+ "version": "7.11.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -38,21 +38,17 @@ const PartialAmountForm = ({
38
38
  )}`
39
39
  };
40
40
 
41
- const getPartialAmountFormErrors = (maximum, itemAmount) => {
41
+ const getPartialAmountFormErrors = itemAmount => {
42
42
  let errorMessages = amountErrors;
43
43
  if (blockPartialPaymentOverpay) {
44
- console.log("item amount in form is", itemAmount);
45
- let maxAmount = !maximum || itemAmount < maximum ? itemAmount : maximum;
46
44
  const maxAmountError = `There is a maximum payment of ${displayCurrency(
47
- maxAmount
45
+ itemAmount
48
46
  )}`;
49
- console.log("max amount in form is", maxAmount);
50
47
  return {
51
48
  ...errorMessages,
52
49
  [numberLessThanOrEqualTo.error]: maxAmountError
53
50
  };
54
51
  }
55
- console.log("error messages are", errorMessages);
56
52
  return errorMessages;
57
53
  };
58
54
 
@@ -72,7 +68,7 @@ const PartialAmountForm = ({
72
68
  field={fields[li.id]}
73
69
  fieldActions={actions.fields[li.id]}
74
70
  showErrors={showErrors}
75
- errorMessages={getPartialAmountFormErrors(maximum, li.amount)}
71
+ errorMessages={getPartialAmountFormErrors(li.amount)}
76
72
  style={{ textAlign: "right" }}
77
73
  placeholder="$0.00"
78
74
  formatter={moneyFormat}
@@ -13,17 +13,7 @@ export const createPartialAmountFormState = (
13
13
  minimum = 1,
14
14
  blockPartialPaymentOverpay = false
15
15
  ) => {
16
- const getPaymentMax = (maximum, itemAmount) => {
17
- if (blockPartialPaymentOverpay) {
18
- return !maximum || itemAmount < maximum ? itemAmount : maximum;
19
- }
20
- return maximum;
21
- };
22
16
  const formConfig = lineItems.reduce((acc, item) => {
23
- console.log("maximum is", maximum);
24
- console.log("item amount is", item.amount);
25
- console.log("block payment overpay", blockPartialPaymentOverpay);
26
-
27
17
  const validators = [
28
18
  required(),
29
19
  validateSum(
@@ -33,16 +23,19 @@ export const createPartialAmountFormState = (
33
23
  .reduce((acc, curr) => [...acc, curr.id], [])
34
24
  )
35
25
  ];
36
- if (!!maximum || blockPartialPaymentOverpay) {
26
+ if (!!maximum) {
37
27
  validators.push(
38
28
  validateSum(
39
- numberLessThanOrEqualTo(getPaymentMax(maximum, item.amount)),
29
+ numberLessThanOrEqualTo(maximum),
40
30
  lineItems
41
31
  .filter(lineItem => lineItem != item)
42
32
  .reduce((acc, curr) => [...acc, curr.id], [])
43
33
  )
44
34
  );
45
35
  }
36
+ if (blockPartialPaymentOverpay) {
37
+ validators.push(numberLessThanOrEqualTo(item.amount));
38
+ }
46
39
  return {
47
40
  ...acc,
48
41
  [item.id]: {