ublo-lib 1.47.17 → 1.47.19
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/es/common/components/cart-preview/cart-pill.d.ts +3 -1
- package/es/common/components/cart-preview/cart-pill.d.ts.map +1 -1
- package/es/common/components/cart-preview/cart-pill.js +5 -3
- package/es/common/components/cart-preview/cart-preview.d.ts +4 -1
- package/es/common/components/cart-preview/cart-preview.d.ts.map +1 -1
- package/es/common/components/cart-preview/cart-preview.js +8 -5
- package/es/common/components/cart-preview/utils.d.ts.map +1 -1
- package/es/common/components/cart-preview/utils.js +8 -1
- package/package.json +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export default CartPill;
|
|
2
|
-
declare function CartPill({ count }: {
|
|
2
|
+
declare function CartPill({ count, className, forcePillVisibility }: {
|
|
3
3
|
count: any;
|
|
4
|
+
className: any;
|
|
5
|
+
forcePillVisibility: any;
|
|
4
6
|
}): import("react/jsx-runtime").JSX.Element;
|
|
5
7
|
//# sourceMappingURL=cart-pill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart-pill.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cart-preview/cart-pill.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cart-pill.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cart-preview/cart-pill.js"],"names":[],"mappings":";AAIA;;;;4CAMC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import classNames from "classnames";
|
|
3
4
|
import css from "./cart-pill.module.css";
|
|
4
|
-
const CartPill = ({ count }) => {
|
|
5
|
-
if (!count)
|
|
5
|
+
const CartPill = ({ count, className, forcePillVisibility }) => {
|
|
6
|
+
if (!count && !forcePillVisibility)
|
|
6
7
|
return null;
|
|
7
|
-
|
|
8
|
+
const classes = classNames(css.pill, className);
|
|
9
|
+
return _jsx("div", { className: classes, children: count });
|
|
8
10
|
};
|
|
9
11
|
export default CartPill;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export default CartPreview;
|
|
2
|
-
declare function CartPreview({ lang, visible }: {
|
|
2
|
+
declare function CartPreview({ lang, visible, className, pillClassName, forcePillVisibility, }: {
|
|
3
3
|
lang: any;
|
|
4
4
|
visible: any;
|
|
5
|
+
className: any;
|
|
6
|
+
pillClassName: any;
|
|
7
|
+
forcePillVisibility: any;
|
|
5
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
6
9
|
//# sourceMappingURL=cart-preview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart-preview.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cart-preview/cart-preview.js"],"names":[],"mappings":";AAYA
|
|
1
|
+
{"version":3,"file":"cart-preview.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cart-preview/cart-preview.js"],"names":[],"mappings":";AAYA;;;;;;4CA6FC"}
|
|
@@ -9,7 +9,7 @@ import * as API from "./api";
|
|
|
9
9
|
import * as Utils from "./utils";
|
|
10
10
|
import css from "./cart-preview.module.css";
|
|
11
11
|
const { publicRuntimeConfig } = getConfig();
|
|
12
|
-
const CartPreview = ({ lang, visible }) => {
|
|
12
|
+
const CartPreview = ({ lang, visible, className, pillClassName, forcePillVisibility, }) => {
|
|
13
13
|
const { lang: ubloLang = lang } = useUbloContext();
|
|
14
14
|
const { resort } = publicRuntimeConfig;
|
|
15
15
|
const [count, setCount] = React.useState(0);
|
|
@@ -28,16 +28,19 @@ const CartPreview = ({ lang, visible }) => {
|
|
|
28
28
|
getCart();
|
|
29
29
|
}
|
|
30
30
|
}, [ubloLang, resort]);
|
|
31
|
-
if (!cart)
|
|
31
|
+
if (!cart && !forcePillVisibility)
|
|
32
32
|
return null;
|
|
33
|
+
if (!cart) {
|
|
34
|
+
return (_jsx(CartPill, { className: pillClassName, count: count, forcePillVisibility: forcePillVisibility }));
|
|
35
|
+
}
|
|
33
36
|
const { orders: bareOrders, price } = cart.cart;
|
|
34
37
|
const orders = Utils.getOrders(bareOrders);
|
|
35
38
|
const preventClick = (e) => e.preventDefault();
|
|
36
39
|
const stopPropagation = (e) => e.stopPropagation();
|
|
37
|
-
const classes = classNames(css.preview, {
|
|
40
|
+
const classes = classNames(css.preview, className, {
|
|
38
41
|
[css.previewVisible]: visible,
|
|
39
42
|
});
|
|
40
|
-
return (_jsxs(_Fragment, { children: [_jsx(CartPill, { count: count }), _jsxs("div", { className: classes, onClick: preventClick, children: [orders.map((order, i) => {
|
|
43
|
+
return (_jsxs(_Fragment, { children: [_jsx(CartPill, { className: pillClassName, count: count, forcePillVisibility: forcePillVisibility }), cart && (_jsxs("div", { className: classes, onClick: preventClick, children: [orders.map((order, i) => {
|
|
41
44
|
const { inscriptions = [], merchantName, price, total } = order;
|
|
42
45
|
return (_jsxs("div", { className: css.entry, children: [_jsxs("div", { className: css.entryTitle, children: [merchantName, _jsxs("span", { className: css.entryPrice, children: [total || price, " \u20AC"] })] }), _jsx("div", { className: css.entryRows, children: inscriptions.map((inscription, i) => {
|
|
43
46
|
const { product, activity } = inscription;
|
|
@@ -46,6 +49,6 @@ const CartPreview = ({ lang, visible }) => {
|
|
|
46
49
|
const { name, label } = product || activity;
|
|
47
50
|
return (_jsx("p", { className: css.entryRow, children: name || label }, i));
|
|
48
51
|
}) })] }, i));
|
|
49
|
-
}), _jsxs("div", { className: css.total, children: [_jsxs("div", { className: css.totalTitle, children: ["Total ", _jsxs("em", { children: ["(", count, " produits)"] })] }), _jsxs("div", { className: css.totalAmount, children: [price, " \u20AC"] })] }), _jsx(Button, { className: css.bottomButton, onClick: stopPropagation, children: "Voir le panier" })] })] }));
|
|
52
|
+
}), _jsxs("div", { className: css.total, children: [_jsxs("div", { className: css.totalTitle, children: ["Total ", _jsxs("em", { children: ["(", count, " produits)"] })] }), _jsxs("div", { className: css.totalAmount, children: [price, " \u20AC"] })] }), _jsx(Button, { className: css.bottomButton, onClick: stopPropagation, children: "Voir le panier" })] }))] }));
|
|
50
53
|
};
|
|
51
54
|
export default CartPreview;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cart-preview/utils.js"],"names":[],"mappings":"AAcO,oEAIN;AAEM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cart-preview/utils.js"],"names":[],"mappings":"AAcO,oEAIN;AAEM,kDAaN"}
|
|
@@ -21,5 +21,12 @@ export const countInscriptions = (cart) => {
|
|
|
21
21
|
return 0;
|
|
22
22
|
}
|
|
23
23
|
const { orders } = cart.cart;
|
|
24
|
-
return Object.keys(orders).reduce((acc, key) =>
|
|
24
|
+
return Object.keys(orders).reduce((acc, key) => {
|
|
25
|
+
const order = orders[key];
|
|
26
|
+
const subCount = order.reduce((subAcc, orderItem) => {
|
|
27
|
+
const { inscriptions = [] } = orderItem;
|
|
28
|
+
return subAcc + inscriptions.length;
|
|
29
|
+
}, 0);
|
|
30
|
+
return acc + subCount;
|
|
31
|
+
}, 0);
|
|
25
32
|
};
|