@thecb/components 11.0.3 → 11.1.0-beta.2
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 +47 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +47 -12
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- 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/package.json
CHANGED
|
@@ -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
|
/>
|