@thecb/components 10.2.2 → 10.2.4-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.2.2",
3
+ "version": "10.2.4-beta.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -17,6 +17,7 @@ import {
17
17
  PaymentMethodAddIcon
18
18
  } from "../icons";
19
19
  import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
20
+ import { noop } from "../../../util/general";
20
21
 
21
22
  const getLargeIcon = iconName => {
22
23
  switch (iconName) {
@@ -36,21 +37,27 @@ const PlaceholderContentWrapper = ({
36
37
  action,
37
38
  destination,
38
39
  children,
39
- dataQa
40
+ dataQa,
41
+ disabled = false
40
42
  }) =>
41
43
  isLink ? (
42
- <Link to={destination} data-qa={dataQa}>
44
+ <Link to={destination} data-qa={dataQa} disabled={disabled}>
43
45
  <Box padding="0" minHeight="100%" extraStyles={`cursor: pointer;`}>
44
46
  {children}
45
47
  </Box>
46
48
  </Link>
47
49
  ) : (
48
50
  <Box
49
- onClick={action}
51
+ onClick={disabled ? noop : action}
50
52
  padding="0"
51
53
  minHeight="100%"
52
- extraStyles={`cursor: pointer;`}
53
54
  dataQa={dataQa}
55
+ aria-disabled={disabled}
56
+ extraStyles={
57
+ disabled
58
+ ? "cursor: default; opacity: 0.7;"
59
+ : "cursor: pointer; opacity: 1;"
60
+ }
54
61
  >
55
62
  {children}
56
63
  </Box>
@@ -65,13 +72,15 @@ const Placeholder = ({
65
72
  variant,
66
73
  largeIcon,
67
74
  themeValues,
68
- dataQa
75
+ dataQa,
76
+ disabled = false
69
77
  }) => (
70
78
  <PlaceholderContentWrapper
71
79
  isLink={isLink}
72
80
  action={action}
73
81
  destination={destination}
74
82
  dataQa={dataQa}
83
+ disabled={disabled}
75
84
  >
76
85
  <Box
77
86
  padding="0"
@@ -108,7 +117,7 @@ const Placeholder = ({
108
117
  <Box
109
118
  padding="0"
110
119
  tabIndex="0"
111
- onKeyPress={e => e.key === "Enter" && action()}
120
+ onKeyPress={e => e.key === "Enter" && !disabled && action()}
112
121
  >
113
122
  <Cluster justify="center" align="center" minHeight="100%">
114
123
  <Switcher maxChildren={2} childGap="0">
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { text, select } from "@storybook/addon-knobs";
2
+ import { text, select, boolean } from "@storybook/addon-knobs";
3
3
  import Placeholder from "./Placeholder";
4
4
  import page from "../../../../.storybook/page";
5
5
 
@@ -21,14 +21,27 @@ const iconLabel = "largeIcon";
21
21
  const defaultIcon = "accounts";
22
22
 
23
23
  export const placeholder = () => (
24
- <Placeholder
25
- variant={select(variantsLabel, variants, defaultValue, groupId)}
26
- isLink
27
- destination={text("destination", "add-account", "props")}
28
- text={text("text", "Add an Account", "props")}
29
- largeIcon={select(iconLabel, icons, defaultIcon, groupId)}
30
- key="placeholder"
31
- />
24
+ <>
25
+ <h2>Placeholder w/Link</h2>
26
+ <Placeholder
27
+ variant={select(variantsLabel, variants, defaultValue, groupId)}
28
+ isLink
29
+ destination={text("destination", "/", "props")}
30
+ text={text("text", "Add an Account", "props")}
31
+ largeIcon={select(iconLabel, icons, defaultIcon, groupId)}
32
+ key="placeholder1"
33
+ disabled={boolean("disabled", false, groupId)}
34
+ />
35
+ <h2>Placeholder w/Action</h2>
36
+ <Placeholder
37
+ variant={select(variantsLabel, variants, defaultValue, groupId)}
38
+ text={text("text", "Add an Account", "props")}
39
+ largeIcon={select(iconLabel, icons, defaultIcon, groupId)}
40
+ key="placeholder2"
41
+ disabled={boolean("disabled", false, groupId)}
42
+ action={() => window.alert("Click event registered!")}
43
+ />
44
+ </>
32
45
  );
33
46
 
34
47
  const story = page({
@@ -36,7 +36,8 @@ const Obligation = ({
36
36
  inactive = false,
37
37
  inactiveLookupTitle = "",
38
38
  inactiveLookupInput = "Account",
39
- inactiveLookupValue = ""
39
+ inactiveLookupValue = "",
40
+ isInCustomerManagement = false
40
41
  }) => {
41
42
  /*
42
43
  The value of obligations is always an array. It can contain:
@@ -137,6 +138,7 @@ const Obligation = ({
137
138
  description={description}
138
139
  subDescription={subDescription}
139
140
  allowedPaymentInstruments={allowedPaymentInstruments}
141
+ isInCustomerManagement={isInCustomerManagement}
140
142
  />
141
143
  )}
142
144
  </Stack>
@@ -160,6 +162,7 @@ const Obligation = ({
160
162
  description={description}
161
163
  subDescription={subDescription}
162
164
  allowedPaymentInstruments={allowedPaymentInstruments}
165
+ isInCustomerManagement={isInCustomerManagement}
163
166
  />
164
167
  )}
165
168
  </Box>
@@ -27,7 +27,8 @@ const AutopayModal = ({
27
27
  inactive,
28
28
  description,
29
29
  subDescription,
30
- allowedPaymentInstruments
30
+ allowedPaymentInstruments,
31
+ isInCustomerManagement = false
31
32
  }) => {
32
33
  const generateMethodNeededText = (planText, allowedPaymentInstruments) => {
33
34
  const allowsCard = allowedPaymentInstruments.includes(CC_METHOD);
@@ -80,6 +81,7 @@ const AutopayModal = ({
80
81
  case "secondary": {
81
82
  return (
82
83
  <ButtonWithAction
84
+ disabled={isInCustomerManagement}
83
85
  text={
84
86
  autoPayActive ? `Turn off ${shortPlan}` : `Set Up ${shortPlan}`
85
87
  }
@@ -99,6 +101,7 @@ const AutopayModal = ({
99
101
  case "tertiary": {
100
102
  return (
101
103
  <ButtonWithAction
104
+ disabled={isInCustomerManagement}
102
105
  text={autoPayActive ? `Manage ${shortPlan}` : `Set Up ${shortPlan}`}
103
106
  variant="tertiary"
104
107
  action={() => {
@@ -23,7 +23,8 @@ const PaymentDetailsActions = ({
23
23
  dueDate,
24
24
  description,
25
25
  subDescription,
26
- allowedPaymentInstruments
26
+ allowedPaymentInstruments,
27
+ isInCustomerManagement = false
27
28
  }) => {
28
29
  const planType = isPaymentPlan ? "Payment Plan" : "Autopay";
29
30
  const [isLoading, setIsLoading] = useState(false);
@@ -119,6 +120,7 @@ const PaymentDetailsActions = ({
119
120
  }}
120
121
  dataQa="Set Up Autopay"
121
122
  extraStyles={isMobile && `flex-grow: 1; width: 100%;`}
123
+ disabled={isInCustomerManagement}
122
124
  />
123
125
  ) : (
124
126
  <AutopayModalModule
@@ -148,6 +150,7 @@ const PaymentDetailsActions = ({
148
150
  text="Pay Now"
149
151
  variant={isMobile ? "smallSecondary" : "secondary"}
150
152
  dataQa="Pay Now"
153
+ disabled={isInCustomerManagement}
151
154
  />
152
155
  </Box>
153
156
  )}
@@ -161,6 +164,7 @@ const PaymentDetailsActions = ({
161
164
  variant={isMobile ? "smallSecondary" : "secondary"}
162
165
  dataQa="Pay Now"
163
166
  extraStyles={isMobile && `flex-grow: 1; width: 100%; margin: 0;`}
167
+ disabled={isInCustomerManagement}
164
168
  />
165
169
  </Box>
166
170
  )}