ublo-lib 1.16.2 → 1.16.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.
@@ -20,17 +20,32 @@ const fetcher = async (url, body) => {
20
20
  return res.json();
21
21
  };
22
22
  export async function fetchInstructors(lang, body = {}) {
23
- return fetcher(`${host}/api/instructors-book/${resort}/${lang}`, {
24
- ...body,
25
- project: true
26
- });
23
+ try {
24
+ return fetcher(`${host}/api/instructors-book/${resort}/${lang}`, {
25
+ ...body,
26
+ project: true
27
+ });
28
+ } catch (e) {
29
+ console.warn(e);
30
+ return [];
31
+ }
27
32
  }
28
33
  export async function fetchInstructor(lang, uri) {
29
- return fetcher(`${host}/api/instructors-book/${resort}/${lang}/${uri}`);
34
+ try {
35
+ return fetcher(`${host}/api/instructors-book/${resort}/${lang}/${uri}`);
36
+ } catch (e) {
37
+ console.warn(e);
38
+ return {};
39
+ }
30
40
  }
31
41
  export const fetchRandomInstructors = async (lang, tags, nbInstructor) => {
32
- return fetcher(`${host}/api/instructors-book/${resort}/${lang}/byTags`, {
33
- tags,
34
- size: nbInstructor
35
- });
42
+ try {
43
+ return fetcher(`${host}/api/instructors-book/${resort}/${lang}/byTags`, {
44
+ tags,
45
+ size: nbInstructor
46
+ });
47
+ } catch (e) {
48
+ console.warn(e);
49
+ return [];
50
+ }
36
51
  };
@@ -1 +1 @@
1
- {"version":3,"file":"parcours-esf.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/parcours-esf/parcours-esf.tsx"],"names":[],"mappings":";AAMA,aAAK,KAAK,GAAG;IACX,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC3C,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAIF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,QAAQ,EACR,WAAgB,EAChB,YAAiB,EACjB,aAAkB,GACnB,EAAE,KAAK,eAmCP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,WAAW,EAAE,GAAG,CAAC;KAClB;CACF"}
1
+ {"version":3,"file":"parcours-esf.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/parcours-esf/parcours-esf.tsx"],"names":[],"mappings":";AAOA,aAAK,KAAK,GAAG;IACX,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC3C,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAIF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,QAAQ,EACR,WAAgB,EAChB,YAAiB,EACjB,aAAkB,GACnB,EAAE,KAAK,eA4CP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,WAAW,EAAE,GAAG,CAAC;KAClB;CACF"}
@@ -1,27 +1,36 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import { useUbloContext } from "ublo/with-ublo";
3
+ import Router from "next/router";
4
+ // import { useUbloContext } from "ublo/with-ublo";
4
5
  import Script from "next/script";
5
6
  import Loader from "dt-design-system/es/loader";
6
7
  import css from "./parcours-esf.module.css";
7
8
  const ID = "parcours-esf";
8
9
  export default function ParcoursEsf({ parcours, constraints = [], noeudsExclus = [], niveauxExclus = [], }) {
9
- const { lang } = useUbloContext();
10
+ // const { lang } = useUbloContext();
10
11
  const [loaded, setLoaded] = React.useState(false);
11
12
  // const parcoursLang = lang === "fr" ? "fr" : "en";
12
13
  const parcoursLang = "fr"; // seul le fr est pris en charge pour le moment
13
- const startParcours = () => {
14
+ const loadParcours = () => {
14
15
  window.EsfParcours.onLoad(() => {
15
16
  setLoaded(true);
16
- window.EsfParcours.start({
17
- groundedTo: `#${ID}`,
18
- lang: parcoursLang,
19
- parcours,
20
- constraints,
21
- noeudsExclus,
22
- niveauxExclus,
23
- });
17
+ startParcours();
24
18
  });
25
19
  };
26
- return (_jsxs(_Fragment, { children: [!loaded && (_jsx("div", { className: css.loader, children: _jsx(Loader, {}) })), _jsx("div", { id: ID, className: css.parcours }), _jsx(Script, { src: "https://parcours-esf.msem.tech/static/js/widget-esf-parcours.js", onLoad: startParcours })] }));
20
+ const startParcours = () => {
21
+ window.EsfParcours.start({
22
+ groundedTo: `#${ID}`,
23
+ lang: parcoursLang,
24
+ parcours,
25
+ constraints,
26
+ noeudsExclus,
27
+ niveauxExclus,
28
+ });
29
+ };
30
+ Router.ready(() => {
31
+ Router.events.on("routeChangeComplete", () => {
32
+ startParcours();
33
+ });
34
+ });
35
+ return (_jsxs(_Fragment, { children: [!loaded && (_jsx("div", { className: css.loader, children: _jsx(Loader, {}) })), _jsx("div", { id: ID, className: css.parcours }), _jsx(Script, { src: "https://parcours-esf.msem.tech/static/js/widget-esf-parcours.js", onLoad: loadParcours })] }));
27
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.16.2",
3
+ "version": "1.16.4",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^2.9.0",
6
6
  "leaflet": "^1.9.1",