ublo-lib 1.21.3 → 1.21.5

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.
@@ -7,18 +7,27 @@ const {
7
7
  } = publicRuntimeConfig;
8
8
  const carnetRougeApi = "https://services.carnet-rouge-esf.app/api";
9
9
  const authorizationCarnetRouge = "6bdecf9053927dcc7e10923a2cc603a4";
10
- const fetcher = async (url, body) => {
11
- const res = await fetch(url, {
12
- method: "POST",
13
- headers: {
14
- ...(body ? {
15
- "content-type": "application/json;charset=utf-8"
16
- } : {}),
17
- Authorization: authorizationCarnetRouge
18
- },
19
- body: body ? JSON.stringify(body) : undefined
20
- });
21
- return res.json();
10
+ const fetcher = async (url, body, retries = 5) => {
11
+ try {
12
+ const res = await fetch(url, {
13
+ method: "POST",
14
+ headers: {
15
+ ...(body ? {
16
+ "content-type": "application/json;charset=utf-8"
17
+ } : {}),
18
+ Authorization: authorizationCarnetRouge
19
+ },
20
+ body: body ? JSON.stringify(body) : undefined
21
+ });
22
+ return res.json();
23
+ } catch (e) {
24
+ if (retries > 0) {
25
+ const plural = retries > 1 ? "s" : "";
26
+ console.warn(`Warning: failed to fetch instructor book ressource "${url}", retrying ${retries} time${plural}...}`);
27
+ return fetcher(url, body, retries - 1);
28
+ }
29
+ throw e;
30
+ }
22
31
  };
23
32
  export async function fetchInstructors(lang, body = {}) {
24
33
  try {
@@ -1,3 +1,9 @@
1
1
  .lumiplan {
2
- padding: 64px 0;
2
+ padding: 28px 0;
3
+ }
4
+
5
+ @media (min-width: 780px) {
6
+ .lumiplan {
7
+ padding: 64px 0;
8
+ }
3
9
  }
@@ -17,7 +17,7 @@ const Opening = React.forwardRef(({ resortOpening }, ref) => {
17
17
  return null;
18
18
  }
19
19
  const { dawnSkiingDays, nightSkiingDays } = resortOpening.availability;
20
- return (_jsxs("div", { ref: ref, className: css.opening, "data-tags": t(lang, "opening.navigation-title"), children: [_jsx("div", { className: css.title, dangerouslySetInnerHTML: { __html: t(lang, "opening.title") } }), _jsx("div", { className: css.tableOuter, children: _jsxs("table", { className: css.table, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", {}), dawnSkiingDays.map((day) => (_jsx("th", { className: css.heading, children: _jsx("div", { className: css.headingInner, children: _jsx(T, { id: `opening.days.${day.dayType}` }) }) }, day.dayType)))] }) }), _jsxs("tbody", { children: [_jsx("tr", { children: _jsx(Rows, { kind: "dawn", rows: dawnSkiingDays }) }), _jsx("tr", { children: _jsx(Rows, { kind: "night", rows: nightSkiingDays }) })] })] }) })] }));
20
+ return (_jsx("div", { ref: ref, className: css.opening, "data-tags": t(lang, "opening.navigation-title"), children: _jsx("div", { className: css.tableOuter, children: _jsxs("table", { className: css.table, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", {}), dawnSkiingDays.map((day) => (_jsx("th", { className: css.heading, children: _jsx("div", { className: css.headingInner, children: _jsx(T, { id: `opening.days.${day.dayType}` }) }) }, day.dayType)))] }) }), _jsxs("tbody", { children: [_jsx("tr", { children: _jsx(Rows, { kind: "dawn", rows: dawnSkiingDays }) }), _jsx("tr", { children: _jsx(Rows, { kind: "night", rows: nightSkiingDays }) })] })] }) }) }));
21
21
  });
22
22
  function Rows({ kind, rows }) {
23
23
  const Icon = kind === "dawn" ? DawnIcon : NightIcon;
@@ -1 +1 @@
1
- {"version":3,"file":"pois.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/lumiplan/pois.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAAyB,QAAQ,EAAQ,MAAM,SAAS,CAAC;AAwDrE,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxB,CAAC;AASF,QAAA,MAAM,IAAI,8EAgLR,CAAC;AAIH,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"pois.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/lumiplan/pois.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,OAAO,KAAK,EAAyB,QAAQ,EAAQ,MAAM,SAAS,CAAC;AAwDrE,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxB,CAAC;AASF,QAAA,MAAM,IAAI,8EA+KR,CAAC;AAIH,eAAe,IAAI,CAAC"}
@@ -96,8 +96,8 @@ const Pois = React.forwardRef(({ pois }, ref) => {
96
96
  const toggleExpanded = () => {
97
97
  setExpanded(!expanded);
98
98
  };
99
- const displayedPois = expanded ? flattenedPois : flattenedPois.slice(0, 15);
100
- return (_jsx("div", { className: css.pois, children: _jsxs("div", { className: css.inner, children: [_jsx("div", { className: css.list, children: displayedPois.map(({ id, name, type, liftType, trailType, trailLevel, sectorName, messagePoi, openingStatus, snowQuality, groomingStatus, openingStatusCompl, }) => {
99
+ const displayedPois = expanded ? flattenedPois : flattenedPois.slice(0, 16);
100
+ return (_jsx("div", { className: css.pois, children: _jsxs("div", { className: css.inner, children: [_jsx("div", { className: css.list, children: displayedPois.map(({ id, name, type, liftType, trailType, trailLevel, sectorName, messagePoi, openingStatus, snowQuality, groomingStatus, }) => {
101
101
  const isLift = type === "SKI_LIFT";
102
102
  const translationCode = isLift
103
103
  ? `pois.lifts.${liftType}`
@@ -1 +1 @@
1
- {"version":3,"file":"road-condition.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/lumiplan/road-condition.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,KAAK,KAAK,GAAG;IACX,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CACpC,CAAC;AAEF,QAAA,MAAM,aAAa,8EA8ElB,CAAC;AAIF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"road-condition.d.ts","sourceRoot":"","sources":["../../../../src/lbm/components/lumiplan/road-condition.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,KAAK,KAAK,GAAG;IACX,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CACpC,CAAC;AAEF,QAAA,MAAM,aAAa,8EAmFlB,CAAC;AAIF,eAAe,aAAa,CAAC"}
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { useUbloContext } from "ublo/with-ublo";
4
4
  import Loader from "dt-design-system/es/loader";
@@ -14,12 +14,13 @@ const RoadCondition = React.forwardRef(({ resortAccess }, ref) => {
14
14
  return null;
15
15
  }
16
16
  const { roadConditions } = resortAccess;
17
- return (_jsxs("div", { ref: ref, className: css.conditions, "data-tags": t(lang, "road-conditions.navigation-title"), children: [_jsx("div", { className: css.title, dangerouslySetInnerHTML: { __html: t(lang, "road-conditions.title") } }), roadConditions.map(({ id, name, status, roadInfo, equipment, surface }) => {
17
+ return (_jsxs("div", { ref: ref, className: css.conditions, "data-tags": t(lang, "road-conditions.navigation-title"), children: [_jsx("div", { className: css.title, dangerouslySetInnerHTML: { __html: t(lang, "road-conditions.title") } }), roadConditions.map(({ id, name, status, roadInfo, equipment, surface, number }) => {
18
18
  const roadInfoData = roadInfo?.data?.find(({ language }) => {
19
19
  const _lang = lang === "fr" ? "fr_FR" : "en_US";
20
20
  return language === _lang;
21
21
  });
22
- return (_jsxs("div", { className: css.condition, children: [_jsx(RoadConditionIcon, { className: css.icon }), _jsxs("div", { className: css.right, children: [_jsxs("div", { className: css.top, children: [_jsx("div", { className: css.name, children: name }), _jsxs("div", { className: css.surface, children: [_jsx("b", { children: _jsx(T, { id: "road-conditions.surface.title" }) }), _jsx(T, { id: `road-conditions.surface.states.${surface}` }), "."] }), _jsxs("div", { className: css.equipment, children: [_jsx("b", { children: _jsx(T, { id: "road-conditions.equipment.title" }) }), _jsx(T, { id: `road-conditions.equipment.states.${equipment}` })] })] }), roadInfoData && (_jsx("div", { className: css.bottom, dangerouslySetInnerHTML: { __html: roadInfoData.data } }))] }), _jsx("div", { className: css.status, children: _jsx(T, { id: `road-conditions.status.${status ? "OPENED" : "CLOSED"}` }) })] }, id));
22
+ const hasValidNumber = !isNaN(parseInt(number, 10));
23
+ return (_jsxs("div", { className: css.condition, children: [_jsx(RoadConditionIcon, { className: css.icon }), _jsxs("div", { className: css.right, children: [_jsxs("div", { className: css.top, children: [_jsxs("div", { className: css.name, children: [name, " ", hasValidNumber && _jsxs(_Fragment, { children: ["n\u00B0", number] })] }), _jsxs("div", { className: css.surface, children: [_jsx("b", { children: _jsx(T, { id: "road-conditions.surface.title" }) }), _jsx(T, { id: `road-conditions.surface.states.${surface}` }), "."] }), _jsxs("div", { className: css.equipment, children: [_jsx("b", { children: _jsx(T, { id: "road-conditions.equipment.title" }) }), _jsx(T, { id: `road-conditions.equipment.states.${equipment}` })] })] }), roadInfoData && (_jsx("div", { className: css.bottom, dangerouslySetInnerHTML: { __html: roadInfoData.data } }))] }), _jsx("div", { className: css.status, children: _jsx(T, { id: `road-conditions.status.${status ? "OPENED" : "CLOSED"}` }) })] }, id));
23
24
  })] }));
24
25
  });
25
26
  RoadCondition.displayName = "RoadCondition";
@@ -30,6 +30,6 @@
30
30
  }
31
31
 
32
32
  .text {
33
- font-style: 18px;
33
+ font-size: 16px;
34
34
  color: hsl(var(--primary));
35
35
  }
@@ -4,6 +4,6 @@ type Props = {
4
4
  data: WeatherInfo;
5
5
  expanded: boolean;
6
6
  };
7
- export default function WeatherData({ kind, data, expanded }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export default function WeatherData({ kind, data, expanded }: Props): import("react/jsx-runtime").JSX.Element | null;
8
8
  export {};
9
9
  //# sourceMappingURL=weather-data.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"weather-data.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/lumiplan/weather/weather-data.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,KAAK,2CA2GlE"}
1
+ {"version":3,"file":"weather-data.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/lumiplan/weather/weather-data.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,KAAK,kDA6GlE"}
@@ -3,6 +3,8 @@ import T from "../i18n/translations";
3
3
  import WeatherIcon from "./weather-icon";
4
4
  import css from "./weather-data.module.css";
5
5
  export default function WeatherData({ kind, data, expanded }) {
6
+ if (!data)
7
+ return null;
6
8
  const { skyStatus, temperature, windchill, indexUv, limitIsothermic0, limitIsothermicMinus10, limitRainSnowFall, visibility, wind, } = data;
7
9
  return (_jsxs("div", { className: css.weatherData, children: [_jsx(WeatherIcon, { sky: skyStatus }), _jsxs("div", { className: css.weatherInfo, children: [_jsx("div", { className: css.weatherInfoTitle, children: _jsx(T, { id: `weather.${kind}` }) }), _jsxs("div", { className: css.weatherInfoTemperatures, children: [_jsxs("span", { children: [temperature.value, _jsx(T, { id: temperature.unit })] }), "|", _jsxs("span", { children: [windchill.value, _jsx(T, { id: windchill.unit }), _jsx("em", { children: _jsx(T, { id: "weather.feels-like" }) })] })] }), expanded && (_jsxs("div", { className: css.expanded, children: [skyStatus && (_jsxs("div", { className: css.data, children: [_jsx(T, { id: "weather.sky-status.title" }), " :", " ", _jsx(T, { id: `weather.sky-status.states.${skyStatus}` })] })), temperature && (_jsxs("div", { className: css.data, children: [_jsx(T, { id: "weather.temperature" }), " : ", temperature.value, _jsx(T, { id: temperature.unit })] })), wind && (_jsxs(_Fragment, { children: [wind.value && (_jsxs("div", { className: css.data, children: [_jsx(T, { id: "weather.wind" }), " : ", wind.value.value, _jsx(T, { id: wind.value.unit })] })), wind.valueMax && (_jsxs("div", { className: css.data, children: [_jsx(T, { id: "weather.wind-max" }), " : ", wind.valueMax.value, _jsx(T, { id: wind.valueMax.unit })] })), wind.direction && (_jsxs("div", { className: css.data, children: [_jsx(T, { id: "weather.wind-direction.title" }), " :", " ", _jsx(T, { id: `weather.wind-direction.states.${wind.direction}` })] }))] })), limitRainSnowFall && (_jsxs("div", { className: css.data, children: [_jsx(T, { id: "weather.limit-rain-snow-fall" }), " :", " ", limitRainSnowFall.value, _jsx(T, { id: limitRainSnowFall.unit })] })), limitIsothermic0 && (_jsxs("div", { className: css.data, children: [_jsx(T, { id: "weather.limit-isothermic-0" }), " : ", limitIsothermic0.value, _jsx(T, { id: limitIsothermic0.unit })] })), limitIsothermicMinus10 && (_jsxs("div", { className: css.data, children: [_jsx(T, { id: "weather.limit-isothermic-minus-10" }), " :", " ", limitIsothermicMinus10.value, _jsx(T, { id: limitIsothermicMinus10.unit })] })), visibility && (_jsxs("div", { className: css.data, children: [_jsx(T, { id: "weather.visibility.title" }), " :", " ", _jsx(T, { id: `weather.visibility.states.${visibility}` })] })), indexUv && (_jsxs("div", { className: css.data, children: [_jsx(T, { id: "weather.index-uv" }), " : ", indexUv.value, _jsx(T, { id: indexUv.unit })] }))] }))] })] }));
8
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"weather.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/lumiplan/weather/weather.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGhD,KAAK,KAAK,GAAG;IACX,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,QAAA,MAAM,OAAO,8EAsIZ,CAAC;AAIF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"weather.d.ts","sourceRoot":"","sources":["../../../../../src/lbm/components/lumiplan/weather/weather.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGhD,KAAK,KAAK,GAAG;IACX,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,QAAA,MAAM,OAAO,8EA+IZ,CAAC;AAIF,eAAe,OAAO,CAAC"}
@@ -15,7 +15,7 @@ const Weather = React.forwardRef(({ weather }, ref) => {
15
15
  const { lang } = useUbloContext();
16
16
  const [currentZoneIndex, setCurrentZoneIndex] = React.useState(0);
17
17
  const [currentDayIndex, setCurrentDayIndex] = React.useState(0);
18
- const [expanded, setExpanded] = React.useState(false);
18
+ const [expanded, setExpanded] = React.useState(true);
19
19
  React.useEffect(() => {
20
20
  setCurrentZoneIndex(0);
21
21
  setCurrentDayIndex(0);
@@ -29,14 +29,15 @@ const Weather = React.forwardRef(({ weather }, ref) => {
29
29
  const { weatherZones } = weather.weather;
30
30
  const { snowZones } = weather.snow;
31
31
  const { weatherInfos } = weatherZones[currentZoneIndex] || {};
32
- const { am, pm } = weatherInfos[currentDayIndex] || {};
32
+ const days = weatherInfos.slice(0, 4);
33
+ const { am, pm } = days[currentDayIndex] || {};
33
34
  const snowData = snowZones[currentZoneIndex] || {};
34
35
  const ExpandIcon = expanded ? Icons.MinusCircle : Icons.PlusCircle;
35
36
  const toggleExpanded = () => {
36
37
  setExpanded(!expanded);
37
38
  };
38
- return (_jsxs("div", { ref: ref, className: css.weather, "data-tags": t(lang, "weather.title"), children: [_jsxs("div", { className: css.header, children: [_jsx("div", { className: css.days, children: weatherInfos.map((weatherInfo, i) => {
39
- const { date, am, pm } = weatherInfo;
39
+ return (_jsxs("div", { ref: ref, className: css.weather, "data-tags": t(lang, "weather.title"), children: [_jsxs("div", { className: css.header, children: [_jsx("div", { className: css.days, children: days.map((day, i) => {
40
+ const { date, am, pm } = day;
40
41
  if (!pm || !am)
41
42
  return null;
42
43
  const isSelected = i === currentDayIndex;
@@ -45,7 +46,7 @@ const Weather = React.forwardRef(({ weather }, ref) => {
45
46
  };
46
47
  const isToday = new Date(date).getDate() === new Date().getDate();
47
48
  const locale = lang === "fr" ? "fr-FR" : "en-UK";
48
- const day = new Date(date).toLocaleDateString(locale, {
49
+ const today = new Date(date).toLocaleDateString(locale, {
49
50
  weekday: "long",
50
51
  });
51
52
  const formatedDate = new Date(date).toLocaleDateString(locale, {
@@ -56,8 +57,13 @@ const Weather = React.forwardRef(({ weather }, ref) => {
56
57
  const classes = classNames(css.day, {
57
58
  [css.daySelected]: isSelected,
58
59
  });
59
- return (_jsxs(Button, { className: classes, onClick: updateCurrentDay, children: [_jsx("b", { children: isToday ? _jsx(T, { id: "weather.today" }) : day }), formatedDate] }, date));
60
+ return (_jsxs(Button, { className: classes, onClick: updateCurrentDay, children: [_jsx("b", { children: isToday ? _jsx(T, { id: "weather.today" }) : today }), formatedDate] }, date));
60
61
  }) }), _jsx("div", { className: css.zones, children: weatherZones.map((zone, i) => {
62
+ const hasData = Boolean(zone.weatherInfos.length > 0 &&
63
+ zone.weatherInfos[0].am &&
64
+ zone.weatherInfos[0].pm);
65
+ if (!hasData)
66
+ return null;
61
67
  const { name, altitude } = zone;
62
68
  const { value, unit } = altitude;
63
69
  const isSelected = i === currentZoneIndex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.21.3",
3
+ "version": "1.21.5",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^3.1.5",
6
6
  "leaflet": "^1.9.1",