@thecb/components 11.1.0-beta.6 → 11.1.0-beta.7

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": "11.1.0-beta.6",
3
+ "version": "11.1.0-beta.7",
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
  } from "./modules";
18
18
  import { themeComponent } from "../../../util/themeUtils";
19
19
  import { fallbackValues } from "./Obligation.theme";
20
+ import { noop } from "../../../util/general";
20
21
 
21
22
  const Obligation = ({
22
23
  config,
@@ -44,7 +45,8 @@ const Obligation = ({
44
45
  cartEnabled = false,
45
46
  cartConfig = undefined,
46
47
  multiCartParams = undefined,
47
- isInCart = false
48
+ isInCart = false,
49
+ openCartSlider = noop
48
50
  }) => {
49
51
  /*
50
52
  The value of obligations is always an array. It can contain:
@@ -152,6 +154,7 @@ const Obligation = ({
152
154
  cartConfig={cartConfig}
153
155
  multiCartParams={multiCartParams}
154
156
  isInCart={isInCart}
157
+ openCartSlider={openCartSlider}
155
158
  />
156
159
  )}
157
160
  </Stack>
@@ -180,6 +183,7 @@ const Obligation = ({
180
183
  cartConfig={cartConfig}
181
184
  multiCartParams={multiCartParams}
182
185
  isInCart={isInCart}
186
+ openCartSlider={openCartSlider}
183
187
  />
184
188
  )}
185
189
  </Box>
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import Obligation from "./Obligation";
3
3
  import { fn } from "@storybook/test";
4
4
  import { Box } from "../../atoms/layouts";
5
+ import { noop } from "../../../util/general";
5
6
 
6
7
  const meta = {
7
8
  title: "Molecules/Obligation",
@@ -203,6 +204,14 @@ const meta = {
203
204
  type: { summary: "boolean" },
204
205
  defaultValue: { summary: false }
205
206
  }
207
+ },
208
+ openCartSlider: {
209
+ description:
210
+ "Function called upon clicking a ButtonWithAction when an obligation is already in the cart. This conveniently opens the cart slider.",
211
+ table: {
212
+ type: { summary: "function" },
213
+ defaultValue: { summary: noop }
214
+ }
206
215
  }
207
216
  }
208
217
  };
@@ -28,7 +28,8 @@ const PaymentDetailsActions = ({
28
28
  disableActions = false,
29
29
  cartEnabled,
30
30
  cartConfig,
31
- isInCart
31
+ isInCart,
32
+ openCartSlider
32
33
  }) => {
33
34
  const planType = isPaymentPlan ? "Payment Plan" : "Autopay";
34
35
  const [isLoading, setIsLoading] = useState(false);
@@ -46,15 +47,17 @@ const PaymentDetailsActions = ({
46
47
  ? `/profile/accounts/details/${obligationSlug}`
47
48
  : `/profile/properties/details/${obligationSlug}`;
48
49
  const handleClick = obligations => {
49
- if (cartEnabled && cartConfig && !isInCart) {
50
- configureMultiCart({
51
- cartId: cartConfig.subClientSlug,
52
- config: cartConfig
53
- });
50
+ if (isInCart) {
51
+ openCartSlider();
52
+ return;
53
+ }
54
+ if (cartEnabled && cartConfig) {
55
+ const { subClientSlug, addToCartConfig } = cartConfig;
56
+ configureMultiCart({ cartId: subClientSlug, config: cartConfig });
54
57
  addToMultiCart({
55
- cartId: cartConfig.subClientSlug,
56
- items: cartConfig.addToCartConfig.items,
57
- itemType: cartConfig.addToCartConfig.itemType
58
+ cartId: subClientSlug,
59
+ items: addToCartConfig.items,
60
+ itemType: addToCartConfig.itemType
58
61
  });
59
62
  } else {
60
63
  setIsLoading(true);
@@ -178,7 +181,7 @@ const PaymentDetailsActions = ({
178
181
  text={text}
179
182
  variant={variant}
180
183
  dataQa={text}
181
- disabled={disableActions || isInCart}
184
+ disabled={disableActions}
182
185
  />
183
186
  </Box>
184
187
  )}
@@ -192,7 +195,7 @@ const PaymentDetailsActions = ({
192
195
  variant={variant}
193
196
  dataQa={text}
194
197
  extraStyles={isMobile && `flex-grow: 1; width: 100%; margin: 0;`}
195
- disabled={disableActions || isInCart}
198
+ disabled={disableActions}
196
199
  />
197
200
  </Box>
198
201
  )}