ublo-lib 1.36.31 → 1.37.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/es/common/components/cross-selling-editor/cross-selling-editor.d.ts +3 -1
- package/es/common/components/cross-selling-editor/cross-selling-editor.d.ts.map +1 -1
- package/es/common/components/cross-selling-editor/cross-selling-editor.js +4 -2
- package/es/common/components/cross-selling-editor/editor.d.ts +3 -1
- package/es/common/components/cross-selling-editor/editor.d.ts.map +1 -1
- package/es/common/components/cross-selling-editor/editor.js +2 -2
- package/es/common/components/cross-selling-editor/esf/index.d.ts +3 -0
- package/es/common/components/cross-selling-editor/esf/index.d.ts.map +1 -0
- package/es/common/components/cross-selling-editor/esf/index.js +2 -0
- package/es/common/components/cross-selling-editor/esf/special-rule-form.d.ts +12 -0
- package/es/common/components/cross-selling-editor/esf/special-rule-form.d.ts.map +1 -0
- package/es/common/components/cross-selling-editor/esf/special-rule-form.js +27 -0
- package/es/common/components/cross-selling-editor/esf/special-rule-form.module.css +4 -0
- package/es/common/components/cross-selling-editor/esf/step-1.d.ts +12 -0
- package/es/common/components/cross-selling-editor/esf/step-1.d.ts.map +1 -0
- package/es/common/components/cross-selling-editor/esf/step-1.js +78 -0
- package/es/common/components/cross-selling-editor/esf/step-1.module.css +35 -0
- package/es/common/components/cross-selling-editor/esf/step-2.d.ts +12 -0
- package/es/common/components/cross-selling-editor/esf/step-2.d.ts.map +1 -0
- package/es/common/components/cross-selling-editor/esf/step-2.js +157 -0
- package/es/common/components/cross-selling-editor/esf/step-2.module.css +72 -0
- package/es/common/components/cross-selling-editor/hooks/use-custom-offers.d.ts.map +1 -1
- package/es/common/components/cross-selling-editor/hooks/use-custom-offers.js +3 -0
- package/es/common/components/cross-selling-editor/hooks/use-fetch.d.ts +12 -0
- package/es/common/components/cross-selling-editor/hooks/use-fetch.d.ts.map +1 -0
- package/es/common/components/cross-selling-editor/hooks/use-fetch.js +35 -0
- package/es/common/components/cross-selling-editor/hooks/use-tunnel-offers.d.ts.map +1 -1
- package/es/common/components/cross-selling-editor/hooks/use-tunnel-offers.js +2 -0
- package/es/common/components/cross-selling-editor/override.d.ts +2 -1
- package/es/common/components/cross-selling-editor/override.d.ts.map +1 -1
- package/es/common/components/cross-selling-editor/override.js +12 -6
- package/es/common/components/cross-selling-editor/overrides-list.d.ts.map +1 -1
- package/es/common/components/cross-selling-editor/overrides-list.js +9 -6
- package/es/common/components/cross-selling-editor/overrides-list.module.css +24 -8
- package/es/common/components/cross-selling-editor/rules.d.ts +3 -2
- package/es/common/components/cross-selling-editor/rules.d.ts.map +1 -1
- package/es/common/components/cross-selling-editor/rules.js +18 -7
- package/es/common/components/cross-selling-editor/services/api.d.ts +7 -0
- package/es/common/components/cross-selling-editor/services/api.d.ts.map +1 -1
- package/es/common/components/cross-selling-editor/services/api.js +101 -3
- package/es/common/components/cross-selling-editor/services/utils.d.ts +7 -4
- package/es/common/components/cross-selling-editor/services/utils.d.ts.map +1 -1
- package/es/common/components/cross-selling-editor/services/utils.js +51 -11
- package/es/common/components/cross-selling-editor/tester/index.d.ts +3 -0
- package/es/common/components/cross-selling-editor/tester/index.d.ts.map +1 -0
- package/es/common/components/cross-selling-editor/tester/index.js +2 -0
- package/es/common/components/cross-selling-editor/tester/tester.d.ts +11 -0
- package/es/common/components/cross-selling-editor/tester/tester.d.ts.map +1 -0
- package/es/common/components/cross-selling-editor/{tester.js → tester/tester.js} +72 -27
- package/es/common/components/cross-selling-editor/{tester.module.css → tester/tester.module.css} +1 -0
- package/es/common/components/cross-selling-editor/{tester-tunnel-offer.d.ts → tester/tunnel-offer.d.ts} +4 -3
- package/es/common/components/cross-selling-editor/tester/tunnel-offer.d.ts.map +1 -0
- package/es/common/components/cross-selling-editor/tester/tunnel-offer.js +54 -0
- package/es/common/components/cross-selling-editor/{tester-tunnel-offer.module.css → tester/tunnel-offer.module.css} +16 -3
- package/es/common/components/cross-selling-editor/types.d.ts +65 -0
- package/es/common/components/cross-selling-editor/types.d.ts.map +1 -1
- package/es/lbm/components/instant-search/services/api.d.ts +0 -1
- package/es/lbm/components/instant-search/services/api.d.ts.map +1 -1
- package/es/lbm/components/instant-search/services/api.js +1 -12
- package/package.json +1 -1
- package/es/common/components/cross-selling-editor/tester-tunnel-offer.d.ts.map +0 -1
- package/es/common/components/cross-selling-editor/tester-tunnel-offer.js +0 -21
- package/es/common/components/cross-selling-editor/tester.d.ts +0 -10
- package/es/common/components/cross-selling-editor/tester.d.ts.map +0 -1
|
@@ -11,7 +11,8 @@ type Props = {
|
|
|
11
11
|
setConfig: React.Dispatch<React.SetStateAction<Config>>;
|
|
12
12
|
closeCreationForm: () => void;
|
|
13
13
|
durations: Durations;
|
|
14
|
+
isEsf: boolean;
|
|
14
15
|
};
|
|
15
|
-
export default function Override({ index, currentOffer, overrides, override, currentOverride, setCurrentOverride, config, setConfig, closeCreationForm, durations, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export default function Override({ index, currentOffer, overrides, override, currentOverride, setCurrentOverride, config, setConfig, closeCreationForm, durations, isEsf, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
export {};
|
|
17
18
|
//# sourceMappingURL=override.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"override.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cross-selling-editor/override.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"override.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cross-selling-editor/override.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EAET,QAAQ,IAAI,YAAY,EACzB,MAAM,SAAS,CAAC;AAEjB,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,QAAQ,EAAE,YAAY,CAAC;IACvB,eAAe,EAAE,YAAY,CAAC;IAC9B,kBAAkB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,KAAK,EACL,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,eAAe,EACf,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,KAAK,GACN,EAAE,KAAK,2CAyLP"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import Popover from "dt-design-system/es/popover";
|
|
@@ -7,9 +7,11 @@ import Input from "dt-design-system/es/input";
|
|
|
7
7
|
import Tooltip from "dt-design-system/es/tooltip";
|
|
8
8
|
import * as Icons from "dt-design-system/es/icons";
|
|
9
9
|
import OverrideTriggerForm from "./override-trigger-form";
|
|
10
|
+
import ESFSpecialRuleForm from "./esf/special-rule-form";
|
|
10
11
|
import styles from "./override.module.css";
|
|
11
|
-
export default function Override({ index, currentOffer, overrides, override, currentOverride, setCurrentOverride, config, setConfig, closeCreationForm, durations, }) {
|
|
12
|
+
export default function Override({ index, currentOffer, overrides, override, currentOverride, setCurrentOverride, config, setConfig, closeCreationForm, durations, isEsf, }) {
|
|
12
13
|
const [formOpen, setFormOpen] = React.useState(false);
|
|
14
|
+
const [esfDialogOpen, setEsfDialogOpen] = React.useState(false);
|
|
13
15
|
const isFirst = index === 0;
|
|
14
16
|
const isLast = index === overrides.length - 1;
|
|
15
17
|
const toggleFormOpen = (e) => {
|
|
@@ -19,6 +21,13 @@ export default function Override({ index, currentOffer, overrides, override, cur
|
|
|
19
21
|
const updateFormOpen = (open) => {
|
|
20
22
|
setFormOpen(open);
|
|
21
23
|
};
|
|
24
|
+
const openEsfDialog = (e) => {
|
|
25
|
+
e.stopPropagation();
|
|
26
|
+
setEsfDialogOpen(true);
|
|
27
|
+
};
|
|
28
|
+
const closeEsfDialog = () => {
|
|
29
|
+
setEsfDialogOpen(false);
|
|
30
|
+
};
|
|
22
31
|
const updateCurrentOverride = () => {
|
|
23
32
|
const isSelected = currentOverride && override.id === currentOverride.id;
|
|
24
33
|
setCurrentOverride(isSelected ? null : override);
|
|
@@ -62,9 +71,6 @@ export default function Override({ index, currentOffer, overrides, override, cur
|
|
|
62
71
|
});
|
|
63
72
|
closeCreationForm();
|
|
64
73
|
};
|
|
65
|
-
const stopPropagation = (e) => {
|
|
66
|
-
e.stopPropagation();
|
|
67
|
-
};
|
|
68
74
|
const updateOverrideName = (e) => {
|
|
69
75
|
e.stopPropagation();
|
|
70
76
|
const target = e.target;
|
|
@@ -97,5 +103,5 @@ export default function Override({ index, currentOffer, overrides, override, cur
|
|
|
97
103
|
const classes = classNames(styles.override, {
|
|
98
104
|
[styles.current]: currentOverride && override.id === currentOverride.id,
|
|
99
105
|
});
|
|
100
|
-
return (_jsxs("div", { className: classes, onClick: updateCurrentOverride, children: [_jsxs("div", { className: styles.sortControls, children: [_jsx(Button, { variant: "transparent", className: styles.sortControl, disabled: isFirst, onClick: sort("up"), compact: true, children: _jsx(Icons.ChevronUp, {}) }), _jsx(Button, { variant: "transparent", className: styles.sortControl, disabled: isLast, onClick: sort("down"), compact: true, children: _jsx(Icons.ChevronDown, {}) })] }), _jsx(Input, { className: styles.input, value: override.name, onChange: updateOverrideName, onClick: stopPropagation, onBlur: updateOverrideName, compact: true }), _jsx(Popover, { trigger: _jsx(Button, { className: styles.edit, compact: true, onClick: toggleFormOpen, children: _jsx(Icons.Tune, {}) }), open: formOpen, onOpenChange: updateFormOpen, children: _jsx(OverrideTriggerForm, { currentOffer: currentOffer, override: override, setConfig: setConfig, durations: durations }) }), _jsx(Tooltip, { content: "Supprimer", children: _jsx(Button, { className: styles.delete, variant: "danger", compact: true, onClick: removeOverride, children: _jsx(Icons.Bin, {}) }) })] }));
|
|
106
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: classes, onClick: updateCurrentOverride, children: [_jsxs("div", { className: styles.sortControls, children: [_jsx(Button, { variant: "transparent", className: styles.sortControl, disabled: isFirst, onClick: sort("up"), compact: true, children: _jsx(Icons.ChevronUp, {}) }), _jsx(Button, { variant: "transparent", className: styles.sortControl, disabled: isLast, onClick: sort("down"), compact: true, children: _jsx(Icons.ChevronDown, {}) })] }), _jsx(Input, { className: styles.input, value: override.name, onChange: updateOverrideName, onClick: (e) => e.stopPropagation(), onBlur: updateOverrideName, compact: true }), isEsf ? (_jsx(Button, { className: styles.edit, compact: true, onClick: openEsfDialog, children: _jsx(Icons.Tune, {}) })) : (_jsx(Popover, { trigger: _jsx(Button, { className: styles.edit, compact: true, onClick: toggleFormOpen, children: _jsx(Icons.Tune, {}) }), open: formOpen, onOpenChange: updateFormOpen, children: _jsx(OverrideTriggerForm, { currentOffer: currentOffer, override: override, setConfig: setConfig, durations: durations }) })), _jsx(Tooltip, { content: "Supprimer", children: _jsx(Button, { className: styles.delete, variant: "danger", compact: true, onClick: removeOverride, children: _jsx(Icons.Bin, {}) }) })] }), isEsf && (_jsx(ESFSpecialRuleForm, { open: esfDialogOpen, close: closeEsfDialog, currentOffer: currentOffer, override: override, setConfig: setConfig }))] }));
|
|
101
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides-list.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cross-selling-editor/overrides-list.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EAET,QAAQ,IAAI,YAAY,EACzB,MAAM,SAAS,CAAC;AAEjB,KAAK,KAAK,GAAG;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,eAAe,EAAE,YAAY,CAAC;IAC9B,kBAAkB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,YAAY,EACZ,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,SAAS,GACV,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"overrides-list.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cross-selling-editor/overrides-list.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EAET,QAAQ,IAAI,YAAY,EACzB,MAAM,SAAS,CAAC;AAEjB,KAAK,KAAK,GAAG;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,eAAe,EAAE,YAAY,CAAC;IAC9B,kBAAkB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,YAAY,EACZ,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,SAAS,GACV,EAAE,KAAK,2CA2IP"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import Button from "dt-design-system/es/button";
|
|
4
4
|
import Collapsible from "dt-design-system/es/collapsible";
|
|
@@ -38,7 +38,7 @@ export default function OverridesList({ currentOffer, overrides, currentOverride
|
|
|
38
38
|
...itemConfig,
|
|
39
39
|
overrides: [
|
|
40
40
|
...itemOverrides,
|
|
41
|
-
{ id: newId, name: newOverrideName,
|
|
41
|
+
{ id: newId, name: newOverrideName, triggers: {}, rules: {} },
|
|
42
42
|
],
|
|
43
43
|
},
|
|
44
44
|
};
|
|
@@ -48,8 +48,11 @@ export default function OverridesList({ currentOffer, overrides, currentOverride
|
|
|
48
48
|
setNewOverride("");
|
|
49
49
|
closeCreationForm();
|
|
50
50
|
};
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
const isEsf = currentOffer === "ESF";
|
|
52
|
+
const labelPlural = isEsf ? "règles" : "surcharges";
|
|
53
|
+
const labelSingular = isEsf ? "règle" : "surcharge";
|
|
54
|
+
const title = (_jsxs("span", { className: styles.title, children: [overrides.length, " ", overrides.length === 1 ? labelSingular : labelPlural, _jsxs(Popover, { className: styles.titlePopover, trigger: _jsx(Button, { variant: "transparent", compact: true, children: _jsx(Icons.Info, {}) }), children: [_jsxs("b", { children: ["Si plusieurs ", labelPlural] }), " correspondent au contenu du panier,", " ", _jsx("b", { children: "seule la premi\u00E8re est appliqu\u00E9e" }), ".", _jsx("br", {}), "Vous pouvez changer l'ordre des ", labelPlural, " \u00E0 l'aide des fl\u00E8ches visible \u00E0 gauche de chaque ", labelSingular, " au survol de ces derni\u00E8res."] })] }));
|
|
55
|
+
return (_jsxs("div", { className: styles.overrides, children: [hasOverrides ? (_jsx(Collapsible, { title: title, className: styles.collapsible, compact: true, open: opened, toggleTooltip: `Afficher toutes les ${labelPlural}`, onOpenChange: setOpened, hiddenContent: overrides.map((override, index) => {
|
|
56
|
+
return (_jsx(Override, { index: index, currentOffer: currentOffer, overrides: overrides, override: override, currentOverride: currentOverride, setCurrentOverride: setCurrentOverride, config: config, setConfig: setConfig, closeCreationForm: closeCreationForm, durations: durations, isEsf: isEsf }, override.id));
|
|
57
|
+
}) })) : null, _jsx(Popover, { className: styles.popover, trigger: _jsxs(Button, { className: styles.addOverride, onClick: toggleCreationForm, variant: "transparent", compact: true, children: ["Ajouter une ", labelSingular, " ", _jsx(Icons.Plus, {})] }), open: creationFormOpened, children: _jsxs("form", { className: styles.createForm, onSubmit: createOverride, children: [_jsx(Input, { placeholder: "Nom", value: newOverride, onValueChange: setNewOverride, error: error, compact: true, autoFocus: true }), _jsx(Button, { className: styles.createSubmit, type: "submit", disabled: newOverrideIsInvalid, children: "Ajouter" })] }) })] }));
|
|
55
58
|
}
|
|
@@ -21,15 +21,30 @@
|
|
|
21
21
|
border-radius: var(--ds-radius-100, 4px);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.addOverride {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
button.addOverride {
|
|
25
|
+
--ds-button-compact-padding: 7px;
|
|
26
|
+
--ds-button-font-weight: 400;
|
|
27
|
+
--ds-button-font-size: 13px;
|
|
28
|
+
--ds-button-radius: var(--ds-radius-100, 4px);
|
|
29
|
+
|
|
30
|
+
width: 100%;
|
|
31
|
+
justify-content: flex-start;
|
|
32
|
+
text-align: left;
|
|
30
33
|
background-color: var(--ds-grey-100, #f8f8f8);
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
button.addOverride:hover {
|
|
37
|
+
background-color: var(--ds-grey-200, #ededed);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
button.addOverride > svg {
|
|
41
|
+
--size: 22px;
|
|
42
|
+
|
|
43
|
+
margin-left: auto;
|
|
44
|
+
padding: 4px;
|
|
45
|
+
fill: var(--ds-grey-100, #f8f8f8);
|
|
46
|
+
background-color: var(--ds-primary, var(--ds-blue-500, #002dcc));
|
|
47
|
+
border-radius: var(--ds-radius-200, 8px);
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
.collapsible {
|
|
@@ -45,6 +60,7 @@
|
|
|
45
60
|
.title {
|
|
46
61
|
display: flex;
|
|
47
62
|
align-items: center;
|
|
63
|
+
gap: 3px;
|
|
48
64
|
}
|
|
49
65
|
|
|
50
66
|
.titlePopover {
|
|
@@ -4,9 +4,10 @@ type Props = {
|
|
|
4
4
|
container: HTMLElement;
|
|
5
5
|
config: Config;
|
|
6
6
|
setConfig: React.Dispatch<React.SetStateAction<Config>>;
|
|
7
|
-
tunnelOffers: Record<string, string>;
|
|
8
7
|
durations: Durations;
|
|
8
|
+
tunnelOffersOrder?: string[];
|
|
9
|
+
displayedTunnelOffers?: string[];
|
|
9
10
|
};
|
|
10
|
-
export default function Rules({ container, config, setConfig,
|
|
11
|
+
export default function Rules({ container, config, setConfig, durations, tunnelOffersOrder, displayedTunnelOffers, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export {};
|
|
12
13
|
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cross-selling-editor/rules.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEjD,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../../src/common/components/cross-selling-editor/rules.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEjD,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,SAAS,EACT,MAAM,EACN,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,qBAAqB,GACtB,EAAE,KAAK,2CAuGP"}
|
|
@@ -8,8 +8,23 @@ import Rule from "./rule";
|
|
|
8
8
|
import OverridesList from "./overrides-list";
|
|
9
9
|
import * as Utils from "./services/utils";
|
|
10
10
|
import styles from "./rules.module.css";
|
|
11
|
-
export default function Rules({ container, config, setConfig,
|
|
12
|
-
const
|
|
11
|
+
export default function Rules({ container, config, setConfig, durations, tunnelOffersOrder, displayedTunnelOffers, }) {
|
|
12
|
+
const tunnelOptions = Object.keys(Utils.tunnelOffers)
|
|
13
|
+
.map((key) => {
|
|
14
|
+
const label = Utils.tunnelOffers[key];
|
|
15
|
+
return { value: key, label };
|
|
16
|
+
})
|
|
17
|
+
.filter(({ value }) => {
|
|
18
|
+
if (!displayedTunnelOffers)
|
|
19
|
+
return true;
|
|
20
|
+
return displayedTunnelOffers.includes(value);
|
|
21
|
+
})
|
|
22
|
+
.sort((a, b) => {
|
|
23
|
+
if (!tunnelOffersOrder)
|
|
24
|
+
return 0;
|
|
25
|
+
return (tunnelOffersOrder.indexOf(a.value) - tunnelOffersOrder.indexOf(b.value));
|
|
26
|
+
});
|
|
27
|
+
const [currentOffer, setCurrentOffer] = React.useState(tunnelOptions.length === 1 ? tunnelOptions[0].value : "");
|
|
13
28
|
const [currentOverride, setCurrentOverride] = React.useState(null);
|
|
14
29
|
const overrides = config[currentOffer]?.overrides || [];
|
|
15
30
|
const showOverrides = currentOffer && Utils.hasAllowedOverrides(currentOffer);
|
|
@@ -19,11 +34,7 @@ export default function Rules({ container, config, setConfig, tunnelOffers, dura
|
|
|
19
34
|
setCurrentOffer(newCurrentOffer);
|
|
20
35
|
setCurrentOverride(null);
|
|
21
36
|
};
|
|
22
|
-
|
|
23
|
-
const label = tunnelOffers[key];
|
|
24
|
-
return { value: key, label };
|
|
25
|
-
});
|
|
26
|
-
return (_jsxs("div", { className: styles.container, children: [_jsxs("div", { className: styles.title, children: ["Configuration", _jsx(Popover, { className: styles.popover, trigger: _jsx(Button, { variant: "transparent", children: _jsx(Icons.Info, {}) }), children: "La configuration vous permet de personnaliser l'ordre d'affichage des produits sugg\u00E9r\u00E9s dans le panier en fonction des produits pr\u00E9sents dans le panier de l'utilisateur." })] }), _jsx("div", { className: styles.explanation, children: "Configurez les suggestions de produit en fonction du contenu du panier" }), _jsx(Select, { className: styles.select, label: "Produit ajout\u00E9 au panier", placeholder: "S\u00E9lectionnez un produit", value: currentOffer, options: tunnelOptions, onValueChange: updateCurrentOffer }), showOverrides && (_jsx(OverridesList, { currentOffer: currentOffer, overrides: overrides, currentOverride: currentOverride, setCurrentOverride: setCurrentOverride, config: config, setConfig: setConfig, durations: durations })), currentOffer && (_jsxs(_Fragment, { children: [_jsx("div", { className: styles.subTitle, children: "Priorisation par types de produit" }), sections.map((section) => {
|
|
37
|
+
return (_jsxs("div", { className: styles.container, children: [_jsxs("div", { className: styles.title, children: ["Configuration", _jsx(Popover, { className: styles.popover, trigger: _jsx(Button, { variant: "transparent", children: _jsx(Icons.Info, {}) }), children: "La configuration vous permet de personnaliser l'ordre d'affichage des produits sugg\u00E9r\u00E9s dans le panier en fonction des produits pr\u00E9sents dans le panier de l'utilisateur." })] }), _jsx("div", { className: styles.explanation, children: "Configurez les suggestions de produit en fonction du contenu du panier" }), _jsx(Select, { className: styles.select, label: "Produit ajout\u00E9 au panier", placeholder: "S\u00E9lectionnez un produit", value: currentOffer, options: tunnelOptions, onValueChange: updateCurrentOffer, disabled: tunnelOptions.length <= 1 }), showOverrides && (_jsx(OverridesList, { currentOffer: currentOffer, overrides: overrides, currentOverride: currentOverride, setCurrentOverride: setCurrentOverride, config: config, setConfig: setConfig, durations: durations })), currentOffer && (_jsxs(_Fragment, { children: [_jsx("div", { className: styles.subTitle, children: "Priorisation par types de produit" }), sections.map((section) => {
|
|
27
38
|
const uuid = section.getAttribute("data-uuid");
|
|
28
39
|
const title = section.querySelector(".tunnel-offer__title").textContent;
|
|
29
40
|
return (_jsx(Rule, { uuid: uuid, uuids: uuids, title: title, currentOffer: currentOffer, currentOverride: currentOverride, config: config, setConfig: setConfig }, title));
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
export declare function fetchTunnelOffers(lang: string, facet: 0 | 1): Promise<any>;
|
|
2
2
|
export declare function fetchMseMCart(cartId: string, lang: string): Promise<any>;
|
|
3
|
+
export declare function fetchEsfWelcome(lang: string, abortController: AbortController): Promise<any>;
|
|
4
|
+
export declare function fetchEsfKinds(lang: string, season: string, stayFrom: string, stayTo: string, period: number, abortController: AbortController): Promise<any>;
|
|
5
|
+
export declare function fetchEsfAges(lang: string, season: string, stayFrom: string, stayTo: string, period: number, abortController: AbortController): Promise<any>;
|
|
6
|
+
export declare function fetchEsfActivities(lang: string, season: string, stayFrom: string, stayTo: string, period: number, ages: string[], kinds: string[], abortController: AbortController): Promise<any>;
|
|
7
|
+
export declare function fetchEsfLevels(lang: string, season: string, stayFrom: string, stayTo: string, period: number, activities: string[], ages: string[], kinds: string[], abortController: AbortController): Promise<any>;
|
|
8
|
+
export declare function fetchEsfMeetings(lang: string, season: string, stayFrom: string, stayTo: string, period: number, activities: string[], ages: string[], kinds: string[], levels: string[], abortController: AbortController): Promise<any>;
|
|
9
|
+
export declare function fetchEsfProducts(lang: string, season: string, stayFrom: string, stayTo: string, period: number, activities: string[], ages: string[], kinds: string[], levels: string[], meetings: string[], abortController: AbortController): Promise<any>;
|
|
3
10
|
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/cross-selling-editor/services/api.ts"],"names":[],"mappings":"AAOA,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/cross-selling-editor/services/api.ts"],"names":[],"mappings":"AAOA,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,gBASjE;AAED,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAW/D;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,eAAe,gBAWjC;AAED,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,gBAqBjC;AAED,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,gBAmBjC;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,EAAE,EACf,eAAe,EAAE,eAAe,gBAqBjC;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAAE,EACpB,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,EAAE,EACf,eAAe,EAAE,eAAe,gBAsBjC;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAAE,EACpB,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,MAAM,EAAE,EAChB,eAAe,EAAE,eAAe,gBAuBjC;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAAE,EACpB,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,MAAM,EAAE,EAClB,eAAe,EAAE,eAAe,gBAwBjC"}
|
|
@@ -4,13 +4,111 @@ const { publicRuntimeConfig } = getConfig();
|
|
|
4
4
|
const { msemServicesUrl, esfplusUrl, channel, resort } = publicRuntimeConfig;
|
|
5
5
|
export async function fetchTunnelOffers(lang, facet) {
|
|
6
6
|
const endpoint = `${msemServicesUrl}/api/tunnel/offers/${channel}/${resort}`;
|
|
7
|
-
const result = await Fetcher.get(endpoint, { lang, facet });
|
|
7
|
+
const result = await Fetcher.get(endpoint, { lang, facet }, undefined, undefined);
|
|
8
8
|
return result;
|
|
9
9
|
}
|
|
10
10
|
export async function fetchMseMCart(cartId, lang) {
|
|
11
11
|
const endpoint = `${esfplusUrl}/api/esfplus/cart`;
|
|
12
12
|
const id = JSON.parse(cartId);
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const result = await Fetcher.post(endpoint, { cartId: id, lang, resort }, undefined, undefined, undefined);
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
export async function fetchEsfWelcome(lang, abortController) {
|
|
17
|
+
const endpoint = `${msemServicesUrl}/api/esf/welcome`;
|
|
18
|
+
const result = await Fetcher.post(endpoint, { lang, resort: String(resort) }, { skipValidation: true }, undefined, abortController.signal);
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
export async function fetchEsfKinds(lang, season, stayFrom, stayTo, period, abortController) {
|
|
22
|
+
const endpoint = `${msemServicesUrl}/api/esf/kinds`;
|
|
23
|
+
const result = await Fetcher.post(endpoint, {
|
|
24
|
+
duplicateCP: true,
|
|
25
|
+
editor: true,
|
|
26
|
+
lang,
|
|
27
|
+
period,
|
|
28
|
+
preview: true,
|
|
29
|
+
resort: String(resort),
|
|
30
|
+
season,
|
|
31
|
+
stayFrom,
|
|
32
|
+
stayTo,
|
|
33
|
+
}, { skipValidation: true }, undefined, abortController.signal);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
export async function fetchEsfAges(lang, season, stayFrom, stayTo, period, abortController) {
|
|
37
|
+
const endpoint = `${msemServicesUrl}/api/esf/ages`;
|
|
38
|
+
const result = await Fetcher.post(endpoint, {
|
|
39
|
+
editor: true,
|
|
40
|
+
lang,
|
|
41
|
+
period,
|
|
42
|
+
resort: String(resort),
|
|
43
|
+
season,
|
|
44
|
+
stayFrom,
|
|
45
|
+
stayTo,
|
|
46
|
+
}, { skipValidation: true }, undefined, abortController.signal);
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
export async function fetchEsfActivities(lang, season, stayFrom, stayTo, period, ages, kinds, abortController) {
|
|
50
|
+
const endpoint = `${msemServicesUrl}/api/esf/activities`;
|
|
51
|
+
const result = await Fetcher.post(endpoint, {
|
|
52
|
+
ages,
|
|
53
|
+
editor: true,
|
|
54
|
+
kinds,
|
|
55
|
+
lang,
|
|
56
|
+
period,
|
|
57
|
+
resort: String(resort),
|
|
58
|
+
season,
|
|
59
|
+
stayFrom,
|
|
60
|
+
stayTo,
|
|
61
|
+
}, { skipValidation: true }, undefined, abortController.signal);
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
export async function fetchEsfLevels(lang, season, stayFrom, stayTo, period, activities, ages, kinds, abortController) {
|
|
65
|
+
const endpoint = `${msemServicesUrl}/api/esf/levels`;
|
|
66
|
+
const result = await Fetcher.post(endpoint, {
|
|
67
|
+
activities,
|
|
68
|
+
ages,
|
|
69
|
+
editor: true,
|
|
70
|
+
kinds,
|
|
71
|
+
lang,
|
|
72
|
+
period,
|
|
73
|
+
resort: String(resort),
|
|
74
|
+
season,
|
|
75
|
+
stayFrom,
|
|
76
|
+
stayTo,
|
|
77
|
+
}, { skipValidation: true }, undefined, abortController.signal);
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
export async function fetchEsfMeetings(lang, season, stayFrom, stayTo, period, activities, ages, kinds, levels, abortController) {
|
|
81
|
+
const endpoint = `${msemServicesUrl}/api/esf/meetings`;
|
|
82
|
+
const result = await Fetcher.post(endpoint, {
|
|
83
|
+
activities,
|
|
84
|
+
ages,
|
|
85
|
+
editor: true,
|
|
86
|
+
kinds,
|
|
87
|
+
lang,
|
|
88
|
+
levels,
|
|
89
|
+
period,
|
|
90
|
+
resort: String(resort),
|
|
91
|
+
season,
|
|
92
|
+
stayFrom,
|
|
93
|
+
stayTo,
|
|
94
|
+
}, { skipValidation: true }, undefined, abortController.signal);
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
export async function fetchEsfProducts(lang, season, stayFrom, stayTo, period, activities, ages, kinds, levels, meetings, abortController) {
|
|
98
|
+
const endpoint = `${msemServicesUrl}/api/esf/products`;
|
|
99
|
+
const result = await Fetcher.post(endpoint, {
|
|
100
|
+
activities,
|
|
101
|
+
ages,
|
|
102
|
+
editor: true,
|
|
103
|
+
kinds,
|
|
104
|
+
lang,
|
|
105
|
+
levels,
|
|
106
|
+
period,
|
|
107
|
+
resort: String(resort),
|
|
108
|
+
season,
|
|
109
|
+
stayFrom,
|
|
110
|
+
stayTo,
|
|
111
|
+
filters: { codesLieuRendezVous: meetings },
|
|
112
|
+
}, { skipValidation: true }, undefined, abortController.signal);
|
|
15
113
|
return result;
|
|
16
114
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config, Override } from "../types";
|
|
1
|
+
import type { Config, EsfOffersContent, Override } from "../types";
|
|
2
2
|
type Stay = {
|
|
3
3
|
from?: string;
|
|
4
4
|
to?: string;
|
|
@@ -10,6 +10,7 @@ type CartContent = {
|
|
|
10
10
|
stay?: Stay;
|
|
11
11
|
skiPassDurations?: number[];
|
|
12
12
|
durationTags?: string[];
|
|
13
|
+
esfOffersContent?: EsfOffersContent[];
|
|
13
14
|
};
|
|
14
15
|
export declare const tunnelOffers: {
|
|
15
16
|
HOT: string;
|
|
@@ -20,19 +21,19 @@ export declare const tunnelOffers: {
|
|
|
20
21
|
STAND: string;
|
|
21
22
|
};
|
|
22
23
|
type OrderKey = keyof typeof tunnelOffers;
|
|
23
|
-
export declare function getSortedOffers(container: HTMLElement, cartContent: CartContent, config: Config): {
|
|
24
|
+
export declare function getSortedOffers(container: HTMLElement, cartContent: CartContent, config: Config, forcedEsfOverride?: string): {
|
|
24
25
|
title: string;
|
|
25
26
|
weight: number;
|
|
26
27
|
elementHTML: string;
|
|
27
28
|
isHidden: boolean;
|
|
28
29
|
}[];
|
|
29
|
-
export declare function getActiveOverride(key: string | OrderKey, cartContent: CartContent, config: Config): Override;
|
|
30
|
+
export declare function getActiveOverride(key: string | OrderKey, cartContent: CartContent, config: Config, forcedEsfOverride?: string): Override;
|
|
30
31
|
export declare const allowedOverrides: string[];
|
|
31
32
|
export declare function hasAllowedOverrides(kind: string): boolean;
|
|
32
33
|
type Inscription = {
|
|
33
|
-
skipassCatalog: string;
|
|
34
34
|
duration: string;
|
|
35
35
|
durationTags?: string[];
|
|
36
|
+
codes: EsfOffersContent;
|
|
36
37
|
};
|
|
37
38
|
type Order = {
|
|
38
39
|
merchant: string;
|
|
@@ -56,7 +57,9 @@ export declare function getStayFromCart(cart: Cart): {
|
|
|
56
57
|
};
|
|
57
58
|
export declare function getSkiPassDurationFromCart(cart: Cart): Promise<number[]>;
|
|
58
59
|
export declare function getDurationTagsFromCart(cart: Cart): Promise<string[]>;
|
|
60
|
+
export declare function getEsfOffersFromCart(cart: Cart): EsfOffersContent[];
|
|
59
61
|
export declare const CONFIG_ID = "cross-selling-editor";
|
|
60
62
|
export declare function getConfig(container: HTMLElement): any;
|
|
63
|
+
export declare function getIntervalLengthFromDates(from: string, to: string): number;
|
|
61
64
|
export {};
|
|
62
65
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/cross-selling-editor/services/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAa,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/cross-selling-editor/services/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAa,MAAM,UAAU,CAAC;AAE9E,KAAK,IAAI,GAAG;IACV,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;CAOxB,CAAC;AAEF,KAAK,QAAQ,GAAG,MAAM,OAAO,YAAY,CAAC;AAE1C,wBAAgB,eAAe,CAC7B,SAAS,EAAE,WAAW,EACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,iBAAiB,CAAC,EAAE,MAAM;;;;;IA6D3B;AAED,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,GAAG,QAAQ,EACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,iBAAiB,CAAC,EAAE,MAAM,YAoB3B;AAqID,eAAO,MAAM,gBAAgB,UAAgD,CAAC;AAE9E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,WAE/C;AAED,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF,KAAK,KAAK,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC;AAE/D,KAAK,IAAI,GAAG;IACV,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,MAY3C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,YAS9C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI;;;;;;;;EAMzC;AAED,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,IAAI,qBAK1D;AAcD,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,IAAI,qBAQvD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,gBAAgB,EAAE,CAUnE;AAED,eAAO,MAAM,SAAS,yBAAyB,CAAC;AAEhD,wBAAgB,SAAS,CAAC,SAAS,EAAE,WAAW,OAI/C;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAOlE"}
|
|
@@ -2,11 +2,11 @@ export const tunnelOffers = {
|
|
|
2
2
|
HOT: "Hébergement",
|
|
3
3
|
LIFT: "Forfait",
|
|
4
4
|
SKI_RENTAL: "Location de matériel",
|
|
5
|
-
ESF: "
|
|
5
|
+
ESF: "Produit esf",
|
|
6
6
|
CONCIERGERIE: "Conciergerie",
|
|
7
7
|
STAND: "Autre produit",
|
|
8
8
|
};
|
|
9
|
-
export function getSortedOffers(container, cartContent, config) {
|
|
9
|
+
export function getSortedOffers(container, cartContent, config, forcedEsfOverride) {
|
|
10
10
|
if (!container || !cartContent || !config)
|
|
11
11
|
return [];
|
|
12
12
|
const sections = Array.from(container.querySelectorAll(".tunnel-offer"));
|
|
@@ -23,13 +23,13 @@ export function getSortedOffers(container, cartContent, config) {
|
|
|
23
23
|
const title = clonedSection.querySelector(".tunnel-offer__title, [data-title]")?.textContent;
|
|
24
24
|
const uuid = section.getAttribute("data-uuid") || "";
|
|
25
25
|
const weight = Object.keys(config).reduce((acc, key) => {
|
|
26
|
-
const override = getActiveOverride(key, cartContent, config);
|
|
26
|
+
const override = getActiveOverride(key, cartContent, config, forcedEsfOverride);
|
|
27
27
|
const currentWeight = override?.rules?.[uuid]?.weight || 0;
|
|
28
28
|
const inCart = cartContent.items[key] || 0;
|
|
29
29
|
return acc + currentWeight * inCart;
|
|
30
30
|
}, 0);
|
|
31
31
|
const isHidden = Object.keys(config).some((key) => {
|
|
32
|
-
const override = getActiveOverride(key, cartContent, config);
|
|
32
|
+
const override = getActiveOverride(key, cartContent, config, forcedEsfOverride);
|
|
33
33
|
const isHidden = override?.rules?.[uuid]?.hidden || false;
|
|
34
34
|
const inCart = cartContent.items[key] || 0;
|
|
35
35
|
return inCart ? isHidden : false;
|
|
@@ -40,32 +40,34 @@ export function getSortedOffers(container, cartContent, config) {
|
|
|
40
40
|
const sortedOffers = filteredOffers.sort((a, b) => b.weight - a.weight);
|
|
41
41
|
return sortedOffers;
|
|
42
42
|
}
|
|
43
|
-
export function getActiveOverride(key, cartContent, config) {
|
|
43
|
+
export function getActiveOverride(key, cartContent, config, forcedEsfOverride) {
|
|
44
44
|
const { items } = cartContent;
|
|
45
45
|
const amountInCart = items[key];
|
|
46
46
|
const item = config[key];
|
|
47
47
|
if (!amountInCart)
|
|
48
48
|
return item?.default;
|
|
49
|
-
const matchingOverrides = getMatchingOverrides(item, cartContent);
|
|
49
|
+
const matchingOverrides = getMatchingOverrides(item, cartContent, forcedEsfOverride);
|
|
50
50
|
const activeOverride = matchingOverrides.length > 0
|
|
51
51
|
? item?.overrides.find((o) => o.id === matchingOverrides[0])
|
|
52
52
|
: item?.default || {};
|
|
53
53
|
return activeOverride;
|
|
54
54
|
}
|
|
55
|
-
function getMatchingOverrides(item, cartContent) {
|
|
55
|
+
function getMatchingOverrides(item, cartContent, forcedEsfOverride) {
|
|
56
56
|
if (!item)
|
|
57
57
|
return [];
|
|
58
58
|
const { overrides = [] } = item;
|
|
59
59
|
const matchs = overrides.reduce((acc, override) => {
|
|
60
|
-
const { stay, merchants, skiPassDurations = [], durationTags, } = cartContent;
|
|
60
|
+
const { stay, merchants, skiPassDurations = [], durationTags, esfOffersContent, } = cartContent;
|
|
61
61
|
const isStayMatching = checkStay(override, stay);
|
|
62
62
|
const isMerchantMatching = checkMerchants(override, merchants);
|
|
63
63
|
const isSkiPassDurationMatching = checkSkiPassDurations(override, skiPassDurations);
|
|
64
64
|
const isDurationTagMatching = checkDurationTags(override, durationTags);
|
|
65
|
+
const isEsfProductMatching = checkEsfProduct(override, esfOffersContent, forcedEsfOverride);
|
|
65
66
|
const isMatching = isStayMatching ||
|
|
66
67
|
isMerchantMatching ||
|
|
67
68
|
isSkiPassDurationMatching ||
|
|
68
|
-
isDurationTagMatching
|
|
69
|
+
isDurationTagMatching ||
|
|
70
|
+
isEsfProductMatching;
|
|
69
71
|
return isMatching ? [...acc, override.id] : acc;
|
|
70
72
|
}, []);
|
|
71
73
|
return matchs;
|
|
@@ -94,7 +96,8 @@ function checkMerchants(override, merchants) {
|
|
|
94
96
|
function checkSkiPassDurations(override, skiPassDurations) {
|
|
95
97
|
if (!skiPassDurations)
|
|
96
98
|
return false;
|
|
97
|
-
const
|
|
99
|
+
const durations = skiPassDurations.map(Number);
|
|
100
|
+
const maxDuration = Math.max(...durations);
|
|
98
101
|
const { skiPassDuration, skiPassDurationOperator = ">=" } = override.triggers || {};
|
|
99
102
|
if (!skiPassDuration)
|
|
100
103
|
return false;
|
|
@@ -121,7 +124,25 @@ function checkDurationTags(override, durationTags) {
|
|
|
121
124
|
return false;
|
|
122
125
|
return durationTags.includes(durationTag);
|
|
123
126
|
}
|
|
124
|
-
|
|
127
|
+
function checkEsfProduct(override, esfOffersContent, forcedEsfOverride) {
|
|
128
|
+
if (!esfOffersContent)
|
|
129
|
+
return false;
|
|
130
|
+
if (forcedEsfOverride) {
|
|
131
|
+
return override.name === forcedEsfOverride;
|
|
132
|
+
}
|
|
133
|
+
const rules = override.triggers?.esf?.rules;
|
|
134
|
+
if (!rules)
|
|
135
|
+
return false;
|
|
136
|
+
return esfOffersContent.some((content) => {
|
|
137
|
+
const keys = Object.keys(content);
|
|
138
|
+
return keys.some((key) => {
|
|
139
|
+
return content[key]?.some((value) => {
|
|
140
|
+
return rules[key].includes(value);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
export const allowedOverrides = ["HOT", "LIFT", "SKI_RENTAL", "STAND", "ESF"];
|
|
125
146
|
export function hasAllowedOverrides(kind) {
|
|
126
147
|
return allowedOverrides.includes(kind);
|
|
127
148
|
}
|
|
@@ -187,9 +208,28 @@ export async function getDurationTagsFromCart(cart) {
|
|
|
187
208
|
const uniqueTags = tags?.length > 0 ? [...new Set(tags)] : [];
|
|
188
209
|
return uniqueTags;
|
|
189
210
|
}
|
|
211
|
+
export function getEsfOffersFromCart(cart) {
|
|
212
|
+
const { ESF: items } = cart.orders;
|
|
213
|
+
if (!items?.length)
|
|
214
|
+
return [];
|
|
215
|
+
return items.reduce((acc, item) => {
|
|
216
|
+
const { inscriptions } = item;
|
|
217
|
+
const offers = inscriptions
|
|
218
|
+
.map((inscription) => inscription?.codes)
|
|
219
|
+
.filter(Boolean);
|
|
220
|
+
return [...acc, ...offers];
|
|
221
|
+
}, []);
|
|
222
|
+
}
|
|
190
223
|
export const CONFIG_ID = "cross-selling-editor";
|
|
191
224
|
export function getConfig(container) {
|
|
192
225
|
const config = container?.querySelector(`#${CONFIG_ID}`);
|
|
193
226
|
const json = JSON.parse(config?.textContent || "{}");
|
|
194
227
|
return json;
|
|
195
228
|
}
|
|
229
|
+
export function getIntervalLengthFromDates(from, to) {
|
|
230
|
+
const stayFrom = new Date(from).getTime();
|
|
231
|
+
const stayTo = new Date(to).getTime();
|
|
232
|
+
const diffTime = Math.abs(stayTo - stayFrom);
|
|
233
|
+
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
|
234
|
+
return diffDays;
|
|
235
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/cross-selling-editor/tester/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Config, Durations } from "../types";
|
|
2
|
+
type Props = {
|
|
3
|
+
container: HTMLElement;
|
|
4
|
+
config: Config;
|
|
5
|
+
durations?: Durations;
|
|
6
|
+
tunnelOffersOrder?: string[];
|
|
7
|
+
displayedTunnelOffers?: string[];
|
|
8
|
+
};
|
|
9
|
+
export default function Tester({ container, config, durations, tunnelOffersOrder, displayedTunnelOffers, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=tester.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tester.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/cross-selling-editor/tester/tester.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAoB,MAAM,UAAU,CAAC;AAEpE,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC7B,SAAS,EACT,MAAM,EACN,SAAS,EACT,iBAAiB,EACjB,qBAAqB,GACtB,EAAE,KAAK,2CAkPP"}
|