ublo-lib 1.0.22 → 1.0.25

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,7 +7,7 @@ import Button from "dt-design-system/es/button";
7
7
  import * as Messages from "./messages";
8
8
  import * as Icons from "./icons";
9
9
  import * as DTIcons from "dt-design-system/es/icons";
10
- import styles from "./index.module.css";
10
+ import styles from "./custom-contact-form.module.css";
11
11
  import { getInitialFormState, getSettings, send } from "./utils";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -20,20 +20,17 @@ const CustomContactFormWithSnackbar = props => {
20
20
  };
21
21
 
22
22
  const CustomContactForm = ({
23
- formTitle,
24
- fields,
25
23
  kind,
26
- onSubmit,
24
+ title,
25
+ fields,
27
26
  presets,
28
- setPresets,
29
- allowPresetsReset,
30
- subjectPrefix,
31
- subjectSuffix,
32
27
  className,
33
28
  innerClassName,
29
+ subject,
30
+ onSubmit,
34
31
  customSend
35
32
  }) => {
36
- const [data, setData] = React.useState(getInitialFormState(fields, presets));
33
+ const [data, setData] = React.useState(getInitialFormState(fields, presets?.values));
37
34
  const [sending, setSending] = React.useState(false);
38
35
  const [ready, setReady] = React.useState(false);
39
36
  const [settings, setSettings] = React.useState();
@@ -57,8 +54,8 @@ const CustomContactForm = ({
57
54
  site,
58
55
  data,
59
56
  fields,
60
- subjectPrefix,
61
- subjectSuffix
57
+ subjectPrefix: subject?.prefix,
58
+ subjectSuffix: subject?.suffix
62
59
  });
63
60
 
64
61
  if (error) {
@@ -84,7 +81,7 @@ const CustomContactForm = ({
84
81
  };
85
82
 
86
83
  const resetForm = () => {
87
- setPresets?.(undefined);
84
+ presets.setter?.(undefined);
88
85
  setData(getInitialFormState(fields));
89
86
  };
90
87
 
@@ -104,8 +101,8 @@ const CustomContactForm = ({
104
101
  }
105
102
  }, [ready, settings, site]);
106
103
  React.useEffect(() => {
107
- setData(getInitialFormState(fields, presets));
108
- }, [fields, presets]);
104
+ setData(getInitialFormState(fields, presets.values));
105
+ }, [fields, presets?.values]);
109
106
  const classes = classnames(styles.root, {
110
107
  [className]: className
111
108
  });
@@ -122,12 +119,12 @@ const CustomContactForm = ({
122
119
  });
123
120
  }
124
121
 
125
- const formKey = presets ? JSON.stringify(presets) : undefined;
122
+ const formKey = presets ? JSON.stringify(presets.values) : undefined;
126
123
  return _jsxs("div", {
127
124
  className: classes,
128
- children: [formTitle && _jsx("div", {
125
+ children: [title && _jsx("div", {
129
126
  className: styles.title,
130
- children: formTitle
127
+ children: title
131
128
  }), _jsx("div", {
132
129
  className: innerClasses,
133
130
  children: Object.keys(fields).map(key => _jsx(Field, {
@@ -137,11 +134,11 @@ const CustomContactForm = ({
137
134
  data: data,
138
135
  setData: setData,
139
136
  settings: settings,
140
- presets: presets
137
+ presets: presets?.values
141
138
  }, key))
142
139
  }, formKey), _jsxs("div", {
143
140
  className: styles.bottom,
144
- children: [presets && allowPresetsReset && _jsx(Button, {
141
+ children: [presets?.allowReset && _jsx(Button, {
145
142
  className: styles.resetButton,
146
143
  disabled: sending,
147
144
  onClick: resetForm,
@@ -1,181 +1,2 @@
1
- import * as React from "react";
2
- import { useEffect, useState } from "react";
3
- import classnames from "classnames";
4
- import { fetchRandomInstructors } from "./fetcher";
5
- import { PersonIcon, ArrowDownIcon, CloseIcon, flags } from "./icons";
6
- import Loader from "./loader";
7
- import messages from "./messages";
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- import { jsxs as _jsxs } from "react/jsx-runtime";
10
- import { Fragment as _Fragment } from "react/jsx-runtime";
11
-
12
- const InstructorSuggestions = ({
13
- school,
14
- lang,
15
- tags,
16
- size,
17
- buildHref,
18
- env
19
- }) => {
20
- const [instructors, setInstructors] = useState();
21
- const [instructor, setInstructor] = useState();
22
- const texts = messages(lang);
23
-
24
- const selectInstructor = instructor => () => {
25
- setInstructor(instructor);
26
- };
27
-
28
- useEffect(() => {
29
- const fetchInstructors = async () => {
30
- if (school && lang && tags) {
31
- const instructors = await fetchRandomInstructors(school, lang, tags, size, env);
32
- setInstructors(instructors);
33
- }
34
- };
35
-
36
- fetchInstructors();
37
- }, [school, lang, tags, size, env]);
38
-
39
- const renderDetails = () => {
40
- const {
41
- firstname,
42
- lastname,
43
- languages,
44
- activities,
45
- introduction,
46
- description,
47
- uri
48
- } = instructor;
49
- return _jsxs(_Fragment, {
50
- children: [_jsx("div", {
51
- className: "instructor-suggestions__details-close",
52
- onClick: selectInstructor(),
53
- children: _jsx(CloseIcon, {
54
- className: "instructor-suggestions__details-close-icon"
55
- })
56
- }), _jsxs("div", {
57
- className: "instructor-suggestions__details-data",
58
- children: [_jsxs("div", {
59
- className: "instructor-suggestions__details-name",
60
- children: [_jsx("span", {
61
- className: "instructor-suggestions__details-firstname",
62
- children: firstname
63
- }), " ", _jsx("span", {
64
- className: "instructor-suggestions__details-lastname",
65
- children: lastname
66
- })]
67
- }), _jsx("div", {
68
- className: "instructor-suggestions__details-langs",
69
- children: languages && languages.map(({
70
- code,
71
- label
72
- }) => {
73
- const Flag = flags[code];
74
- return Flag ? _jsx(Flag, {
75
- className: "instructor-suggestions__details-lang",
76
- title: label
77
- }, code) : _jsx("div", {
78
- className: "instructor-suggestions__details-langtext",
79
- children: label
80
- }, code);
81
- })
82
- }), activities && _jsxs("div", {
83
- className: "instructor-suggestions__details-skills",
84
- children: ["Mes sp\xE9cialit\xE9s sont :", " ", activities.map(({
85
- code,
86
- label
87
- }, index) => {
88
- const length = activities.length;
89
- return _jsxs("div", {
90
- className: "instructor-suggestions__details-skill",
91
- children: [_jsx("span", {
92
- className: "instructor-suggestions__details-skillspan",
93
- children: label
94
- }), index < length - 2 ? ", " : index < length - 1 ? texts["instructor-suggestions-and"] : ""]
95
- }, code);
96
- })]
97
- })]
98
- }), _jsxs("div", {
99
- className: "instructor-suggestions__details-description",
100
- children: [_jsx("div", {
101
- className: "instructor-suggestions__details-mojo",
102
- dangerouslySetInnerHTML: {
103
- __html: introduction
104
- }
105
- }), description && description.trim() !== "" && _jsxs(_Fragment, {
106
- children: [_jsx("div", {
107
- className: "instructor-suggestions__details-description-title",
108
- children: texts["instructor-suggestions-about"]
109
- }), _jsx("div", {
110
- className: "instructor-suggestions__details-text",
111
- dangerouslySetInnerHTML: {
112
- __html: description
113
- }
114
- })]
115
- })]
116
- }), buildHref && _jsx("div", {
117
- className: "instructor-suggestions__details-bottom",
118
- children: _jsx("a", {
119
- className: "instructor-suggestions__details-see-more",
120
- href: buildHref(uri),
121
- children: texts["instructor-suggestions-see-full-version"]
122
- })
123
- })]
124
- });
125
- };
126
-
127
- const renderInstructors = () => {
128
- return instructors.map(instructor => {
129
- const {
130
- uri,
131
- photo,
132
- firstname,
133
- lastname
134
- } = instructor;
135
- return _jsx("div", {
136
- className: "instructor-suggestions__instructor",
137
- onClick: selectInstructor(instructor),
138
- children: _jsxs("div", {
139
- className: "instructor-suggestions__instructor-inner",
140
- children: [_jsx("div", {
141
- className: "instructor-suggestions__instructor-image-container",
142
- children: photo ? _jsx("img", {
143
- src: photo,
144
- className: "instructor-suggestions__instructor-image",
145
- alt: `${firstname}-${lastname}`
146
- }) : _jsx(PersonIcon, {
147
- className: "instructor-suggestions__instructor-imageplaceholder"
148
- })
149
- }), _jsx("div", {
150
- className: "instructor-suggestions__instructor-firstname",
151
- children: firstname
152
- }), _jsx("div", {
153
- className: "instructor-suggestions__instructor-lastname",
154
- children: lastname
155
- }), _jsx("div", {
156
- className: "instructor-suggestions__instructor-arrow-container",
157
- children: _jsx(ArrowDownIcon, {
158
- className: "instructor-suggestions__instructor-arrow"
159
- })
160
- })]
161
- })
162
- }, uri);
163
- });
164
- };
165
-
166
- const detailsClasses = classnames("instructor-suggestions__details", {
167
- "instructor-suggestions__details__open": instructor
168
- });
169
- return _jsxs("div", {
170
- className: "instructor-suggestions",
171
- children: [_jsx("div", {
172
- className: "instructor-suggestions__instructors",
173
- children: instructors ? renderInstructors() : _jsx(Loader, {})
174
- }), _jsx("div", {
175
- className: detailsClasses,
176
- children: instructor ? renderDetails() : ""
177
- })]
178
- });
179
- };
180
-
1
+ import InstructorSuggestions from "./instructor-suggestions";
181
2
  export default InstructorSuggestions;
@@ -0,0 +1,187 @@
1
+ import * as React from "react";
2
+ import { useEffect, useState } from "react";
3
+ import classnames from "classnames";
4
+ import { fetchRandomInstructors } from "./fetcher";
5
+ import { PersonIcon, ArrowDownIcon, CloseIcon, flags } from "./icons";
6
+ import Loader from "./loader";
7
+ import messages from "./messages";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ import { Fragment as _Fragment } from "react/jsx-runtime";
11
+
12
+ const InstructorSuggestions = ({
13
+ size,
14
+ buildHref,
15
+ env
16
+ }) => {
17
+ const {
18
+ seo,
19
+ lang,
20
+ config
21
+ } = useUbloContext();
22
+ const {
23
+ resort: school
24
+ } = config;
25
+ const tags = useMemo(() => seo && seo.keywords && seo.keywords.trim() !== "" ? seo.keywords.split(",") : undefined, [seo]);
26
+ const [instructors, setInstructors] = useState();
27
+ const [instructor, setInstructor] = useState();
28
+ const texts = messages(lang);
29
+
30
+ const selectInstructor = instructor => () => {
31
+ setInstructor(instructor);
32
+ };
33
+
34
+ useEffect(() => {
35
+ const fetchInstructors = async () => {
36
+ if (school && lang && tags) {
37
+ const instructors = await fetchRandomInstructors(school, lang, tags, size, env);
38
+ setInstructors(instructors);
39
+ }
40
+ };
41
+
42
+ fetchInstructors();
43
+ }, [school, lang, tags, size, env]);
44
+
45
+ const renderDetails = () => {
46
+ const {
47
+ firstname,
48
+ lastname,
49
+ languages,
50
+ activities,
51
+ introduction,
52
+ description,
53
+ uri
54
+ } = instructor;
55
+ return _jsxs(_Fragment, {
56
+ children: [_jsx("div", {
57
+ className: "instructor-suggestions__details-close",
58
+ onClick: selectInstructor(),
59
+ children: _jsx(CloseIcon, {
60
+ className: "instructor-suggestions__details-close-icon"
61
+ })
62
+ }), _jsxs("div", {
63
+ className: "instructor-suggestions__details-data",
64
+ children: [_jsxs("div", {
65
+ className: "instructor-suggestions__details-name",
66
+ children: [_jsx("span", {
67
+ className: "instructor-suggestions__details-firstname",
68
+ children: firstname
69
+ }), " ", _jsx("span", {
70
+ className: "instructor-suggestions__details-lastname",
71
+ children: lastname
72
+ })]
73
+ }), _jsx("div", {
74
+ className: "instructor-suggestions__details-langs",
75
+ children: languages && languages.map(({
76
+ code,
77
+ label
78
+ }) => {
79
+ const Flag = flags[code];
80
+ return Flag ? _jsx(Flag, {
81
+ className: "instructor-suggestions__details-lang",
82
+ title: label
83
+ }, code) : _jsx("div", {
84
+ className: "instructor-suggestions__details-langtext",
85
+ children: label
86
+ }, code);
87
+ })
88
+ }), activities && _jsxs("div", {
89
+ className: "instructor-suggestions__details-skills",
90
+ children: ["Mes sp\xE9cialit\xE9s sont :", " ", activities.map(({
91
+ code,
92
+ label
93
+ }, index) => {
94
+ const length = activities.length;
95
+ return _jsxs("div", {
96
+ className: "instructor-suggestions__details-skill",
97
+ children: [_jsx("span", {
98
+ className: "instructor-suggestions__details-skillspan",
99
+ children: label
100
+ }), index < length - 2 ? ", " : index < length - 1 ? texts["instructor-suggestions-and"] : ""]
101
+ }, code);
102
+ })]
103
+ })]
104
+ }), _jsxs("div", {
105
+ className: "instructor-suggestions__details-description",
106
+ children: [_jsx("div", {
107
+ className: "instructor-suggestions__details-mojo",
108
+ dangerouslySetInnerHTML: {
109
+ __html: introduction
110
+ }
111
+ }), description && description.trim() !== "" && _jsxs(_Fragment, {
112
+ children: [_jsx("div", {
113
+ className: "instructor-suggestions__details-description-title",
114
+ children: texts["instructor-suggestions-about"]
115
+ }), _jsx("div", {
116
+ className: "instructor-suggestions__details-text",
117
+ dangerouslySetInnerHTML: {
118
+ __html: description
119
+ }
120
+ })]
121
+ })]
122
+ }), buildHref && _jsx("div", {
123
+ className: "instructor-suggestions__details-bottom",
124
+ children: _jsx("a", {
125
+ className: "instructor-suggestions__details-see-more",
126
+ href: buildHref(uri),
127
+ children: texts["instructor-suggestions-see-full-version"]
128
+ })
129
+ })]
130
+ });
131
+ };
132
+
133
+ const renderInstructors = () => {
134
+ return instructors.map(instructor => {
135
+ const {
136
+ uri,
137
+ photo,
138
+ firstname,
139
+ lastname
140
+ } = instructor;
141
+ return _jsx("div", {
142
+ className: "instructor-suggestions__instructor",
143
+ onClick: selectInstructor(instructor),
144
+ children: _jsxs("div", {
145
+ className: "instructor-suggestions__instructor-inner",
146
+ children: [_jsx("div", {
147
+ className: "instructor-suggestions__instructor-image-container",
148
+ children: photo ? _jsx("img", {
149
+ src: photo,
150
+ className: "instructor-suggestions__instructor-image",
151
+ alt: `${firstname}-${lastname}`
152
+ }) : _jsx(PersonIcon, {
153
+ className: "instructor-suggestions__instructor-imageplaceholder"
154
+ })
155
+ }), _jsx("div", {
156
+ className: "instructor-suggestions__instructor-firstname",
157
+ children: firstname
158
+ }), _jsx("div", {
159
+ className: "instructor-suggestions__instructor-lastname",
160
+ children: lastname
161
+ }), _jsx("div", {
162
+ className: "instructor-suggestions__instructor-arrow-container",
163
+ children: _jsx(ArrowDownIcon, {
164
+ className: "instructor-suggestions__instructor-arrow"
165
+ })
166
+ })]
167
+ })
168
+ }, uri);
169
+ });
170
+ };
171
+
172
+ const detailsClasses = classnames("instructor-suggestions__details", {
173
+ "instructor-suggestions__details__open": instructor
174
+ });
175
+ return _jsxs("div", {
176
+ className: "instructor-suggestions",
177
+ children: [_jsx("div", {
178
+ className: "instructor-suggestions__instructors",
179
+ children: instructors ? renderInstructors() : _jsx(Loader, {})
180
+ }), _jsx("div", {
181
+ className: detailsClasses,
182
+ children: instructor ? renderDetails() : ""
183
+ })]
184
+ });
185
+ };
186
+
187
+ export default InstructorSuggestions;
@@ -3,7 +3,7 @@ import List from "./list";
3
3
  import Details from "./details";
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
5
 
6
- const InstructorsBook = props => {
6
+ const Inner = props => {
7
7
  return _jsx("div", {
8
8
  className: "instructors-book",
9
9
  children: props.instructor ? _jsx(Details, { ...props
@@ -12,4 +12,4 @@ const InstructorsBook = props => {
12
12
  });
13
13
  };
14
14
 
15
- export default InstructorsBook;
15
+ export default Inner;
@@ -0,0 +1,124 @@
1
+ import * as React from "react";
2
+ import { memo, useEffect, useState } from "react";
3
+ import { useUbloContext } from "ublo/with-ublo";
4
+ import Inner from "./inner";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const host = "https://instructors-book-server.carnet-rouge-esf.com";
7
+
8
+ const fetcher = async (url, school, body) => {
9
+ const res = await fetch(url, {
10
+ method: "POST",
11
+ headers: {
12
+ "content-type": "application/json;charset=utf-8",
13
+ Authorization: "00q2qa545018261l252gg3414t3qa2",
14
+ schoolcode: school
15
+ },
16
+ body: body ? JSON.stringify(body) : undefined
17
+ });
18
+ return res.json();
19
+ };
20
+
21
+ export const fetchInstructorsContext = (school, lang, body = {}) => fetcher(`${host}/api/instructors-book/${school}/${lang}`, school, { ...body,
22
+ project: true
23
+ });
24
+ export const fetchInstructor = (school, lang, uri) => fetcher(`${host}/api/instructors-book/${school}/${lang}/${uri}`, school);
25
+
26
+ const propsFromQueryString = () => {
27
+ if (typeof window === "undefined") return {};
28
+ const params = new URLSearchParams(document.location.search);
29
+ const activity = params.get("activity") || undefined;
30
+ const language = params.get("language") || undefined;
31
+ return {
32
+ activity,
33
+ language
34
+ };
35
+ };
36
+
37
+ const hasTrailingSlash = path => path.length > 1 && path.endsWith("/");
38
+
39
+ const InstructorsBook = ({
40
+ instructorsContext,
41
+ instructor,
42
+ trombi
43
+ }) => {
44
+ const {
45
+ lang,
46
+ path,
47
+ config
48
+ } = useUbloContext();
49
+ const {
50
+ resort
51
+ } = config;
52
+ const [instructorsCtx, setInstructorsCtx] = useState(instructorsContext);
53
+ const [activity, setActivity] = useState();
54
+ const [language, setLanguage] = useState();
55
+ useEffect(() => {
56
+ const {
57
+ activity,
58
+ language
59
+ } = propsFromQueryString();
60
+
61
+ if (activity) {
62
+ sessionStorage.activity = activity;
63
+ }
64
+
65
+ if (language) {
66
+ sessionStorage.language = language;
67
+ }
68
+
69
+ setActivity(sessionStorage.activity);
70
+ setLanguage(sessionStorage.language);
71
+
72
+ if ((sessionStorage.activity || sessionStorage.language) && !instructor) {
73
+ fetchNewContext(sessionStorage.activity, sessionStorage.language);
74
+ }
75
+ }, []);
76
+
77
+ const fetchNewContext = async (activity, language) => {
78
+ const newContext = await fetchInstructorsContext(resort, lang, {
79
+ activity,
80
+ language
81
+ });
82
+ setInstructorsCtx(newContext);
83
+ };
84
+
85
+ const selectInstructor = uri => {
86
+ return {
87
+ href: path.concat(hasTrailingSlash(path) ? "" : "/").concat(uri)
88
+ };
89
+ };
90
+
91
+ const backToList = uri => {
92
+ return {
93
+ href: path.replace(`/${uri}`, "")
94
+ };
95
+ };
96
+
97
+ const selectFilter = async (filter, value) => {
98
+ sessionStorage[filter] = value;
99
+
100
+ if (filter === "activity") {
101
+ setActivity(value);
102
+ await fetchNewContext(value, language);
103
+ } else {
104
+ setLanguage(value);
105
+ await fetchNewContext(activity, value);
106
+ }
107
+ };
108
+
109
+ const dataProps = instructorsCtx !== undefined ? { ...instructorsCtx
110
+ } : {
111
+ instructor
112
+ };
113
+ return _jsx(Inner, { ...dataProps,
114
+ lang: lang,
115
+ selectInstructor: selectInstructor,
116
+ selectFilter: selectFilter,
117
+ backToList: backToList,
118
+ activity: activity,
119
+ language: language,
120
+ trombi: trombi
121
+ });
122
+ };
123
+
124
+ export default memo(InstructorsBook);
@@ -17,6 +17,7 @@ const messages = {
17
17
  rooms: "Chambres",
18
18
  nbRooms: "Nombre de chambres",
19
19
  roomType: "Type de chambre",
20
+ activities: "Activités",
20
21
  domains: "Domaines",
21
22
  durations: "Durées",
22
23
  skiers: "Personnes",
@@ -14,6 +14,16 @@ import styles from "./ski-pass.module.css";
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
16
  import { Fragment as _Fragment } from "react/jsx-runtime";
17
+ const ACTIVITIES_LABELS = {
18
+ piscine: "Piscine",
19
+ patinoire: "Patinoire",
20
+ vtt: "VTT",
21
+ ski: "Ski",
22
+ "acces-pieton": "Accès piéton",
23
+ "bouee-neige": "Bouée sur neige",
24
+ "ski-activite": "Ski + Activités",
25
+ luge: "Luge sur rails"
26
+ };
17
27
  const DEFAULT_DATA = {
18
28
  stayFrom: "",
19
29
  stayTo: "",
@@ -30,6 +40,7 @@ const getDefaultData = config => {
30
40
  stay,
31
41
  skiers,
32
42
  firstSkiDate,
43
+ activities,
33
44
  domains,
34
45
  durations
35
46
  } = config.presets;
@@ -38,6 +49,7 @@ const getDefaultData = config => {
38
49
  stayTo: stay?.to || DEFAULT_DATA.stayTo,
39
50
  skiers: skiers || DEFAULT_DATA.skiers,
40
51
  firstSkiDate: firstSkiDate || DEFAULT_DATA.firstSkiDate,
52
+ activities: activities || DEFAULT_DATA.activities,
41
53
  domains: domains || DEFAULT_DATA.domains,
42
54
  durations: durations || DEFAULT_DATA.durations
43
55
  };
@@ -81,6 +93,47 @@ const SkiPass = ({
81
93
  value: catalog,
82
94
  label: catalog
83
95
  }))];
96
+ const activities = [...new Set(filters?.domains?.reduce((acc, domain) => {
97
+ const {
98
+ tags
99
+ } = domain;
100
+ if (!tags?.length) return acc;
101
+ const formatedTags = tags.filter(tag => {
102
+ return Object.keys(ACTIVITIES_LABELS).includes(tag) && !acc.some(item => item.value === tag);
103
+ }).map(tag => {
104
+ return {
105
+ value: tag,
106
+ label: ACTIVITIES_LABELS[tag] || tag
107
+ };
108
+ });
109
+ return [...acc, ...formatedTags];
110
+ }, []))];
111
+ const selectedActivities = data.activities.map(activity => activities.find(a => a.value === activity));
112
+ const selectedActivitiesCodes = activities.reduce((acc, activity) => {
113
+ const {
114
+ value
115
+ } = activity;
116
+ return data.activities?.includes(value) ? [...new Set([...acc, value])] : acc;
117
+ }, []);
118
+ const filteredDomains = selectedActivitiesCodes?.length > 0 ? filters.domains?.filter(domain => {
119
+ return domain.tags?.some(tag => {
120
+ return selectedActivitiesCodes.includes(tag);
121
+ });
122
+ }) : filters?.domains;
123
+ const selectedDomainsIds = filters?.domains.reduce((acc, domain) => {
124
+ const {
125
+ code,
126
+ catalogIds
127
+ } = domain;
128
+ return data.domains.includes(code) ? [...new Set([...acc, ...catalogIds])] : acc;
129
+ }, []);
130
+ const filteredDurations = selectedActivitiesCodes?.length > 0 ? filters.durations?.filter(duration => {
131
+ return duration.tags?.some(tag => {
132
+ return selectedActivitiesCodes.includes(tag) || duration.catalogIds.some(id => selectedDomainsIds.includes(id));
133
+ });
134
+ }) : filters?.durations;
135
+ const selectedDomains = data.domains.map(domain => filters?.domains?.find(d => d.value === domain));
136
+ const selectedDurations = data.durations.map(domain => filters?.durations?.find(d => d.value === domain));
84
137
 
85
138
  const updateField = field => value => {
86
139
  const isFrom = field === "stayFrom";
@@ -195,12 +248,14 @@ const SkiPass = ({
195
248
  to: stayTo
196
249
  } : undefined;
197
250
  const skiers = data.skiers?.length > 0 ? data.skiers : undefined;
251
+ const activities = data.activities.length > 0 ? data.activities : undefined;
198
252
  const domains = data.domains.length > 0 ? data.domains : undefined;
199
253
  const durations = data.durations.length > 0 ? data.durations : undefined;
200
254
  const presets = {
201
255
  stay,
202
256
  skiers,
203
257
  firstSkiDate,
258
+ activities,
204
259
  domains,
205
260
  durations
206
261
  };
@@ -250,16 +305,6 @@ const SkiPass = ({
250
305
  }));
251
306
  };
252
307
 
253
- const selectedDomainsIds = filters?.domains.reduce((acc, domain) => {
254
- const {
255
- code,
256
- catalogIds
257
- } = domain;
258
- return data.domains.includes(code) ? [...new Set([...acc, ...catalogIds])] : acc;
259
- }, []);
260
- const filteredDurations = selectedDomainsIds?.length > 0 ? filters?.durations?.filter(duration => duration.catalogIds.some(id => selectedDomainsIds.includes(id))) : filters?.durations;
261
- const selectedDomains = data.domains.map(domain => filters?.domains?.find(d => d.value === domain));
262
- const selectedDurations = data.durations.map(domain => filters?.durations?.find(d => d.value === domain));
263
308
  return _jsxs("div", {
264
309
  className: styles.skiPass,
265
310
  children: [_jsx("div", {
@@ -322,20 +367,27 @@ const SkiPass = ({
322
367
  }), _jsx("div", {
323
368
  className: styles.label,
324
369
  children: messages.filters
370
+ }), activities.length > 1 && _jsx(MutlipleSelect, {
371
+ placeholder: "Selectionnez une ou plusieurs options",
372
+ label: messages.activities,
373
+ options: activities,
374
+ values: selectedActivities,
375
+ onChange: updateFilter("activities")
325
376
  }), _jsxs("div", {
326
377
  className: styles.row,
327
- children: [filters?.domains?.length > 1 && _jsx(MutlipleSelect, {
378
+ children: [filteredDomains.length > 0 && _jsx(MutlipleSelect, {
328
379
  placeholder: "Selectionnez une ou plusieurs options",
329
380
  label: messages.domains,
330
- options: filters.domains,
381
+ options: filteredDomains,
331
382
  values: selectedDomains,
332
383
  onChange: updateFilter("domains")
333
- }), data.domains?.length > 0 && filteredDurations?.length > 1 && _jsx(MutlipleSelect, {
384
+ }), filteredDurations.length > 0 && _jsx(MutlipleSelect, {
334
385
  placeholder: "Selectionnez une ou plusieurs options",
335
386
  label: messages.durations,
336
387
  options: filteredDurations,
337
388
  values: selectedDurations,
338
- onChange: updateFilter("durations")
389
+ onChange: updateFilter("durations"),
390
+ disabled: data.domains?.length === 0
339
391
  })]
340
392
  }), widgetUrl && _jsxs(_Fragment, {
341
393
  children: [_jsx("div", {
@@ -100,6 +100,7 @@
100
100
  var(--cms-primary-color, #004cc2)
101
101
  )
102
102
  );
103
+ font-family: "Open Sans", sans-serif;
103
104
  border-radius: var(--cms-radius-300, 15px);
104
105
  pointer-events: none;
105
106
  touch-action: none;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.0.22",
3
+ "version": "1.0.25",
4
4
  "peerDependencies": {
5
+ "dt-design-system": "^2.0.0",
6
+ "next": "^12.0.0",
5
7
  "react": "^18.2.0",
6
8
  "react-dom": "^18.2.0",
7
- "dt-design-system": "^2.0.0",
8
9
  "ublo": "^2.0.0"
9
10
  },
10
11
  "dependencies": {
@@ -31,6 +32,7 @@
31
32
  "eslint-plugin-promise": "^6.0.1",
32
33
  "eslint-plugin-react": "^7.31.7",
33
34
  "eslint-plugin-react-hooks": "^4.6.0",
35
+ "next": "^12.0.0",
34
36
  "react": "^18.2.0",
35
37
  "react-dom": "^18.2.0",
36
38
  "react-scripts": "5.0.1",