@thecb/components 3.4.0 → 3.5.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 +526 -97
- package/package.json +3 -3
- package/src/components/atoms/icons/AutopayOnIcon.js +28 -0
- package/src/components/atoms/icons/TimeoutImage.js +138 -0
- package/src/components/atoms/icons/icons.stories.js +3 -1
- package/src/components/atoms/icons/index.js +5 -1
- package/src/components/molecules/index.js +1 -0
- package/src/components/molecules/obligation/Obligation.js +58 -21
- package/src/components/molecules/obligation/modules/AmountModule.js +38 -30
- package/src/components/molecules/obligation/modules/AutopayModalModule.js +99 -0
- package/src/components/molecules/obligation/modules/AutopayModalModule.theme.js +9 -0
- package/src/components/molecules/obligation/modules/PaymentDetailsActions.js +110 -31
- package/src/components/molecules/partial-amount-form/PartialAmountForm.js +6 -2
- package/src/components/molecules/partial-amount-form/PartialAmountForm.state.js +2 -2
- package/src/components/molecules/timeout/Timeout.js +41 -0
- package/src/components/molecules/timeout/index.js +3 -0
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { Box, Cluster } from "../../../atoms/layouts";
|
|
3
3
|
import ButtonWithAction from "../../../atoms/button-with-action";
|
|
4
|
+
import { AutopayModalModule } from "./AutopayModalModule";
|
|
4
5
|
import { GHOST_GREY } from "../../../../constants/colors";
|
|
6
|
+
import AmountModule from "./AmountModule";
|
|
5
7
|
|
|
6
|
-
const PaymentDetailsActions = ({
|
|
8
|
+
const PaymentDetailsActions = ({
|
|
9
|
+
isMobile,
|
|
10
|
+
obligations,
|
|
11
|
+
config,
|
|
12
|
+
actions,
|
|
13
|
+
autoPayEnabled,
|
|
14
|
+
autoPayAvailable,
|
|
15
|
+
handleAutopayAction,
|
|
16
|
+
deactivatePaymentSchedule,
|
|
17
|
+
navigateToSettings,
|
|
18
|
+
autoPaySchedule
|
|
19
|
+
}) => {
|
|
7
20
|
const [isLoading, setIsLoading] = useState(false);
|
|
21
|
+
const [modalOpen, toggleModal] = useState(false);
|
|
8
22
|
const { obligationSlug } = config;
|
|
9
23
|
const { createPaymentFromProfile, setDetailedObligation } = actions;
|
|
10
24
|
const detailsSlug =
|
|
@@ -20,46 +34,111 @@ const PaymentDetailsActions = ({ isMobile, obligations, config, actions }) => {
|
|
|
20
34
|
};
|
|
21
35
|
return (
|
|
22
36
|
<Box
|
|
23
|
-
padding="16px 0 0"
|
|
37
|
+
padding={isMobile ? "0" : "16px 0 0"}
|
|
24
38
|
minWidth="100%"
|
|
25
39
|
borderSize="1px"
|
|
26
40
|
borderColor={GHOST_GREY}
|
|
27
41
|
borderWidthOverride="1px 0 0 0"
|
|
28
42
|
key={`${obligations[0].id}-actions`}
|
|
29
43
|
>
|
|
30
|
-
|
|
31
|
-
justify={isMobile ? "center" : "flex-end"}
|
|
32
|
-
align="center"
|
|
33
|
-
childGap="0"
|
|
34
|
-
>
|
|
44
|
+
{isMobile && (
|
|
35
45
|
<Box
|
|
36
|
-
padding=
|
|
37
|
-
|
|
46
|
+
padding="16px 24px"
|
|
47
|
+
borderSize="1px"
|
|
48
|
+
borderColor={GHOST_GREY}
|
|
49
|
+
borderWidthOverride="0 0 1px 0"
|
|
38
50
|
>
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
<Cluster justify="space-between" align="center" nowrap>
|
|
52
|
+
<Box padding="0" width="100%">
|
|
53
|
+
<AmountModule
|
|
54
|
+
totalAmountDue={obligations.reduce(
|
|
55
|
+
(acc, curr) => acc + curr.amountDue,
|
|
56
|
+
0
|
|
57
|
+
)}
|
|
58
|
+
autoPayEnabled={autoPayEnabled}
|
|
59
|
+
isMobile={isMobile}
|
|
60
|
+
deactivatePaymentSchedule={deactivatePaymentSchedule}
|
|
61
|
+
navigateToSettings={navigateToSettings}
|
|
62
|
+
autoPaySchedule={autoPaySchedule}
|
|
63
|
+
/>
|
|
64
|
+
</Box>
|
|
65
|
+
<Box padding="0" width="100%">
|
|
66
|
+
<ButtonWithAction
|
|
67
|
+
isLoading={isLoading}
|
|
68
|
+
action={() => handleClick(obligations)}
|
|
69
|
+
text="Pay Now"
|
|
70
|
+
variant={isMobile ? "smallSecondary" : "secondary"}
|
|
71
|
+
dataQa="Pay Now"
|
|
72
|
+
extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
|
|
73
|
+
/>
|
|
74
|
+
</Box>
|
|
75
|
+
</Cluster>
|
|
48
76
|
</Box>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
77
|
+
)}
|
|
78
|
+
<Box padding={isMobile ? "16px" : "0"}>
|
|
79
|
+
<Cluster
|
|
80
|
+
justify={isMobile ? "center" : "flex-end"}
|
|
81
|
+
align="center"
|
|
82
|
+
childGap="0"
|
|
52
83
|
>
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
84
|
+
<Box
|
|
85
|
+
padding={isMobile ? "0 8px 0 0" : "8px"}
|
|
86
|
+
extraStyles={isMobile && `flex-grow: 1;`}
|
|
87
|
+
>
|
|
88
|
+
<ButtonWithAction
|
|
89
|
+
variant="tertiary"
|
|
90
|
+
text={
|
|
91
|
+
config.type === "ACCOUNT"
|
|
92
|
+
? "Account Details"
|
|
93
|
+
: "Property Details"
|
|
94
|
+
}
|
|
95
|
+
action={handleDetailsClick}
|
|
96
|
+
dataQa="Account Details"
|
|
97
|
+
extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
|
|
98
|
+
/>
|
|
99
|
+
</Box>
|
|
100
|
+
<Box
|
|
101
|
+
padding={isMobile ? "0 8px 0 0" : "8px"}
|
|
102
|
+
extraStyles={isMobile && `flex-grow: 1;`}
|
|
103
|
+
>
|
|
104
|
+
{autoPayAvailable && !autoPayEnabled ? (
|
|
105
|
+
<ButtonWithAction
|
|
106
|
+
variant="tertiary"
|
|
107
|
+
text="Set Up Autopay"
|
|
108
|
+
action={handleAutopayAction}
|
|
109
|
+
dataQa="Set Up Autopay"
|
|
110
|
+
extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
|
|
111
|
+
/>
|
|
112
|
+
) : (
|
|
113
|
+
<AutopayModalModule
|
|
114
|
+
autoPayActive={autoPayEnabled}
|
|
115
|
+
autoPaySchedule={autoPaySchedule}
|
|
116
|
+
toggleModal={toggleModal}
|
|
117
|
+
modalOpen={modalOpen}
|
|
118
|
+
navigateToSettings={navigateToSettings}
|
|
119
|
+
deactivatePaymentSchedule={deactivatePaymentSchedule}
|
|
120
|
+
buttonLinkType
|
|
121
|
+
isMobile={isMobile}
|
|
122
|
+
/>
|
|
123
|
+
)}
|
|
124
|
+
</Box>
|
|
125
|
+
{!isMobile && (
|
|
126
|
+
<Box
|
|
127
|
+
padding={isMobile ? "0 0 0 8px" : "8px"}
|
|
128
|
+
extraStyles={isMobile && `flex-grow: 1;`}
|
|
129
|
+
>
|
|
130
|
+
<ButtonWithAction
|
|
131
|
+
isLoading={isLoading}
|
|
132
|
+
action={() => handleClick(obligations)}
|
|
133
|
+
text="Pay Now"
|
|
134
|
+
variant={isMobile ? "smallSecondary" : "secondary"}
|
|
135
|
+
dataQa="Pay Now"
|
|
136
|
+
extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
|
|
137
|
+
/>
|
|
138
|
+
</Box>
|
|
139
|
+
)}
|
|
140
|
+
</Cluster>
|
|
141
|
+
</Box>
|
|
63
142
|
</Box>
|
|
64
143
|
);
|
|
65
144
|
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
required,
|
|
4
|
+
numberGreaterThan,
|
|
5
|
+
numberLessThanOrEqualTo
|
|
6
|
+
} from "redux-freeform";
|
|
3
7
|
import { displayCurrency } from "../../../util/general";
|
|
4
8
|
import Text from "../../atoms/text";
|
|
5
9
|
import {
|
|
@@ -28,7 +32,7 @@ const PartialAmountForm = ({
|
|
|
28
32
|
[numberGreaterThan.error]: `Your total payment must be greater than ${displayCurrency(
|
|
29
33
|
minimum
|
|
30
34
|
)}`,
|
|
31
|
-
[
|
|
35
|
+
[numberLessThanOrEqualTo.error]: `Your total payment must be less than ${displayCurrency(
|
|
32
36
|
maximum
|
|
33
37
|
)}`
|
|
34
38
|
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
onlyNaturals,
|
|
5
5
|
validateSum,
|
|
6
6
|
numberGreaterThan,
|
|
7
|
-
|
|
7
|
+
numberLessThanOrEqualTo
|
|
8
8
|
} from "redux-freeform";
|
|
9
9
|
|
|
10
10
|
export const createPartialAmountFormState = (
|
|
@@ -25,7 +25,7 @@ export const createPartialAmountFormState = (
|
|
|
25
25
|
if (!!maximum) {
|
|
26
26
|
validators.push(
|
|
27
27
|
validateSum(
|
|
28
|
-
|
|
28
|
+
numberLessThanOrEqualTo(maximum),
|
|
29
29
|
lineItems
|
|
30
30
|
.filter(lineItem => lineItem != item)
|
|
31
31
|
.reduce((acc, curr) => [...acc, curr.id], [])
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box, Stack, Center, Cover } from "../../atoms/layouts";
|
|
3
|
+
import { TimeoutImage } from "../../atoms/icons";
|
|
4
|
+
import ButtonWithAction from "../../atoms/button-with-action";
|
|
5
|
+
import Heading from "../../atoms/heading";
|
|
6
|
+
import { FONT_WEIGHT_BOLD } from "../../../constants/style_constants";
|
|
7
|
+
import Paragraph from "../../atoms/paragraph";
|
|
8
|
+
|
|
9
|
+
const Timeout = ({ onLogout }) => (
|
|
10
|
+
<Cover>
|
|
11
|
+
<Center intrinsic>
|
|
12
|
+
<Box padding="0" maxWidth="500px">
|
|
13
|
+
<Stack childGap="32px" justify="center">
|
|
14
|
+
<Center intrinsic>
|
|
15
|
+
<TimeoutImage />
|
|
16
|
+
</Center>
|
|
17
|
+
<Box padding="0">
|
|
18
|
+
<Heading textAlign="center" weight={FONT_WEIGHT_BOLD}>
|
|
19
|
+
Request Timed Out
|
|
20
|
+
</Heading>
|
|
21
|
+
<Paragraph variant="pL" extraStyles={`text-align: center;`}>
|
|
22
|
+
That was taking longer than we expected and your request timed
|
|
23
|
+
out. Please log out, log back in, and then try again.
|
|
24
|
+
</Paragraph>
|
|
25
|
+
</Box>
|
|
26
|
+
<Center intrinsic>
|
|
27
|
+
<Box padding="0">
|
|
28
|
+
<ButtonWithAction
|
|
29
|
+
variant="primary"
|
|
30
|
+
text="Log out"
|
|
31
|
+
action={onLogout}
|
|
32
|
+
/>
|
|
33
|
+
</Box>
|
|
34
|
+
</Center>
|
|
35
|
+
</Stack>
|
|
36
|
+
</Box>
|
|
37
|
+
</Center>
|
|
38
|
+
</Cover>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export default Timeout;
|