@thecb/components 3.4.1 → 3.5.1

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.
@@ -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 = ({ isMobile, obligations, config, actions }) => {
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
- <Cluster
31
- justify={isMobile ? "center" : "flex-end"}
32
- align="center"
33
- childGap="0"
34
- >
44
+ {isMobile && (
35
45
  <Box
36
- padding={isMobile ? "0 8px 0 0" : "8px"}
37
- extraStyles={isMobile && `flex-grow: 1;`}
46
+ padding="16px 24px"
47
+ borderSize="1px"
48
+ borderColor={GHOST_GREY}
49
+ borderWidthOverride="0 0 1px 0"
38
50
  >
39
- <ButtonWithAction
40
- variant={isMobile ? "smallSecondary" : "secondary"}
41
- text={
42
- config.type === "ACCOUNT" ? "Account Details" : "Property Details"
43
- }
44
- action={handleDetailsClick}
45
- dataQa="Account Details"
46
- extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
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
- <Box
50
- padding={isMobile ? "0 0 0 8px" : "8px"}
51
- extraStyles={isMobile && `flex-grow: 1;`}
77
+ )}
78
+ <Box padding={isMobile ? "16px" : "0"}>
79
+ <Cluster
80
+ justify={isMobile ? "center" : "flex-end"}
81
+ align="center"
82
+ childGap="0"
52
83
  >
53
- <ButtonWithAction
54
- isLoading={isLoading}
55
- action={() => handleClick(obligations)}
56
- text="Make Payment"
57
- variant={isMobile ? "smallPrimary" : "primary"}
58
- dataQa="Make Payment"
59
- extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
60
- />
61
- </Box>
62
- </Cluster>
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
  };
@@ -0,0 +1,46 @@
1
+ import React, { useContext } from "react";
2
+ import { ThemeContext } from "styled-components";
3
+ import { Box, Stack, Center, Cover } from "../../atoms/layouts";
4
+ import { TimeoutImage } from "../../atoms/icons";
5
+ import ButtonWithAction from "../../atoms/button-with-action";
6
+ import Heading from "../../atoms/heading";
7
+ import { FONT_WEIGHT_BOLD } from "../../../constants/style_constants";
8
+ import Paragraph from "../../atoms/paragraph";
9
+ import withWindowSize from "../../withWindowSize";
10
+
11
+ const Timeout = ({ onLogout }) => {
12
+ const { isMobile } = useContext(ThemeContext);
13
+ return (
14
+ <Cover>
15
+ <Center intrinsic>
16
+ <Box padding="0" maxWidth={isMobile ? "100%" : "500px"}>
17
+ <Stack childGap="32px" justify="center">
18
+ <Box padding={isMobile ? "1rem" : "0"}>
19
+ <TimeoutImage />
20
+ </Box>
21
+ <Box padding="0">
22
+ <Heading textAlign="center" weight={FONT_WEIGHT_BOLD}>
23
+ Request Timed Out
24
+ </Heading>
25
+ <Paragraph variant="pL" extraStyles={`text-align: center;`}>
26
+ That was taking longer than we expected and your request timed
27
+ out. Please log out, log back in, and then try again.
28
+ </Paragraph>
29
+ </Box>
30
+ <Center intrinsic>
31
+ <Box padding="0">
32
+ <ButtonWithAction
33
+ variant="primary"
34
+ text="Log out"
35
+ action={onLogout}
36
+ />
37
+ </Box>
38
+ </Center>
39
+ </Stack>
40
+ </Box>
41
+ </Center>
42
+ </Cover>
43
+ );
44
+ };
45
+
46
+ export default withWindowSize(Timeout);
@@ -0,0 +1,3 @@
1
+ import Timeout from "./Timeout";
2
+
3
+ export default Timeout;