@thecb/components 11.0.2 → 11.1.0-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/dist/index.cjs.js +771 -125
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +771 -125
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -1
- package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +14 -0
- package/src/components/atoms/button-with-action/ButtonWithAction.theme.js +57 -18
- package/src/components/atoms/icons/SuccessfulIconMedium.js +3 -2
- package/src/components/molecules/obligation/Obligation.js +13 -1
- package/src/components/molecules/obligation/Obligation.stories.js +72 -0
- package/src/components/molecules/obligation/modules/PaymentDetailsActions.js +34 -9
- package/src/util/general.js +40 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thecb/components",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.1.0-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",
|
|
@@ -93,6 +93,7 @@
|
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"@babel/runtime": "^7.15.4",
|
|
96
|
+
"@thecb/components": "file:.yalc/@thecb/components",
|
|
96
97
|
"@types/styled-components": "^5.1.34",
|
|
97
98
|
"core-js": "^3.22.5",
|
|
98
99
|
"formatted-input": "^1.0.0",
|
|
@@ -107,3 +107,17 @@ export const WhiteSecondary = {
|
|
|
107
107
|
...Primary.args,
|
|
108
108
|
variant: "whiteSecondary"
|
|
109
109
|
};
|
|
110
|
+
|
|
111
|
+
export const GreenPrimary = {
|
|
112
|
+
args: {
|
|
113
|
+
...Primary.args,
|
|
114
|
+
variant: "greenPrimary"
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const GreenSecondary = {
|
|
119
|
+
args: {
|
|
120
|
+
...Primary.args,
|
|
121
|
+
variant: "greenSecondary"
|
|
122
|
+
}
|
|
123
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { colors, styleConstants } from "../../../constants";
|
|
2
|
+
import { adjustHexColor } from "../../../util/general";
|
|
2
3
|
|
|
3
4
|
const {
|
|
4
5
|
WHITE,
|
|
@@ -7,6 +8,8 @@ const {
|
|
|
7
8
|
PEACOCK_BLUE,
|
|
8
9
|
MANATEE_GREY,
|
|
9
10
|
MATISSE_BLUE,
|
|
11
|
+
HINT_GREEN,
|
|
12
|
+
SEA_GREEN,
|
|
10
13
|
RASPBERRY,
|
|
11
14
|
ERROR_COLOR
|
|
12
15
|
} = colors;
|
|
@@ -24,8 +27,10 @@ const disabledBorderColor = {
|
|
|
24
27
|
tertiary: TRANSPARENT,
|
|
25
28
|
danger: MANATEE_GREY,
|
|
26
29
|
dangerSecondary: MANATEE_GREY,
|
|
30
|
+
whitePrimary: MANATEE_GREY,
|
|
27
31
|
whiteSecondary: MANATEE_GREY,
|
|
28
|
-
|
|
32
|
+
greenPrimary: SEA_GREEN,
|
|
33
|
+
greenSecondary: SEA_GREEN
|
|
29
34
|
};
|
|
30
35
|
|
|
31
36
|
const disabledColor = {
|
|
@@ -39,8 +44,10 @@ const disabledColor = {
|
|
|
39
44
|
tertiary: MANATEE_GREY,
|
|
40
45
|
danger: WHITE,
|
|
41
46
|
dangerSecondary: MANATEE_GREY,
|
|
47
|
+
whitePrimary: MANATEE_GREY,
|
|
42
48
|
whiteSecondary: MANATEE_GREY,
|
|
43
|
-
|
|
49
|
+
greenPrimary: WHITE,
|
|
50
|
+
greenSecondary: SEA_GREEN
|
|
44
51
|
};
|
|
45
52
|
|
|
46
53
|
const disabledBackgroundColor = {
|
|
@@ -54,8 +61,10 @@ const disabledBackgroundColor = {
|
|
|
54
61
|
tertiary: TRANSPARENT,
|
|
55
62
|
danger: MANATEE_GREY,
|
|
56
63
|
dangerSecondary: TRANSPARENT,
|
|
64
|
+
whitePrimary: TRANSPARENT,
|
|
57
65
|
whiteSecondary: TRANSPARENT,
|
|
58
|
-
|
|
66
|
+
greenPrimary: SEA_GREEN,
|
|
67
|
+
greenSecondary: TRANSPARENT
|
|
59
68
|
};
|
|
60
69
|
|
|
61
70
|
const padding = {
|
|
@@ -69,8 +78,10 @@ const padding = {
|
|
|
69
78
|
ghost: "0.65rem 0",
|
|
70
79
|
danger: "0.75rem 1.5rem",
|
|
71
80
|
dangerSecondary: "0.75rem 1.5rem",
|
|
81
|
+
whitePrimary: "1.125rem 0.75rem",
|
|
72
82
|
whiteSecondary: "0.75rem 2rem",
|
|
73
|
-
|
|
83
|
+
greenPrimary: "0.75rem 1.5rem",
|
|
84
|
+
greenSecondary: "0.75rem 1.5rem"
|
|
74
85
|
};
|
|
75
86
|
|
|
76
87
|
const color = {
|
|
@@ -84,8 +95,10 @@ const color = {
|
|
|
84
95
|
tertiary: MATISSE_BLUE,
|
|
85
96
|
danger: WHITE,
|
|
86
97
|
dangerSecondary: ERROR_COLOR,
|
|
98
|
+
whitePrimary: WHITE,
|
|
87
99
|
whiteSecondary: WHITE,
|
|
88
|
-
|
|
100
|
+
greenPrimary: WHITE,
|
|
101
|
+
greenSecondary: SEA_GREEN
|
|
89
102
|
};
|
|
90
103
|
|
|
91
104
|
const fontSizeVariant = {
|
|
@@ -100,7 +113,9 @@ const fontSizeVariant = {
|
|
|
100
113
|
danger: "pS",
|
|
101
114
|
dangerSecondary: "pS",
|
|
102
115
|
whiteSecondary: "pS",
|
|
103
|
-
whitePrimary: "pS"
|
|
116
|
+
whitePrimary: "pS",
|
|
117
|
+
greenPrimary: "pS",
|
|
118
|
+
greenSecondary: "pS"
|
|
104
119
|
};
|
|
105
120
|
|
|
106
121
|
const fontWeight = {
|
|
@@ -115,7 +130,9 @@ const fontWeight = {
|
|
|
115
130
|
danger: "600",
|
|
116
131
|
dangerSecondary: "600",
|
|
117
132
|
whiteSecondary: "600",
|
|
118
|
-
whitePrimary: "600"
|
|
133
|
+
whitePrimary: "600",
|
|
134
|
+
greenPrimary: "600",
|
|
135
|
+
greenSecondary: "600"
|
|
119
136
|
};
|
|
120
137
|
|
|
121
138
|
const height = {
|
|
@@ -129,8 +146,10 @@ const height = {
|
|
|
129
146
|
tertiary: "3rem",
|
|
130
147
|
danger: "3rem",
|
|
131
148
|
dangerSecondary: "3rem",
|
|
149
|
+
whitePrimary: "auto",
|
|
132
150
|
whiteSecondary: "3rem",
|
|
133
|
-
|
|
151
|
+
greenPrimary: "3rem",
|
|
152
|
+
greenSecondary: "3rem"
|
|
134
153
|
};
|
|
135
154
|
|
|
136
155
|
const minWidth = {
|
|
@@ -144,8 +163,10 @@ const minWidth = {
|
|
|
144
163
|
tertiary: "130px",
|
|
145
164
|
danger: "130px",
|
|
146
165
|
dangerSecondary: "157px",
|
|
166
|
+
whitePrimary: "130px",
|
|
147
167
|
whiteSecondary: "160px",
|
|
148
|
-
|
|
168
|
+
greenPrimary: "130px",
|
|
169
|
+
greenSecondary: "130px"
|
|
149
170
|
};
|
|
150
171
|
|
|
151
172
|
const textDecoration = {
|
|
@@ -159,8 +180,10 @@ const textDecoration = {
|
|
|
159
180
|
tertiary: "none",
|
|
160
181
|
danger: "none",
|
|
161
182
|
dangerSecondary: "none",
|
|
183
|
+
whitePrimary: "none",
|
|
162
184
|
whiteSecondary: "none",
|
|
163
|
-
|
|
185
|
+
greenPrimary: "none",
|
|
186
|
+
greenSecondary: "none"
|
|
164
187
|
};
|
|
165
188
|
|
|
166
189
|
const backgroundColor = {
|
|
@@ -174,8 +197,10 @@ const backgroundColor = {
|
|
|
174
197
|
tertiary: TRANSPARENT,
|
|
175
198
|
danger: RASPBERRY,
|
|
176
199
|
dangerSecondary: TRANSPARENT,
|
|
200
|
+
whitePrimary: TRANSPARENT,
|
|
177
201
|
whiteSecondary: TRANSPARENT,
|
|
178
|
-
|
|
202
|
+
greenPrimary: SEA_GREEN,
|
|
203
|
+
greenSecondary: TRANSPARENT
|
|
179
204
|
};
|
|
180
205
|
|
|
181
206
|
const border = {
|
|
@@ -189,8 +214,10 @@ const border = {
|
|
|
189
214
|
tertiary: "none",
|
|
190
215
|
danger: "2px solid " + RASPBERRY,
|
|
191
216
|
dangerSecondary: "2px solid " + ERROR_COLOR,
|
|
217
|
+
whitePrimary: "2px solid " + TRANSPARENT,
|
|
192
218
|
whiteSecondary: "2px solid " + WHITE,
|
|
193
|
-
|
|
219
|
+
greenPrimary: "2px solid " + SEA_GREEN,
|
|
220
|
+
greenSecondary: "2px solid " + SEA_GREEN
|
|
194
221
|
};
|
|
195
222
|
|
|
196
223
|
const hoverBackgroundColor = {
|
|
@@ -204,8 +231,10 @@ const hoverBackgroundColor = {
|
|
|
204
231
|
tertiary: TRANSPARENT,
|
|
205
232
|
danger: "#BA002C",
|
|
206
233
|
dangerSecondary: "#FAE7EE",
|
|
234
|
+
whitePrimary: TRANSPARENT,
|
|
207
235
|
whiteSecondary: TRANSPARENT,
|
|
208
|
-
|
|
236
|
+
greenPrimary: adjustHexColor(SEA_GREEN, 10, "darken"),
|
|
237
|
+
greenSecondary: HINT_GREEN
|
|
209
238
|
};
|
|
210
239
|
|
|
211
240
|
const hoverBorderColor = {
|
|
@@ -219,8 +248,10 @@ const hoverBorderColor = {
|
|
|
219
248
|
tertiary: TRANSPARENT,
|
|
220
249
|
danger: "#BA002C",
|
|
221
250
|
dangerSecondary: "#B10541",
|
|
251
|
+
whitePrimary: "2px solid " + TRANSPARENT,
|
|
222
252
|
whiteSecondary: "2px solid " + TRANSPARENT,
|
|
223
|
-
|
|
253
|
+
greenPrimary: SEA_GREEN,
|
|
254
|
+
greenSecondary: SEA_GREEN
|
|
224
255
|
};
|
|
225
256
|
|
|
226
257
|
const hoverColor = {
|
|
@@ -234,8 +265,10 @@ const hoverColor = {
|
|
|
234
265
|
tertiary: SAPPHIRE_BLUE,
|
|
235
266
|
danger: WHITE,
|
|
236
267
|
dangerSecondary: "#B10541",
|
|
268
|
+
whitePrimary: WHITE,
|
|
237
269
|
whiteSecondary: WHITE,
|
|
238
|
-
|
|
270
|
+
greenPrimary: WHITE,
|
|
271
|
+
greenSecondary: SEA_GREEN
|
|
239
272
|
};
|
|
240
273
|
|
|
241
274
|
const activeBackgroundColor = {
|
|
@@ -249,8 +282,10 @@ const activeBackgroundColor = {
|
|
|
249
282
|
tertiary: TRANSPARENT,
|
|
250
283
|
danger: "#870000",
|
|
251
284
|
dangerSecondary: "#FAE7EE",
|
|
285
|
+
whitePrimary: TRANSPARENT,
|
|
252
286
|
whiteSecondary: TRANSPARENT,
|
|
253
|
-
|
|
287
|
+
greenPrimary: adjustHexColor(SEA_GREEN, 20, "darken"),
|
|
288
|
+
greenSecondary: adjustHexColor(HINT_GREEN, 5, "darken")
|
|
254
289
|
};
|
|
255
290
|
|
|
256
291
|
const activeBorderColor = {
|
|
@@ -264,8 +299,10 @@ const activeBorderColor = {
|
|
|
264
299
|
tertiary: TRANSPARENT,
|
|
265
300
|
danger: "#870000",
|
|
266
301
|
dangerSecondary: "#910029",
|
|
302
|
+
whitePrimary: "2px solid " + TRANSPARENT,
|
|
267
303
|
whiteSecondary: "2px solid " + TRANSPARENT,
|
|
268
|
-
|
|
304
|
+
greenPrimary: SEA_GREEN,
|
|
305
|
+
greenSecondary: SEA_GREEN
|
|
269
306
|
};
|
|
270
307
|
|
|
271
308
|
const activeColor = {
|
|
@@ -279,8 +316,10 @@ const activeColor = {
|
|
|
279
316
|
tertiary: PEACOCK_BLUE,
|
|
280
317
|
danger: WHITE,
|
|
281
318
|
dangerSecondary: "#910029",
|
|
319
|
+
whitePrimary: WHITE,
|
|
282
320
|
whiteSecondary: WHITE,
|
|
283
|
-
|
|
321
|
+
greenPrimary: WHITE,
|
|
322
|
+
greenSecondary: SEA_GREEN
|
|
284
323
|
};
|
|
285
324
|
|
|
286
325
|
export const fallbackValues = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { SEA_GREEN } from "../../../constants/colors";
|
|
2
3
|
|
|
3
|
-
const SuccessfulIconMedium = ({ iconIndex = 0 }) => {
|
|
4
|
+
const SuccessfulIconMedium = ({ iconIndex = 0, fill = SEA_GREEN }) => {
|
|
4
5
|
const mask0ID = `SuccessfulIconMedium-mask0-${iconIndex}`;
|
|
5
6
|
const mask1ID = `SuccessfulIconMedium-mask1-${iconIndex}`;
|
|
6
7
|
return (
|
|
@@ -11,7 +12,7 @@ const SuccessfulIconMedium = ({ iconIndex = 0 }) => {
|
|
|
11
12
|
fill="none"
|
|
12
13
|
xmlns="http://www.w3.org/2000/svg"
|
|
13
14
|
>
|
|
14
|
-
<circle cx="12" cy="12" r="12" fill=
|
|
15
|
+
<circle cx="12" cy="12" r="12" fill={fill} />
|
|
15
16
|
<mask
|
|
16
17
|
id={mask0ID}
|
|
17
18
|
style={{ maskType: "luminance" }}
|
|
@@ -40,7 +40,11 @@ const Obligation = ({
|
|
|
40
40
|
inactiveLookupInput = "Account",
|
|
41
41
|
inactiveLookupValue = "",
|
|
42
42
|
isInCustomerManagement = false,
|
|
43
|
-
themeValues
|
|
43
|
+
themeValues,
|
|
44
|
+
cartEnabled = false,
|
|
45
|
+
cartConfig = undefined,
|
|
46
|
+
multiCartParams = undefined,
|
|
47
|
+
isInCart = false
|
|
44
48
|
}) => {
|
|
45
49
|
/*
|
|
46
50
|
The value of obligations is always an array. It can contain:
|
|
@@ -144,6 +148,10 @@ const Obligation = ({
|
|
|
144
148
|
subDescription={subDescription}
|
|
145
149
|
allowedPaymentInstruments={allowedPaymentInstruments}
|
|
146
150
|
disableActions={isInCustomerManagement}
|
|
151
|
+
cartEnabled={cartEnabled}
|
|
152
|
+
cartConfig={cartConfig}
|
|
153
|
+
multiCartParams={multiCartParams}
|
|
154
|
+
isInCart={isInCart}
|
|
147
155
|
/>
|
|
148
156
|
)}
|
|
149
157
|
</Stack>
|
|
@@ -168,6 +176,10 @@ const Obligation = ({
|
|
|
168
176
|
subDescription={subDescription}
|
|
169
177
|
allowedPaymentInstruments={allowedPaymentInstruments}
|
|
170
178
|
disableActions={isInCustomerManagement}
|
|
179
|
+
cartEnabled={cartEnabled}
|
|
180
|
+
cartConfig={cartConfig}
|
|
181
|
+
multiCartParams={multiCartParams}
|
|
182
|
+
isInCart={isInCart}
|
|
171
183
|
/>
|
|
172
184
|
)}
|
|
173
185
|
</Box>
|
|
@@ -300,6 +300,7 @@ export const ActiveObligation = {
|
|
|
300
300
|
],
|
|
301
301
|
actions: {
|
|
302
302
|
createPaymentFromProfile: fn(),
|
|
303
|
+
addToMultiCart: fn(),
|
|
303
304
|
setDetailedObligation: fn(),
|
|
304
305
|
navigateToDetailedObligation: fn(),
|
|
305
306
|
deleteObligationAssoc: fn()
|
|
@@ -366,6 +367,7 @@ export const InactiveObligation = {
|
|
|
366
367
|
],
|
|
367
368
|
actions: {
|
|
368
369
|
createPaymentFromProfile: fn(),
|
|
370
|
+
addToMultiCart: fn(),
|
|
369
371
|
setDetailedObligation: fn(),
|
|
370
372
|
navigateToDetailedObligation: fn(),
|
|
371
373
|
deleteObligationAssoc: fn()
|
|
@@ -436,6 +438,7 @@ export const CustomerManagementObligation = {
|
|
|
436
438
|
],
|
|
437
439
|
actions: {
|
|
438
440
|
createPaymentFromProfile: fn(),
|
|
441
|
+
addToMultiCart: fn(),
|
|
439
442
|
setDetailedObligation: fn(),
|
|
440
443
|
navigateToDetailedObligation: fn(),
|
|
441
444
|
deleteObligationAssoc: fn()
|
|
@@ -458,3 +461,72 @@ export const CustomerManagementObligation = {
|
|
|
458
461
|
</Box>
|
|
459
462
|
)
|
|
460
463
|
};
|
|
464
|
+
|
|
465
|
+
export const CartEnabledObligation = {
|
|
466
|
+
args: {
|
|
467
|
+
config: obligationConfig,
|
|
468
|
+
obligations: [
|
|
469
|
+
{
|
|
470
|
+
allowedPaymentInstruments: ["CASH", "CREDIT_CARD", "BANK_ACCOUNT"],
|
|
471
|
+
amountDue: 5438,
|
|
472
|
+
customAttributes: {
|
|
473
|
+
account_number: "1006",
|
|
474
|
+
city: "Cityville",
|
|
475
|
+
client_slug: "Cityville",
|
|
476
|
+
customer_name: "Shadout Mapes",
|
|
477
|
+
due_date: "2024-09-01T12:00:00",
|
|
478
|
+
invoice_number: "101006.0",
|
|
479
|
+
line_item_description: "Shadout Mapes",
|
|
480
|
+
line_item_sub_description: "1006",
|
|
481
|
+
name: "Shadout Mapes",
|
|
482
|
+
service_type: "water",
|
|
483
|
+
state: "North Carolina",
|
|
484
|
+
street_address_line_1: "23145 O'Hara Wells",
|
|
485
|
+
sub_client_slug: "cityville-water",
|
|
486
|
+
total_due_amount: "5438.0",
|
|
487
|
+
utility_type: "water",
|
|
488
|
+
zip_code: "79221"
|
|
489
|
+
},
|
|
490
|
+
id: "1006",
|
|
491
|
+
kind: "FEE",
|
|
492
|
+
description: "Cityville Water Management",
|
|
493
|
+
subDescription: "Account: 1006",
|
|
494
|
+
amountValue: 5438,
|
|
495
|
+
details: {
|
|
496
|
+
description: "Cityville Water Management",
|
|
497
|
+
subDescription: "Account: 1006"
|
|
498
|
+
},
|
|
499
|
+
paymentAttributes: {
|
|
500
|
+
description: "Account: 1006",
|
|
501
|
+
subDescription: "",
|
|
502
|
+
amount: 5438
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
],
|
|
506
|
+
actions: {
|
|
507
|
+
createPaymentFromProfile: fn(),
|
|
508
|
+
addToMultiCart: fn(),
|
|
509
|
+
setDetailedObligation: fn(),
|
|
510
|
+
navigateToDetailedObligation: fn(),
|
|
511
|
+
deleteObligationAssoc: fn()
|
|
512
|
+
},
|
|
513
|
+
autoPayEnabled: true,
|
|
514
|
+
autoPayAvailable: true,
|
|
515
|
+
handleAutopayAction: fn(),
|
|
516
|
+
navigateToSettings: fn(),
|
|
517
|
+
deactivatePaymentSchedule: fn(),
|
|
518
|
+
isMobile: false,
|
|
519
|
+
nextAutopayDate: "On",
|
|
520
|
+
obligationAssocID: "046d66b9-5cea-4ccf-895a-97f21f314b72",
|
|
521
|
+
dueDate: "2024-09-01",
|
|
522
|
+
agencyName: "Water",
|
|
523
|
+
isInCustomerManagement: false,
|
|
524
|
+
cartEnabled: true,
|
|
525
|
+
isInCart: false
|
|
526
|
+
},
|
|
527
|
+
render: args => (
|
|
528
|
+
<Box minWidth="800px">
|
|
529
|
+
<Obligation {...args} />
|
|
530
|
+
</Box>
|
|
531
|
+
)
|
|
532
|
+
};
|
|
@@ -25,7 +25,10 @@ const PaymentDetailsActions = ({
|
|
|
25
25
|
description,
|
|
26
26
|
subDescription,
|
|
27
27
|
allowedPaymentInstruments,
|
|
28
|
-
disableActions = false
|
|
28
|
+
disableActions = false,
|
|
29
|
+
cartEnabled,
|
|
30
|
+
cartConfig,
|
|
31
|
+
isInCart
|
|
29
32
|
}) => {
|
|
30
33
|
const planType = isPaymentPlan ? "Payment Plan" : "Autopay";
|
|
31
34
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -33,6 +36,8 @@ const PaymentDetailsActions = ({
|
|
|
33
36
|
const { obligationSlug } = config;
|
|
34
37
|
const {
|
|
35
38
|
createPaymentFromProfile,
|
|
39
|
+
configureMultiCart,
|
|
40
|
+
addToMultiCart,
|
|
36
41
|
setDetailedObligation,
|
|
37
42
|
navigateToDetailedObligation
|
|
38
43
|
} = actions;
|
|
@@ -41,13 +46,33 @@ const PaymentDetailsActions = ({
|
|
|
41
46
|
? `/profile/accounts/details/${obligationSlug}`
|
|
42
47
|
: `/profile/properties/details/${obligationSlug}`;
|
|
43
48
|
const handleClick = obligations => {
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
if (cartEnabled && cartConfig && !isInCart) {
|
|
50
|
+
configureMultiCart({
|
|
51
|
+
cartId: cartConfig.subClientSlug,
|
|
52
|
+
config: cartConfig
|
|
53
|
+
});
|
|
54
|
+
addToMultiCart({
|
|
55
|
+
cartId: cartConfig.subClientSlug,
|
|
56
|
+
items: cartConfig.addToCartConfig.items,
|
|
57
|
+
itemType: cartConfig.addToCartConfig.itemType
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
setIsLoading(true);
|
|
61
|
+
createPaymentFromProfile(obligations, config);
|
|
62
|
+
}
|
|
46
63
|
};
|
|
47
64
|
const handleDetailsClick = () => {
|
|
48
65
|
setDetailedObligation(obligations, config, obligationAssocID);
|
|
49
66
|
navigateToDetailedObligation(detailsSlug);
|
|
50
67
|
};
|
|
68
|
+
const variant = cartEnabled
|
|
69
|
+
? isInCart
|
|
70
|
+
? "greenPrimry"
|
|
71
|
+
: "secondary"
|
|
72
|
+
: isMobile
|
|
73
|
+
? "smallSecondary"
|
|
74
|
+
: "secondary";
|
|
75
|
+
const text = cartEnabled ? (isInCart ? "In Cart" : "Add to Cart") : "Pay Now";
|
|
51
76
|
return (
|
|
52
77
|
<Box
|
|
53
78
|
padding={isMobile ? "0" : "16px 0 0"}
|
|
@@ -150,9 +175,9 @@ const PaymentDetailsActions = ({
|
|
|
150
175
|
<ButtonWithAction
|
|
151
176
|
isLoading={isLoading}
|
|
152
177
|
action={disableActions ? noop : () => handleClick(obligations)}
|
|
153
|
-
text=
|
|
154
|
-
variant={
|
|
155
|
-
dataQa=
|
|
178
|
+
text={text}
|
|
179
|
+
variant={variant}
|
|
180
|
+
dataQa={text}
|
|
156
181
|
disabled={disableActions}
|
|
157
182
|
/>
|
|
158
183
|
</Box>
|
|
@@ -163,9 +188,9 @@ const PaymentDetailsActions = ({
|
|
|
163
188
|
<ButtonWithAction
|
|
164
189
|
isLoading={isLoading}
|
|
165
190
|
action={disableActions ? noop : () => handleClick(obligations)}
|
|
166
|
-
text=
|
|
167
|
-
variant={
|
|
168
|
-
dataQa=
|
|
191
|
+
text={text}
|
|
192
|
+
variant={variant}
|
|
193
|
+
dataQa={text}
|
|
169
194
|
extraStyles={isMobile && `flex-grow: 1; width: 100%; margin: 0;`}
|
|
170
195
|
disabled={disableActions}
|
|
171
196
|
/>
|
package/src/util/general.js
CHANGED
|
@@ -173,3 +173,43 @@ export const wrapIndex = (index, length) => {
|
|
|
173
173
|
return index;
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Adjusts a hex color by lightening or darkening it.
|
|
179
|
+
*
|
|
180
|
+
* Intended for use when a satisfactory color is not available in the design system.
|
|
181
|
+
*
|
|
182
|
+
* @param {string} hex - The original hex color (e.g., "#3498db").
|
|
183
|
+
* @param {number} percent - The percentage to adjust the color (0-100).
|
|
184
|
+
* @param {string} action - The action to perform: 'lighten' or 'darken'.
|
|
185
|
+
* @returns {string} - The adjusted hex color.
|
|
186
|
+
* @throws {Error} - Throws an error if the action is not 'lighten' or 'darken'.
|
|
187
|
+
*/
|
|
188
|
+
export const adjustHexColor = (hex, percent, action) => {
|
|
189
|
+
// Remove hash at the start if present
|
|
190
|
+
hex = hex.replace(/^\s*#/, "");
|
|
191
|
+
|
|
192
|
+
// Parse r, g, b values
|
|
193
|
+
let r = parseInt(hex.substring(0, 2), 16);
|
|
194
|
+
let g = parseInt(hex.substring(2, 4), 16);
|
|
195
|
+
let b = parseInt(hex.substring(4, 6), 16);
|
|
196
|
+
|
|
197
|
+
// Adjust RGB values based on the action
|
|
198
|
+
if (action === "darken") {
|
|
199
|
+
r = Math.max(0, Math.floor(r * (1 - percent / 100)));
|
|
200
|
+
g = Math.max(0, Math.floor(g * (1 - percent / 100)));
|
|
201
|
+
b = Math.max(0, Math.floor(b * (1 - percent / 100)));
|
|
202
|
+
} else if (action === "lighten") {
|
|
203
|
+
r = Math.min(255, Math.floor(r + (255 - r) * (percent / 100)));
|
|
204
|
+
g = Math.min(255, Math.floor(g + (255 - g) * (percent / 100)));
|
|
205
|
+
b = Math.min(255, Math.floor(b + (255 - b) * (percent / 100)));
|
|
206
|
+
} else {
|
|
207
|
+
throw new Error("Action must be either 'lighten' or 'darken'");
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Convert back to hex
|
|
211
|
+
return `#${((1 << 24) + (r << 16) + (g << 8) + b)
|
|
212
|
+
.toString(16)
|
|
213
|
+
.slice(1)
|
|
214
|
+
.padStart(6, "0")}`;
|
|
215
|
+
};
|