@thecb/components 7.11.0-beta.3 → 7.11.0-beta.5
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 +11 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +11 -8
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/partial-amount-form/PartialAmountForm.js +4 -1
- package/src/components/molecules/partial-amount-form/PartialAmountForm.state.js +8 -5
package/package.json
CHANGED
|
@@ -47,7 +47,10 @@ const PartialAmountForm = ({
|
|
|
47
47
|
maxAmount
|
|
48
48
|
)}`;
|
|
49
49
|
console.log("max amount in form is", maxAmount);
|
|
50
|
-
|
|
50
|
+
return {
|
|
51
|
+
...errorMessages,
|
|
52
|
+
[numberLessThanOrEqualTo.error]: maxAmountError
|
|
53
|
+
};
|
|
51
54
|
}
|
|
52
55
|
console.log("error messages are", errorMessages);
|
|
53
56
|
return errorMessages;
|
|
@@ -13,14 +13,17 @@ 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
|
+
};
|
|
16
22
|
const formConfig = lineItems.reduce((acc, item) => {
|
|
17
23
|
console.log("maximum is", maximum);
|
|
18
24
|
console.log("item amount is", item.amount);
|
|
19
25
|
console.log("block payment overpay", blockPartialPaymentOverpay);
|
|
20
|
-
|
|
21
|
-
if (blockPartialPaymentOverpay) {
|
|
22
|
-
paymentMax = !maximum || item.amount < maximum ? item.amount : maximum;
|
|
23
|
-
}
|
|
26
|
+
|
|
24
27
|
console.log("payment max is", paymentMax);
|
|
25
28
|
const validators = [
|
|
26
29
|
required(),
|
|
@@ -34,7 +37,7 @@ export const createPartialAmountFormState = (
|
|
|
34
37
|
if (!!maximum || blockPartialPaymentOverpay) {
|
|
35
38
|
validators.push(
|
|
36
39
|
validateSum(
|
|
37
|
-
numberLessThanOrEqualTo(
|
|
40
|
+
numberLessThanOrEqualTo(getPaymentMax(maximum, item.amount)),
|
|
38
41
|
lineItems
|
|
39
42
|
.filter(lineItem => lineItem != item)
|
|
40
43
|
.reduce((acc, curr) => [...acc, curr.id], [])
|