@thecb/components 7.6.0 → 7.6.1-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "7.6.0",
3
+ "version": "7.6.1-beta.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
package/src/.DS_Store ADDED
Binary file
Binary file
@@ -6,6 +6,7 @@ import {
6
6
  ATHENS_GREY,
7
7
  GRECIAN_GREY
8
8
  } from "../../../constants/colors";
9
+ import { ACH_METHOD, CC_METHOD, CASH_METHOD } from "../../../constants/general";
9
10
  import {
10
11
  IconModule,
11
12
  TitleModule,
@@ -45,7 +46,12 @@ const Obligation = ({
45
46
  The top level desc/subdesc for all obligations in a collection is the same
46
47
  (Collection accounts look different in the Account Details page)
47
48
  */
48
- const firstObligation = obligations[0];
49
+ const firstObligation = obligations?.[0] ?? {};
50
+ const {
51
+ allowedPaymentInstruments = [CASH_METHOD, CC_METHOD, ACH_METHOD],
52
+ description = "Account",
53
+ subDescription = obligationAssocID
54
+ } = firstObligation;
49
55
  const customAttributes = firstObligation?.customAttributes ?? {};
50
56
  const boxShadowValue =
51
57
  "0px 2px 4px rgba(41, 42, 51, 0.1), 0px 1px 1px 2px rgba(41, 42, 51, 0.1);";
@@ -55,8 +61,7 @@ const Obligation = ({
55
61
  borderRadius="4px"
56
62
  boxShadow={boxShadowValue}
57
63
  as="section"
58
- aria-label={`${firstObligation?.description ??
59
- "account"} ${firstObligation?.subDescription ?? obligationAssocID}`}
64
+ aria-label={`${description} - ${subDescription}`}
60
65
  border={`1px solid ${GRECIAN_GREY}`}
61
66
  borderWidthOverride="1px 0 0 0"
62
67
  >
@@ -85,8 +90,8 @@ const Obligation = ({
85
90
  />
86
91
  )}
87
92
  <TitleModule
88
- title={firstObligation?.description}
89
- subtitle={firstObligation?.subDescription}
93
+ title={description}
94
+ subtitle={subDescription}
90
95
  titleColor={BRIGHT_GREY}
91
96
  isMobile={isMobile}
92
97
  />
@@ -106,6 +111,9 @@ const Obligation = ({
106
111
  paymentPlanSchedule={paymentPlanSchedule}
107
112
  isPaymentPlan={isPaymentPlan}
108
113
  nextAutopayDate={nextAutopayDate}
114
+ description={description}
115
+ subDescription={subDescription}
116
+ allowedPaymentInstruments={allowedPaymentInstruments}
109
117
  />
110
118
  )}
111
119
  </Cluster>
@@ -126,6 +134,9 @@ const Obligation = ({
126
134
  isPaymentPlan={isPaymentPlan}
127
135
  nextAutopayDate={nextAutopayDate}
128
136
  obligationAssocID={obligationAssocID}
137
+ description={description}
138
+ subDescription={subDescription}
139
+ allowedPaymentInstruments={allowedPaymentInstruments}
129
140
  />
130
141
  )}
131
142
  </Stack>
@@ -146,6 +157,9 @@ const Obligation = ({
146
157
  isPaymentPlan={isPaymentPlan}
147
158
  nextAutopayDate={nextAutopayDate}
148
159
  obligationAssocID={obligationAssocID}
160
+ description={description}
161
+ subDescription={subDescription}
162
+ allowedPaymentInstruments={allowedPaymentInstruments}
149
163
  />
150
164
  )}
151
165
  </Box>
@@ -201,6 +215,9 @@ const Obligation = ({
201
215
  dueDate={dueDate}
202
216
  agencyName={agencyName}
203
217
  configType={config.type}
218
+ description={description}
219
+ subDescription={subDescription}
220
+ allowedPaymentInstruments={allowedPaymentInstruments}
204
221
  />
205
222
  )}
206
223
  </Cluster>
@@ -220,6 +237,9 @@ const Obligation = ({
220
237
  dueDate={dueDate}
221
238
  agencyName={agencyName}
222
239
  configType={config.type}
240
+ description={description}
241
+ subDescription={subDescription}
242
+ allowedPaymentInstruments={allowedPaymentInstruments}
223
243
  />
224
244
  )}
225
245
  </Stack>
@@ -15,7 +15,10 @@ const AmountModule = ({
15
15
  autoPaySchedule,
16
16
  paymentPlanSchedule,
17
17
  isPaymentPlan,
18
- nextAutopayDate
18
+ nextAutopayDate,
19
+ description,
20
+ subDescription,
21
+ allowedPaymentInstruments
19
22
  }) => {
20
23
  const [modalOpen, toggleModal] = useState(false);
21
24
  return (
@@ -43,6 +46,9 @@ const AmountModule = ({
43
46
  isPaymentPlan={isPaymentPlan}
44
47
  nextAutopayDate={nextAutopayDate}
45
48
  controlType="link"
49
+ description={description}
50
+ subDescription={subDescription}
51
+ allowedPaymentInstruments={allowedPaymentInstruments}
46
52
  />
47
53
  )}
48
54
  </Stack>
@@ -5,8 +5,10 @@ import Text from "../../../atoms/text";
5
5
  import { AutopayOnIcon } from "../../../atoms/icons";
6
6
  import { Box, Cluster } from "../../../atoms/layouts";
7
7
  import { SEA_GREEN } from "../../../../constants/colors";
8
+ import { ACH_METHOD, CC_METHOD } from "../../../../constants/general";
8
9
  import { fallbackValues } from "./AutopayModalModule.theme";
9
10
  import { themeComponent } from "../../../../util/themeUtils";
11
+ import { titleCaseString } from "../../../../util/general";
10
12
 
11
13
  const AutopayModal = ({
12
14
  autoPayActive,
@@ -22,27 +24,41 @@ const AutopayModal = ({
22
24
  isPaymentPlan,
23
25
  nextAutopayDate,
24
26
  dueDate,
25
- inactive
27
+ inactive,
28
+ description,
29
+ subDescription,
30
+ allowedPaymentInstruments
26
31
  }) => {
27
- const planType = isPaymentPlan ? "Payment Plan" : "Autopay";
32
+ const generateMethodNeededText = (planText, allowedPaymentInstruments) => {
33
+ const allowsCard = allowedPaymentInstruments.includes(CC_METHOD);
34
+ const allowsACH = allowedPaymentInstruments.includes(ACH_METHOD);
35
+ const methodRequired =
36
+ allowsCard && !allowsACH
37
+ ? "debit or credit card payment method"
38
+ : !allowsCard && allowsACH
39
+ ? "checking account payment method"
40
+ : "payment method";
41
+
42
+ return `To setup ${planText} you must have a saved ${methodRequired} and address in your profile. Do you want to save these now?`;
43
+ };
44
+ const plan = isPaymentPlan ? "your payment plan" : "autopay";
45
+ const shortPlan = isPaymentPlan ? "Payment Plan" : "Autopay";
46
+ const deactivateText = `deactivate ${shortPlan} for ${description}: ${subDescription}`;
47
+ const activateText = `Set Up ${shortPlan} for ${description}: ${subDescription}`;
28
48
  const nextDate = dueDate || nextAutopayDate;
29
49
  const modalExtraProps = {
30
50
  modalHeaderText: autoPayActive
31
- ? `Deactivate ${planType}`
32
- : `Set Up ${planType}`,
51
+ ? titleCaseString(deactivateText)
52
+ : titleCaseString(activateText),
33
53
  modalBodyText: autoPayActive
34
- ? `Are you sure you want to deactivate ${
35
- isPaymentPlan ? "your payment plan" : "autopay"
36
- }? ${
54
+ ? `Are you sure you want to deactivate ${plan}? ${
37
55
  !inactive && nextDate
38
56
  ? `Your next payment will be due on ${nextDate}.`
39
57
  : ""
40
58
  }`
41
- : `To set up ${
42
- isPaymentPlan ? "a payment plan" : "autopay"
43
- } you must save a payment method and address in your profile. Do you want to save these now?`,
59
+ : generateMethodNeededText(plan, allowedPaymentInstruments),
44
60
  continueButtonText: autoPayActive
45
- ? `Disable ${planType}`
61
+ ? `Disable ${shortPlan}`
46
62
  : "Add to Profile",
47
63
  useDangerButton: autoPayActive,
48
64
  continueAction: autoPayActive
@@ -74,7 +90,9 @@ const AutopayModal = ({
74
90
  case "secondary": {
75
91
  return (
76
92
  <ButtonWithAction
77
- text={autoPayActive ? `Turn off ${planType}` : `Set Up ${planType}`}
93
+ text={
94
+ autoPayActive ? `Turn off ${shortPlan}` : `Set Up ${shortPlan}`
95
+ }
78
96
  variant="secondary"
79
97
  action={() => {
80
98
  toggleModal(true);
@@ -91,7 +109,7 @@ const AutopayModal = ({
91
109
  case "tertiary": {
92
110
  return (
93
111
  <ButtonWithAction
94
- text={autoPayActive ? `Manage ${planType}` : `Set Up ${planType}`}
112
+ text={autoPayActive ? `Manage ${shortPlan}` : `Set Up ${shortPlan}`}
95
113
  variant="tertiary"
96
114
  action={() => {
97
115
  toggleModal(true);
@@ -124,13 +142,13 @@ const AutopayModal = ({
124
142
  e.key === "Enter" && toggleModal(true);
125
143
  }}
126
144
  tabIndex="0"
127
- dataQa={`${planType} On`}
145
+ dataQa={`${shortPlan} On`}
128
146
  color={SEA_GREEN}
129
147
  weight={themeValues.fontWeight}
130
148
  hoverStyles={themeValues.modalLinkHoverFocus}
131
149
  extraStyles={`padding-left: 0.25rem;`}
132
150
  >
133
- {`${planType} ${nextAutopayDate}`}
151
+ {`${shortPlan} ${nextAutopayDate}`}
134
152
  </Text>
135
153
  </Cluster>
136
154
  </Box>
@@ -18,7 +18,10 @@ const InactiveControlsModule = ({
18
18
  dueDate,
19
19
  agencyName,
20
20
  configType,
21
- actions
21
+ actions,
22
+ description,
23
+ subDescription,
24
+ allowedPaymentInstruments
22
25
  }) => {
23
26
  const [modalOpen, toggleModal] = useState(false);
24
27
  const { deleteObligationAssoc } = actions;
@@ -52,6 +55,9 @@ const InactiveControlsModule = ({
52
55
  dueDate={dueDate}
53
56
  controlType="secondary"
54
57
  inactive
58
+ description={description}
59
+ subDescription={subDescription}
60
+ allowedPaymentInstruments={allowedPaymentInstruments}
55
61
  />
56
62
  </Box>
57
63
  )}
@@ -20,7 +20,10 @@ const PaymentDetailsActions = ({
20
20
  isPaymentPlan,
21
21
  nextAutopayDate,
22
22
  obligationAssocID,
23
- dueDate
23
+ dueDate,
24
+ description,
25
+ subDescription,
26
+ allowedPaymentInstruments
24
27
  }) => {
25
28
  const planType = isPaymentPlan ? "Payment Plan" : "Autopay";
26
29
  const [isLoading, setIsLoading] = useState(false);
@@ -73,6 +76,9 @@ const PaymentDetailsActions = ({
73
76
  paymentPlanSchedule={paymentPlanSchedule}
74
77
  isPaymentPlan={isPaymentPlan}
75
78
  nextAutopayDate={nextAutopayDate}
79
+ description={description}
80
+ subDescription={subDescription}
81
+ allowedPaymentInstruments={allowedPaymentInstruments}
76
82
  />
77
83
  </Cluster>
78
84
  </Box>
@@ -128,6 +134,9 @@ const PaymentDetailsActions = ({
128
134
  isPaymentPlan={isPaymentPlan}
129
135
  nextAutopayDate={nextAutopayDate}
130
136
  dueDate={dueDate}
137
+ description={description}
138
+ subDescription={subDescription}
139
+ allowedPaymentInstruments={allowedPaymentInstruments}
131
140
  />
132
141
  )}
133
142
  </Box>
@@ -0,0 +1,3 @@
1
+ export const ACH_METHOD = "BANK_ACCOUNT";
2
+ export const CC_METHOD = "CREDIT_CARD";
3
+ export const CASH_METHOD = "CASH";
@@ -144,3 +144,18 @@ export const throttle = (delay, fn) => {
144
144
  return fn(...args);
145
145
  };
146
146
  };
147
+
148
+ export const titleCaseWord = word => {
149
+ return word.charAt(0).toUpperCase() + word.slice(1);
150
+ };
151
+
152
+ export const titleCaseString = string => {
153
+ return string
154
+ .split(" ")
155
+ .map((word, index, string) =>
156
+ index === 0 || index === string.length - 1 || word.length > 3
157
+ ? titleCaseWord(word.toLowerCase())
158
+ : word
159
+ )
160
+ .join(" ");
161
+ };