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