@thecb/components 10.4.0-beta.1 → 10.4.0-beta.11

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.
@@ -5,6 +5,7 @@ import Text from "../../../atoms/text";
5
5
  import { FONT_WEIGHT_SEMIBOLD } from "../../../../constants/style_constants";
6
6
  import { displayCurrency } from "../../../../util/general";
7
7
  import { AutopayModalModule } from "./AutopayModalModule";
8
+ import { noop } from "../../../../util/general";
8
9
 
9
10
  const AmountModule = ({
10
11
  totalAmountDue,
@@ -18,7 +19,8 @@ const AmountModule = ({
18
19
  nextAutopayDate,
19
20
  description,
20
21
  subDescription,
21
- allowedPaymentInstruments
22
+ allowedPaymentInstruments,
23
+ disableActions = false
22
24
  }) => {
23
25
  const [modalOpen, toggleModal] = useState(false);
24
26
  return (
@@ -49,6 +51,16 @@ const AmountModule = ({
49
51
  description={description}
50
52
  subDescription={subDescription}
51
53
  allowedPaymentInstruments={allowedPaymentInstruments}
54
+ disableActions={disableActions}
55
+ action={() => (disableActions ? noop : toggleModal(true))}
56
+ onClick={() => (disableActions ? noop : toggleModal(true))}
57
+ onKeyPress={
58
+ disableActions
59
+ ? () => noop
60
+ : e => {
61
+ e.key === "Enter" && toggleModal(true);
62
+ }
63
+ }
52
64
  />
53
65
  )}
54
66
  </Stack>
@@ -17,6 +17,9 @@ export const amountModule = () => (
17
17
  autoPaySchedule={{}}
18
18
  paymentPlanSchedule={{}}
19
19
  isPaymentPlan={boolean("isPaymentPlan", false, groupId)}
20
+ disableActions={boolean("disableActions", false, groupId)}
21
+ subDescription="Amount Module Subdescription"
22
+ description="Amount Module Description"
20
23
  />
21
24
  );
22
25
 
@@ -28,7 +28,10 @@ const AutopayModal = ({
28
28
  description,
29
29
  subDescription,
30
30
  allowedPaymentInstruments,
31
- isInCustomerManagement = false
31
+ disableActions = false,
32
+ action,
33
+ onClick,
34
+ onKeyPress
32
35
  }) => {
33
36
  const generateMethodNeededText = (planText, allowedPaymentInstruments) => {
34
37
  const allowsCard = allowedPaymentInstruments.includes(CC_METHOD);
@@ -81,13 +84,12 @@ const AutopayModal = ({
81
84
  case "secondary": {
82
85
  return (
83
86
  <ButtonWithAction
84
- disabled={isInCustomerManagement}
85
87
  text={
86
88
  autoPayActive ? `Turn off ${shortPlan}` : `Set Up ${shortPlan}`
87
89
  }
88
90
  variant="secondary"
89
91
  action={() => {
90
- toggleModal(true);
92
+ action || toggleModal(true);
91
93
  }}
92
94
  dataQa="Turn off Autopay"
93
95
  extraStyles={
@@ -95,20 +97,21 @@ const AutopayModal = ({
95
97
  ? `flex-grow: 1; width: 100%; margin: 0;`
96
98
  : `flex-grow: 1; min-width: 165px;`
97
99
  }
100
+ disabled={disableActions}
98
101
  />
99
102
  );
100
103
  }
101
104
  case "tertiary": {
102
105
  return (
103
106
  <ButtonWithAction
104
- disabled={isInCustomerManagement}
105
107
  text={autoPayActive ? `Manage ${shortPlan}` : `Set Up ${shortPlan}`}
106
- variant={isInCustomerManagement ? "disabledTertiary" : "tertiary"}
108
+ variant="tertiary"
107
109
  action={() => {
108
- isInCustomerManagement ? noop : toggleModal(true);
110
+ action || toggleModal(true);
109
111
  }}
110
112
  dataQa="Manage Autopay"
111
113
  extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
114
+ disabled={disableActions}
112
115
  />
113
116
  );
114
117
  }
@@ -117,7 +120,7 @@ const AutopayModal = ({
117
120
  <Box
118
121
  padding="0"
119
122
  onClick={() => {
120
- isInCustomerManagement ? noop : toggleModal(true);
123
+ onClick || toggleModal(true);
121
124
  }}
122
125
  hoverStyles={hoverStyles}
123
126
  activeStyles={activeStyles}
@@ -130,13 +133,12 @@ const AutopayModal = ({
130
133
  <AutopayOnIcon />
131
134
  <Text
132
135
  variant="pS"
133
- onClick={() => toggleModal(true)}
136
+ onClick={() => onClick || toggleModal(true)}
134
137
  onKeyPress={
135
- isInCustomerManagement
136
- ? noop
137
- : e => {
138
- e.key === "Enter" && toggleModal(true);
139
- }
138
+ onKeyPress ||
139
+ (e => {
140
+ e.key === "Enter" && toggleModal(true);
141
+ })
140
142
  }
141
143
  tabIndex="0"
142
144
  dataQa={`${shortPlan} On`}
@@ -144,6 +146,7 @@ const AutopayModal = ({
144
146
  weight={themeValues.fontWeight}
145
147
  hoverStyles={themeValues.modalLinkHoverFocus}
146
148
  extraStyles={`padding-left: 0.25rem;`}
149
+ disabled={disableActions}
147
150
  >
148
151
  {`${shortPlan} ${nextAutopayDate}`}
149
152
  </Text>
@@ -155,8 +158,8 @@ const AutopayModal = ({
155
158
  };
156
159
  return (
157
160
  <Modal
158
- showModal={isInCustomerManagement ? noop : () => toggleModal(true)}
159
- hideModal={isInCustomerManagement ? noop : () => toggleModal(false)}
161
+ showModal={disableActions ? noop : () => toggleModal(true)}
162
+ hideModal={disableActions ? noop : () => toggleModal(false)}
160
163
  modalOpen={modalOpen}
161
164
  {...modalExtraProps}
162
165
  >
@@ -22,7 +22,7 @@ const InactiveControlsModule = ({
22
22
  description,
23
23
  subDescription,
24
24
  allowedPaymentInstruments,
25
- isInCustomerManagement = false
25
+ disableActions = false
26
26
  }) => {
27
27
  const [modalOpen, toggleModal] = useState(false);
28
28
  const { deleteObligationAssoc } = actions;
@@ -59,17 +59,26 @@ const InactiveControlsModule = ({
59
59
  description={description}
60
60
  subDescription={subDescription}
61
61
  allowedPaymentInstruments={allowedPaymentInstruments}
62
- isInCustomerManagement={isInCustomerManagement}
62
+ disableActions={disableActions}
63
+ action={() => (disableActions ? noop : toggleModal(true))}
64
+ onClick={() => (disableActions ? noop : toggleModal(true))}
65
+ onKeyPress={
66
+ disableActions
67
+ ? () => noop
68
+ : e => {
69
+ e.key === "Enter" && toggleModal(true);
70
+ }
71
+ }
63
72
  />
64
73
  </Box>
65
74
  )}
66
75
  <Box padding="0" extraStyles={`flex-grow: 1;`}>
67
76
  <RemoveAccountModalModule
68
77
  agencyName={agencyName}
69
- removeAccount={isInCustomerManagement ? noop : handleRemoveAccount}
78
+ removeAccount={disableActions ? noop : handleRemoveAccount}
70
79
  accountType={configType === "ACCOUNT" ? "Account" : "Property"}
71
80
  isMobile={isMobile}
72
- isInCustomerManagement={isInCustomerManagement}
81
+ disableActions={disableActions}
73
82
  />
74
83
  </Box>
75
84
  </Cluster>
@@ -4,6 +4,7 @@ import ButtonWithAction from "../../../atoms/button-with-action";
4
4
  import { AutopayModalModule } from "./AutopayModalModule";
5
5
  import { GHOST_GREY } from "../../../../constants/colors";
6
6
  import AmountModule from "./AmountModule";
7
+ import { noop } from "../../../../util/general";
7
8
 
8
9
  const PaymentDetailsActions = ({
9
10
  isMobile,
@@ -24,7 +25,7 @@ const PaymentDetailsActions = ({
24
25
  description,
25
26
  subDescription,
26
27
  allowedPaymentInstruments,
27
- isInCustomerManagement = false
28
+ disableActions = false
28
29
  }) => {
29
30
  const planType = isPaymentPlan ? "Payment Plan" : "Autopay";
30
31
  const [isLoading, setIsLoading] = useState(false);
@@ -80,6 +81,7 @@ const PaymentDetailsActions = ({
80
81
  description={description}
81
82
  subDescription={subDescription}
82
83
  allowedPaymentInstruments={allowedPaymentInstruments}
84
+ disableActions={disableActions}
83
85
  />
84
86
  </Cluster>
85
87
  </Box>
@@ -95,13 +97,13 @@ const PaymentDetailsActions = ({
95
97
  extraStyles={isMobile && `flex-grow: 1;`}
96
98
  >
97
99
  <ButtonWithAction
98
- variant={isInCustomerManagement ? "disabledTertiary" : "tertiary"}
100
+ variant="tertiary"
99
101
  text={
100
102
  config.type === "ACCOUNT"
101
103
  ? "Account Details"
102
104
  : "Property Details"
103
105
  }
104
- action={handleDetailsClick}
106
+ action={disableActions ? noop : handleDetailsClick}
105
107
  dataQa="Account Details"
106
108
  extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
107
109
  />
@@ -112,17 +114,21 @@ const PaymentDetailsActions = ({
112
114
  >
113
115
  {autoPayAvailable && !autoPayEnabled ? (
114
116
  <ButtonWithAction
115
- variant={
116
- isInCustomerManagement ? "disabledTertiary" : "tertiary"
117
- }
117
+ variant="tertiary"
118
118
  text={`Set Up ${planType}`}
119
119
  action={() => {
120
- setDetailedObligation(obligations, config, obligationAssocID);
121
- handleAutopayAction();
120
+ if (!disableActions) {
121
+ setDetailedObligation(
122
+ obligations,
123
+ config,
124
+ obligationAssocID
125
+ );
126
+ handleAutopayAction();
127
+ }
122
128
  }}
123
129
  dataQa="Set Up Autopay"
124
130
  extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
125
- disabled={isInCustomerManagement}
131
+ disabled={disableActions}
126
132
  />
127
133
  ) : (
128
134
  <AutopayModalModule
@@ -141,7 +147,16 @@ const PaymentDetailsActions = ({
141
147
  description={description}
142
148
  subDescription={subDescription}
143
149
  allowedPaymentInstruments={allowedPaymentInstruments}
144
- isInCustomerManagement={isInCustomerManagement}
150
+ disableActions={disableActions}
151
+ action={() => (disableActions ? noop : toggleModal(true))}
152
+ onClick={() => (disableActions ? noop : toggleModal(true))}
153
+ onKeyPress={
154
+ disableActions
155
+ ? () => noop
156
+ : e => {
157
+ e.key === "Enter" && toggleModal(true);
158
+ }
159
+ }
145
160
  />
146
161
  )}
147
162
  </Box>
@@ -149,21 +164,11 @@ const PaymentDetailsActions = ({
149
164
  <Box padding={"0"}>
150
165
  <ButtonWithAction
151
166
  isLoading={isLoading}
152
- action={
153
- isInCustomerManagement ? noop : () => handleClick(obligations)
154
- }
167
+ action={disableActions ? noop : () => handleClick(obligations)}
155
168
  text="Pay Now"
156
- variant={
157
- isMobile
158
- ? isInCustomerManagement
159
- ? "disabledSmallSecondary"
160
- : "smallSecondary"
161
- : isInCustomerManagement
162
- ? "disabledSecondary"
163
- : "secondary"
164
- }
169
+ variant={isMobile ? "smallSecondary" : "secondary"}
165
170
  dataQa="Pay Now"
166
- disabled={isInCustomerManagement}
171
+ disabled={disableActions}
167
172
  />
168
173
  </Box>
169
174
  )}
@@ -172,12 +177,14 @@ const PaymentDetailsActions = ({
172
177
  <Box padding="8px 0 0" width="100%">
173
178
  <ButtonWithAction
174
179
  isLoading={isLoading}
175
- action={() => handleClick(obligations)}
180
+ action={() =>
181
+ disableActions ? noop : () => handleClick(obligations)
182
+ }
176
183
  text="Pay Now"
177
184
  variant={isMobile ? "smallSecondary" : "secondary"}
178
185
  dataQa="Pay Now"
179
186
  extraStyles={isMobile && `flex-grow: 1; width: 100%; margin: 0;`}
180
- disabled={isInCustomerManagement}
187
+ disabled={disableActions}
181
188
  />
182
189
  </Box>
183
190
  )}
@@ -9,7 +9,7 @@ const RemoveAccountModalModule = ({
9
9
  removeAccount,
10
10
  accountType,
11
11
  isMobile,
12
- isInCustomerManagement = false
12
+ disableActions = false
13
13
  }) => {
14
14
  const [modalIsOpen, setModalIsOpen] = useState(false);
15
15
  const lastItem = [...obligations].pop();
@@ -32,8 +32,8 @@ const RemoveAccountModalModule = ({
32
32
 
33
33
  return (
34
34
  <Modal
35
- showModal={() => setModalIsOpen(true)}
36
- hideModal={() => setModalIsOpen(false)}
35
+ showModal={disableActions ? noop : () => setModalIsOpen(true)}
36
+ hideModal={disableActions ? noop : () => setModalIsOpen(false)}
37
37
  modalOpen={modalIsOpen}
38
38
  modalHeaderText={`Remove ${accountType}`}
39
39
  modalBodyText={`Are you sure you want to remove the ${identifier} ${accounts}? Any autopay scheduled against ${
@@ -41,21 +41,23 @@ const RemoveAccountModalModule = ({
41
41
  } will be deactivated.`}
42
42
  continueButtonText="Remove"
43
43
  continueAction={() => {
44
- removeAccount();
45
- setModalIsOpen(false);
44
+ if (!disableActions) {
45
+ removeAccount();
46
+ setModalIsOpen(false);
47
+ }
46
48
  }}
47
49
  useDangerButton
48
50
  >
49
51
  <Box padding="0" extraStyles={`flex-grow: 1;`}>
50
52
  <ButtonWithAction
51
53
  text="Remove"
52
- variant={isInCustomerManagement ? "disabledSecondary" : "secondary"}
53
- action={isInCustomerManagement ? noop : () => setModalIsOpen(true)}
54
+ variant="secondary"
55
+ action={disableActions ? noop : () => setModalIsOpen(true)}
54
56
  dataQa="Remove Account"
55
57
  extraStyles={
56
58
  isMobile ? `flex-grow: 1; width: 100%; margin: 0;` : `flex-grow: 1;`
57
59
  }
58
- disabled={isInCustomerManagement}
60
+ disabled={disableActions}
59
61
  />
60
62
  </Box>
61
63
  </Modal>