ublo-lib 1.45.2 → 1.45.4
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/esf/components/magic-box/booking.js +1 -1
- package/es/esf/components/magic-box/magic-box.d.ts +3 -3
- package/es/esf/components/magic-box/magic-box.d.ts.map +1 -1
- package/es/esf/components/magic-box/magic-box.js +30 -17
- package/es/esf/components/magic-box/magic-box.module.css +3 -2
- package/es/esf/components/magic-box/messages.d.ts.map +1 -1
- package/es/esf/components/magic-box/messages.js +4 -0
- package/es/esf/components/magic-box/services/api.d.ts.map +1 -1
- package/es/esf/components/magic-box/services/api.js +9 -8
- package/es/future/hooks/use-msem-presets.d.ts +16 -3
- package/es/future/hooks/use-msem-presets.d.ts.map +1 -1
- package/es/future/hooks/use-msem-presets.js +24 -4
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import Button from "dt-design-system/es/button";
|
|
|
5
5
|
import * as Icons from "dt-design-system/es/icons";
|
|
6
6
|
import { message } from "./messages";
|
|
7
7
|
import { loadWidgetMseM } from "./services/widgets";
|
|
8
|
-
import * as Plausible from "../../../
|
|
8
|
+
import * as Plausible from "../../../future/components/plausible";
|
|
9
9
|
import css from "./booking.module.css";
|
|
10
10
|
const Booking = ({ stay, cartUrl, channel, values, maxCPDuration, setCurrentStep, msemWidgetHost, }) => {
|
|
11
11
|
const { lang, cmsMode, config } = useUbloContext();
|
|
@@ -3,9 +3,9 @@ type Stay = {
|
|
|
3
3
|
from: string;
|
|
4
4
|
to: string;
|
|
5
5
|
};
|
|
6
|
-
type MseMWidgetHost = "https://widget.msem.tech" | "https://widget-integration.msem.tech";
|
|
7
|
-
type MseMApiHost = "https://services.msem.tech/api/esf" | "https://services-integration.msem.tech/api/esf";
|
|
8
|
-
type MseMAdminHost = "https://admin.mon-sejour-en-montagne.com/api/gesco" | "https://admin-integration.mon-sejour-en-montagne.com/api/gesco";
|
|
6
|
+
type MseMWidgetHost = "https://widget.msem.tech" | "https://widget-integration.msem.tech" | "https://widget-uat.msem.tech";
|
|
7
|
+
type MseMApiHost = "https://services.msem.tech/api/esf" | "https://services-integration.msem.tech/api/esf" | "https://services-uat.msem.tech/api/esf";
|
|
8
|
+
type MseMAdminHost = "https://admin.mon-sejour-en-montagne.com/api/gesco" | "https://admin-integration.mon-sejour-en-montagne.com/api/gesco" | "https://admin-uat.mon-sejour-en-montagne.com/api/gesco";
|
|
9
9
|
type Props = {
|
|
10
10
|
stay?: Stay;
|
|
11
11
|
cartUrl: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"magic-box.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/magic-box/magic-box.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"magic-box.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/magic-box/magic-box.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,KAAK,cAAc,GACf,0BAA0B,GAC1B,sCAAsC,GACtC,8BAA8B,CAAC;AACnC,KAAK,WAAW,GACZ,oCAAoC,GACpC,gDAAgD,GAChD,wCAAwC,CAAC;AAC7C,KAAK,aAAa,GACd,oDAAoD,GACpD,gEAAgE,GAChE,wDAAwD,CAAC;AAE7D,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,CAAC,EAAE;QACb,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,kBAAkB,EAAE,OAAO,CAAC;KAC7B,CAAC;CACH,CAAC;;AAIF,wBAAoC;AAEpC,iBAAS,QAAQ,CAAC,EAChB,IAAI,EACJ,OAAO,EACP,OAAe,EACf,SAAS,EACT,YAAY,EACZ,aAAa,EACb,OAAW,EACX,OAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,cAA2C,EAC3C,WAAkD,EAClD,aAAoE,EACpE,YAAY,EACZ,QAAQ,GACT,EAAE,KAAK,2CA4NP"}
|
|
@@ -4,6 +4,7 @@ import classNames from "classnames";
|
|
|
4
4
|
import Router from "next/router";
|
|
5
5
|
import { useUbloContext } from "ublo/with-ublo";
|
|
6
6
|
import Button from "dt-design-system/es/button";
|
|
7
|
+
import Information from "dt-design-system/es/information";
|
|
7
8
|
import * as Icons from "dt-design-system/es/icons";
|
|
8
9
|
import Filters from "./filters";
|
|
9
10
|
import Booking from "./booking";
|
|
@@ -15,7 +16,8 @@ function MagicBox({ stay, cartUrl, channel = "ESF", className, alignContent, max
|
|
|
15
16
|
const [filters, setFilters] = React.useState();
|
|
16
17
|
const [values, setValues] = React.useState();
|
|
17
18
|
const [currentStep, setCurrentStep] = React.useState(0);
|
|
18
|
-
const [VELClosed] = React.useState(false);
|
|
19
|
+
const [VELClosed, setVELClosed] = React.useState(false);
|
|
20
|
+
const [jmoins, setJmoins] = React.useState();
|
|
19
21
|
const [customSubmitChecked, setCustomSubmitChecked] = React.useState(false);
|
|
20
22
|
const { lang: ubloLang, config } = useUbloContext();
|
|
21
23
|
const { resort, merchant } = config;
|
|
@@ -47,19 +49,20 @@ function MagicBox({ stay, cartUrl, channel = "ESF", className, alignContent, max
|
|
|
47
49
|
};
|
|
48
50
|
const refreshFilters = React.useCallback(async () => {
|
|
49
51
|
if (stay) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
try {
|
|
53
|
+
setFilters([]);
|
|
54
|
+
const { from: stayFrom, to: stayTo } = stay;
|
|
55
|
+
const [welcomeResult, paramsResult] = await Promise.all([
|
|
56
|
+
API.fetchWelcome({
|
|
57
|
+
msemApiHost,
|
|
58
|
+
lang,
|
|
59
|
+
resort,
|
|
60
|
+
stayFrom,
|
|
61
|
+
stayTo,
|
|
62
|
+
}),
|
|
63
|
+
API.fetchParams(msemAdminHost, lang, resort, merchant, channel, categories),
|
|
64
|
+
]);
|
|
65
|
+
const { season: currentSeason, availableSeasons } = welcomeResult;
|
|
63
66
|
const { categories: categoryList } = paramsResult;
|
|
64
67
|
const season = currentSeason || availableSeasons[0] || "2025";
|
|
65
68
|
const filtersResult = await API.fetchFilters({
|
|
@@ -71,8 +74,9 @@ function MagicBox({ stay, cartUrl, channel = "ESF", className, alignContent, max
|
|
|
71
74
|
stayFrom,
|
|
72
75
|
stayTo,
|
|
73
76
|
});
|
|
74
|
-
const
|
|
75
|
-
|
|
77
|
+
const { filters = {}, cpInactive, jmoins } = filtersResult;
|
|
78
|
+
const newFilters = Object.keys(filters).reduce((acc, key) => {
|
|
79
|
+
const filter = filters[key];
|
|
76
80
|
if (key === "days") {
|
|
77
81
|
const days = filter.filter((item) => {
|
|
78
82
|
return (!item.restricted &&
|
|
@@ -101,6 +105,15 @@ function MagicBox({ stay, cartUrl, channel = "ESF", className, alignContent, max
|
|
|
101
105
|
? { ...newFilters, categories: formattedCategories }
|
|
102
106
|
: newFilters;
|
|
103
107
|
setFilters(allFilters);
|
|
108
|
+
setVELClosed(cpInactive);
|
|
109
|
+
const jmoinsValue = Object.keys(filters).length > 0 && jmoins !== 0 ? undefined : jmoins;
|
|
110
|
+
setJmoins(jmoinsValue);
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
console.error(e);
|
|
114
|
+
setFilters([]);
|
|
115
|
+
setVELClosed(true);
|
|
116
|
+
setJmoins(undefined);
|
|
104
117
|
}
|
|
105
118
|
}
|
|
106
119
|
}, [
|
|
@@ -131,7 +144,7 @@ function MagicBox({ stay, cartUrl, channel = "ESF", className, alignContent, max
|
|
|
131
144
|
const showFilter = stay && filters && values;
|
|
132
145
|
const SubmitIcon = customSubmitChecked ? Icons.ArrowRight : Icons.Search;
|
|
133
146
|
const classes = classNames(css.root, className);
|
|
134
|
-
return (_jsx("div", { className: classes, "data-align": alignContent, children: _jsxs("div", { className: css.top, children: [children, VELClosed && (_jsx("
|
|
147
|
+
return (_jsx("div", { className: classes, "data-align": alignContent, children: _jsxs("div", { className: css.top, children: [children, VELClosed && !jmoins && (_jsx(Information, { type: "error", className: css.errorMessage, children: message(lang, "vel-closed") })), jmoins && (_jsxs(Information, { type: "warning", className: css.errorMessage, children: [message(lang, "booking-block-day-minus-start"), " ", jmoins, message(lang, "booking-block-day-minus-end")] })), !VELClosed && currentStep === 0 && (_jsxs(_Fragment, { children: [!filters && _jsx("div", { className: css.loader }), showFilter && (_jsx(Filters, { filters: filters, values: values, setValues: setValues, customSubmit: customSubmit, customSubmitChecked: customSubmitChecked, setCustomSubmitChecked: setCustomSubmitChecked }))] })), _jsxs(Button, { className: css.confirm, onClick: submit, disabled: VELClosed || !isValid, children: [message(lang, customSubmitChecked ? "proceed" : "confirm"), _jsx(SubmitIcon, {})] }), currentStep === 1 && (_jsx(Booking, { stay: stay, cartUrl: cartUrl, channel: channel, values: values, maxCPDuration: maxCPDuration, setCurrentStep: setCurrentStep, msemWidgetHost: msemWidgetHost }))] }) }));
|
|
135
148
|
}
|
|
136
149
|
function getDefaultValues(filters) {
|
|
137
150
|
return Object.keys(filters || {}).reduce((acc, key) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/magic-box/messages.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/magic-box/messages.js"],"names":[],"mappings":"AAmCO,iDAIN"}
|
|
@@ -11,6 +11,8 @@ const locales = {
|
|
|
11
11
|
categories: " à ",
|
|
12
12
|
"vel-closed": "La vente en ligne est fermée pour le moment.",
|
|
13
13
|
proceed: "Finaliser ma demande",
|
|
14
|
+
"booking-block-day-minus-start": "La réservation des cours privés est possible uniquement à plus de ",
|
|
15
|
+
"booking-block-day-minus-end": " jours de la date de début de cours souhaitée.",
|
|
14
16
|
},
|
|
15
17
|
en: {
|
|
16
18
|
confirm: "Find an instructor",
|
|
@@ -24,6 +26,8 @@ const locales = {
|
|
|
24
26
|
categories: " at ",
|
|
25
27
|
"vel-closed": "Online sales are closed for now.",
|
|
26
28
|
proceed: "Finalize my request",
|
|
29
|
+
"booking-block-day-minus-start": "Booking requests are closed ",
|
|
30
|
+
"booking-block-day-minus-end": " days before the start of the lesson.",
|
|
27
31
|
},
|
|
28
32
|
};
|
|
29
33
|
export const message = (lang, id) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../src/esf/components/magic-box/services/api.js"],"names":[],"mappings":"AAGA;;;;;;iBAOC;AAED;;;;;;;;;;iBAqBC;AAED,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../src/esf/components/magic-box/services/api.js"],"names":[],"mappings":"AAGA;;;;;;iBAOC;AAED;;;;;;;;;;iBAqBC;AAED,oIAeC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { POST } from "../../../../future/utils/fetcher";
|
|
2
2
|
export function fetchWelcome({ msemApiHost, lang, resort, stayFrom, stayTo }) {
|
|
3
|
-
return
|
|
3
|
+
return POST(`${msemApiHost}/welcome`, {
|
|
4
4
|
resort,
|
|
5
5
|
lang,
|
|
6
6
|
stayFrom,
|
|
@@ -8,7 +8,7 @@ export function fetchWelcome({ msemApiHost, lang, resort, stayFrom, stayTo }) {
|
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
export async function fetchFilters({ msemApiHost, channel, lang, resort, season, stayFrom, stayTo, kinds = ["CP"], engagement = true, }) {
|
|
11
|
-
return
|
|
11
|
+
return POST(`${msemApiHost}/filters`, {
|
|
12
12
|
channel,
|
|
13
13
|
lang,
|
|
14
14
|
resort,
|
|
@@ -20,10 +20,11 @@ export async function fetchFilters({ msemApiHost, channel, lang, resort, season,
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
export async function fetchParams(msemAdminHost, lang, resort, merchant, channel, categories) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
return POST(`${msemAdminHost}/contact/parameters`, {
|
|
24
|
+
lang,
|
|
25
|
+
resort,
|
|
26
|
+
merchant,
|
|
27
|
+
channel,
|
|
28
|
+
categories,
|
|
27
29
|
});
|
|
28
|
-
return res.json();
|
|
29
30
|
}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
type Preset = {
|
|
2
|
+
widget: string;
|
|
3
|
+
options: Record<string, any>;
|
|
4
|
+
presets: Record<string, any>;
|
|
5
|
+
};
|
|
6
|
+
type Props = {
|
|
7
|
+
defaultOptions: Record<string, any> & {
|
|
8
|
+
prefixes: Record<string, string>;
|
|
9
|
+
};
|
|
10
|
+
callbacks: {
|
|
11
|
+
beforeLaunch: (preset: Preset) => void;
|
|
12
|
+
afterLaunch: (preset: Preset) => void;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default function useMseMPresets({ defaultOptions, callbacks }: Props): void;
|
|
16
|
+
export {};
|
|
4
17
|
//# sourceMappingURL=use-msem-presets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-msem-presets.d.ts","sourceRoot":"","sources":["../../../src/future/hooks/use-msem-presets.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,cAAc,EAAE
|
|
1
|
+
{"version":3,"file":"use-msem-presets.d.ts","sourceRoot":"","sources":["../../../src/future/hooks/use-msem-presets.ts"],"names":[],"mappings":"AAYA,KAAK,MAAM,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QACpC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,CAAC;IACF,SAAS,EAAE;QAET,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;QAEvC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;KACvC,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE,KAAK,QAsI1E"}
|
|
@@ -5,7 +5,7 @@ import * as MseM from "../components/msem";
|
|
|
5
5
|
import * as Cms from "../../common/utils/cms";
|
|
6
6
|
const PRESET_ATTRIBUTE = "data-msem-preset";
|
|
7
7
|
const PRESET_PLACEHOLDER_ATTRIBUTE = "data-msem-placeholder";
|
|
8
|
-
export default function useMseMPresets({ defaultOptions }) {
|
|
8
|
+
export default function useMseMPresets({ defaultOptions, callbacks }) {
|
|
9
9
|
const { lang, cmsMode, path } = useUbloContext();
|
|
10
10
|
const isEnabled = cmsMode !== "editing" && cmsMode !== "info";
|
|
11
11
|
const handleSectionClick = React.useCallback((e) => {
|
|
@@ -15,7 +15,7 @@ export default function useMseMPresets({ defaultOptions }) {
|
|
|
15
15
|
const preset = section?.getAttribute(PRESET_ATTRIBUTE);
|
|
16
16
|
if (!preset)
|
|
17
17
|
return;
|
|
18
|
-
const { widget, options = {}, presets, groundedTo
|
|
18
|
+
const { widget, options = {}, presets, groundedTo } = JSON.parse(preset);
|
|
19
19
|
if (groundedTo)
|
|
20
20
|
return;
|
|
21
21
|
const { prefixes = {}, ...otherDefaultOptions } = defaultOptions;
|
|
@@ -35,8 +35,14 @@ export default function useMseMPresets({ defaultOptions }) {
|
|
|
35
35
|
window.open(endpoint, "_blank");
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
+
if (typeof callbacks?.beforeLaunch === "function") {
|
|
39
|
+
callbacks.beforeLaunch({ widget, options: allOptions, presets });
|
|
40
|
+
}
|
|
38
41
|
MseM.loadWidget(widget, allOptions, presets);
|
|
39
|
-
|
|
42
|
+
if (typeof callbacks?.afterLaunch === "function") {
|
|
43
|
+
callbacks.afterLaunch({ widget, options: allOptions, presets });
|
|
44
|
+
}
|
|
45
|
+
}, [callbacks, defaultOptions, lang]);
|
|
40
46
|
React.useEffect(() => {
|
|
41
47
|
if (isEnabled) {
|
|
42
48
|
document.body.addEventListener("click", handleSectionClick);
|
|
@@ -84,8 +90,22 @@ export default function useMseMPresets({ defaultOptions }) {
|
|
|
84
90
|
...urlPresets,
|
|
85
91
|
};
|
|
86
92
|
placeholder.setAttribute("id", uniqueId);
|
|
93
|
+
if (typeof callbacks?.beforeLaunch === "function") {
|
|
94
|
+
callbacks.beforeLaunch({
|
|
95
|
+
widget,
|
|
96
|
+
options: allOptions,
|
|
97
|
+
presets: allPresets,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
87
100
|
MseM.loadWidget(widget, allOptions, allPresets);
|
|
101
|
+
if (typeof callbacks?.afterLaunch === "function") {
|
|
102
|
+
callbacks.afterLaunch({
|
|
103
|
+
widget,
|
|
104
|
+
options: allOptions,
|
|
105
|
+
presets: allPresets,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
88
108
|
});
|
|
89
109
|
}
|
|
90
|
-
}, [defaultOptions, lang]);
|
|
110
|
+
}, [callbacks, defaultOptions, lang]);
|
|
91
111
|
}
|