ublo-lib 1.50.11 → 1.50.13
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart-transfer.d.ts","sourceRoot":"","sources":["../../../src/common/components/cart-transfer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cart-transfer.d.ts","sourceRoot":"","sources":["../../../src/common/components/cart-transfer.tsx"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,UAAU,YAAY,QAYnC"}
|
|
@@ -1,45 +1,71 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import getConfig from "next/config";
|
|
3
|
-
const
|
|
3
|
+
const PARAM = "msemSession";
|
|
4
|
+
const KEYS = ["cartId", "cartIds", "resort", "stay", "paxplan"];
|
|
5
|
+
const { domains = {} } = getConfig().publicRuntimeConfig;
|
|
6
|
+
const hosts = Object.values(domains).filter(Boolean);
|
|
7
|
+
if (typeof window !== "undefined" && hosts.length > 1)
|
|
8
|
+
receiveSession();
|
|
4
9
|
export default function CartTransfer() {
|
|
5
10
|
React.useEffect(() => {
|
|
6
|
-
const { domains } = getConfig()?.publicRuntimeConfig ?? {};
|
|
7
|
-
const hosts = Object.values(domains ?? {}).filter(Boolean);
|
|
8
11
|
if (hosts.length < 2)
|
|
9
12
|
return;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const a = e.target?.closest?.("a[href]");
|
|
13
|
-
if (!a || a.host === location.host || !hosts.includes(a.host))
|
|
14
|
-
return;
|
|
15
|
-
try {
|
|
16
|
-
const storedCartId = window.sessionStorage.getItem(STORAGE_KEY);
|
|
17
|
-
if (!storedCartId)
|
|
18
|
-
return;
|
|
19
|
-
const url = new URL(a.href);
|
|
20
|
-
url.searchParams.set(STORAGE_KEY, String(JSON.parse(storedCartId)));
|
|
21
|
-
a.href = url.toString();
|
|
22
|
-
}
|
|
23
|
-
catch (e) { }
|
|
24
|
-
};
|
|
25
|
-
document.addEventListener("click", addCartId, true);
|
|
26
|
-
document.addEventListener("auxclick", addCartId, true);
|
|
13
|
+
document.addEventListener("click", onLinkClick, true);
|
|
14
|
+
document.addEventListener("auxclick", onLinkClick, true);
|
|
27
15
|
return () => {
|
|
28
|
-
document.removeEventListener("click",
|
|
29
|
-
document.removeEventListener("auxclick",
|
|
16
|
+
document.removeEventListener("click", onLinkClick, true);
|
|
17
|
+
document.removeEventListener("auxclick", onLinkClick, true);
|
|
30
18
|
};
|
|
31
19
|
}, []);
|
|
32
20
|
return null;
|
|
33
21
|
}
|
|
34
|
-
function
|
|
22
|
+
function onLinkClick(e) {
|
|
23
|
+
const link = e.target.closest("a[href]");
|
|
24
|
+
if (e.defaultPrevented || !link || !isOtherLangLink(link))
|
|
25
|
+
return;
|
|
26
|
+
if (!sessionStorage.getItem("cartId"))
|
|
27
|
+
return;
|
|
28
|
+
const url = new URL(link.href);
|
|
29
|
+
url.searchParams.set(PARAM, JSON.stringify(readSession()));
|
|
30
|
+
if (isPlainClick(e, link)) {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
location.assign(url);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
link.href = url.toString();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function readSession() {
|
|
39
|
+
const session = {};
|
|
40
|
+
for (const key of KEYS) {
|
|
41
|
+
const value = sessionStorage.getItem(key);
|
|
42
|
+
if (value)
|
|
43
|
+
session[key] = JSON.parse(value);
|
|
44
|
+
}
|
|
45
|
+
return session;
|
|
46
|
+
}
|
|
47
|
+
function receiveSession() {
|
|
35
48
|
try {
|
|
36
|
-
const url = new URL(
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
49
|
+
const url = new URL(location.href);
|
|
50
|
+
const param = url.searchParams.get(PARAM);
|
|
51
|
+
if (!param)
|
|
39
52
|
return;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
const session = JSON.parse(param);
|
|
54
|
+
for (const key of KEYS) {
|
|
55
|
+
if (key in session) {
|
|
56
|
+
sessionStorage.setItem(key, JSON.stringify(session[key]));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
url.searchParams.delete(PARAM);
|
|
60
|
+
history.replaceState(history.state, "", url);
|
|
43
61
|
}
|
|
44
|
-
catch
|
|
62
|
+
catch { }
|
|
63
|
+
}
|
|
64
|
+
function isOtherLangLink(link) {
|
|
65
|
+
return link.host !== location.host && hosts.includes(link.host);
|
|
66
|
+
}
|
|
67
|
+
function isPlainClick(e, link) {
|
|
68
|
+
const modified = e.metaKey || e.ctrlKey || e.shiftKey || e.altKey;
|
|
69
|
+
const sameTab = !link.target || link.target === "_self";
|
|
70
|
+
return e.type === "click" && e.button === 0 && !modified && sameTab;
|
|
45
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitment-banner.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/commitment-banner/commitment-banner.tsx"],"names":[],"mappings":"AAQA,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,IAAI,EACJ,IAAc,EACd,SAAS,GACV,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"commitment-banner.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/commitment-banner/commitment-banner.tsx"],"names":[],"mappings":"AAQA,KAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,IAAI,EACJ,IAAc,EACd,SAAS,GACV,EAAE,KAAK,2CAuCP"}
|
|
@@ -7,7 +7,8 @@ import styles from "./commitment-banner.module.css";
|
|
|
7
7
|
import EsfLogo from "./esf-logo";
|
|
8
8
|
import FranceMontagneLogo from "./france-montagne-logo";
|
|
9
9
|
export default function CommitmentBanner({ lang, mode = "light", className, }) {
|
|
10
|
-
|
|
10
|
+
if (!lang || lang !== "fr")
|
|
11
|
+
return null;
|
|
11
12
|
const classes = classNames(styles.banner, className, {
|
|
12
13
|
[styles.dark]: mode === "dark",
|
|
13
14
|
});
|