ublo-lib 1.17.7 → 1.18.0
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/common/components/editable-calendar/calendar.js +3 -2
- package/es/esf/components/{instructors-book-v2 → instructors-book}/api.js +12 -8
- package/es/esf/components/{instructors-book-v2 → instructors-book}/book.js +1 -1
- package/es/esf/components/{instructors-book-v2 → instructors-book}/filters.js +2 -2
- package/es/esf/components/instructors-book/index.js +6 -3
- package/es/esf/components/{instructors-book-v2 → instructors-book}/instructor.js +6 -6
- package/es/esf/components/instructors-book/list.js +39 -170
- package/es/esf/components/instructors-book/messages.js +36 -37
- package/es/esf/components/{instructors-book-v2 → instructors-book}/sheet.js +17 -17
- package/es/esf/components/instructors-book/utils.js +48 -2
- package/package.json +1 -1
- package/es/esf/components/instructor-suggestions/fetcher.js +0 -16
- package/es/esf/components/instructor-suggestions/icons.js +0 -266
- package/es/esf/components/instructor-suggestions/index.js +0 -2
- package/es/esf/components/instructor-suggestions/instructor-suggestions.js +0 -180
- package/es/esf/components/instructor-suggestions/loader.js +0 -8
- package/es/esf/components/instructor-suggestions/messages.js +0 -16
- package/es/esf/components/instructors-book/container.js +0 -18
- package/es/esf/components/instructors-book/details.js +0 -117
- package/es/esf/components/instructors-book/icons.js +0 -266
- package/es/esf/components/instructors-book/inner.js +0 -15
- package/es/esf/components/instructors-book/instructors-book.js +0 -111
- package/es/esf/components/instructors-book/link.js +0 -17
- package/es/esf/components/instructors-book/list-utils.js +0 -18
- package/es/esf/components/instructors-book/loader.js +0 -8
- package/es/esf/components/instructors-book-v2/index.js +0 -6
- package/es/esf/components/instructors-book-v2/list.js +0 -47
- package/es/esf/components/instructors-book-v2/messages.js +0 -41
- package/es/esf/components/instructors-book-v2/utils.js +0 -51
- /package/es/esf/components/{instructors-book-v2 → instructors-book}/book.module.css +0 -0
- /package/es/esf/components/{instructors-book-v2 → instructors-book}/filters.module.css +0 -0
- /package/es/esf/components/{instructors-book-v2 → instructors-book}/flags.js +0 -0
- /package/es/esf/components/{instructors-book-v2 → instructors-book}/instructor.module.css +0 -0
- /package/es/esf/components/{instructors-book-v2 → instructors-book}/list.module.css +0 -0
- /package/es/esf/components/{instructors-book-v2 → instructors-book}/prefixes.js +0 -0
- /package/es/esf/components/{instructors-book-v2 → instructors-book}/sheet.module.css +0 -0
- /package/es/esf/components/{instructors-book-v2 → instructors-book}/suggestions.js +0 -0
- /package/es/esf/components/{instructors-book-v2 → instructors-book}/suggestions.module.css +0 -0
|
@@ -23,8 +23,9 @@ function Calendar({
|
|
|
23
23
|
const now = new Date();
|
|
24
24
|
const minDate = now;
|
|
25
25
|
if (minDate) minDate.setHours(0, 0, 0, 0);
|
|
26
|
-
const
|
|
27
|
-
const
|
|
26
|
+
const currentMonth = Data.THIS_MONTH;
|
|
27
|
+
const presetMonth = getMonthFromPresets(presets?.dates);
|
|
28
|
+
const defaultMonth = currentMonth > presetMonth ? currentMonth : presetMonth;
|
|
28
29
|
const currentYear = Data.THIS_YEAR;
|
|
29
30
|
const [month, setMonth] = React.useState(currentMonth);
|
|
30
31
|
const [year, setYear] = React.useState(currentYear);
|
|
@@ -5,15 +5,16 @@ const {
|
|
|
5
5
|
const {
|
|
6
6
|
resort
|
|
7
7
|
} = publicRuntimeConfig;
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const carnetRougeApi = "https://services.carnet-rouge-esf.app/api";
|
|
9
|
+
const authorizationCarnetRouge = "6bdecf9053927dcc7e10923a2cc603a4";
|
|
10
10
|
const fetcher = async (url, body) => {
|
|
11
11
|
const res = await fetch(url, {
|
|
12
12
|
method: "POST",
|
|
13
13
|
headers: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
...(body ? {
|
|
15
|
+
"content-type": "application/json;charset=utf-8"
|
|
16
|
+
} : {}),
|
|
17
|
+
Authorization: authorizationCarnetRouge
|
|
17
18
|
},
|
|
18
19
|
body: body ? JSON.stringify(body) : undefined
|
|
19
20
|
});
|
|
@@ -21,7 +22,8 @@ const fetcher = async (url, body) => {
|
|
|
21
22
|
};
|
|
22
23
|
export async function fetchInstructors(lang, body = {}) {
|
|
23
24
|
try {
|
|
24
|
-
|
|
25
|
+
const url = `${carnetRougeApi}/annuaire/public/moniteurs/${resort}/${lang}`;
|
|
26
|
+
return fetcher(url, {
|
|
25
27
|
...body,
|
|
26
28
|
project: true
|
|
27
29
|
});
|
|
@@ -32,7 +34,8 @@ export async function fetchInstructors(lang, body = {}) {
|
|
|
32
34
|
}
|
|
33
35
|
export async function fetchInstructor(lang, uri) {
|
|
34
36
|
try {
|
|
35
|
-
|
|
37
|
+
const url = `${carnetRougeApi}/annuaire/public/moniteur/${resort}/${lang}/${uri}`;
|
|
38
|
+
return fetcher(url);
|
|
36
39
|
} catch (e) {
|
|
37
40
|
console.warn(e);
|
|
38
41
|
return {};
|
|
@@ -40,7 +43,8 @@ export async function fetchInstructor(lang, uri) {
|
|
|
40
43
|
}
|
|
41
44
|
export const fetchRandomInstructors = async (lang, tags, nbInstructor) => {
|
|
42
45
|
try {
|
|
43
|
-
|
|
46
|
+
const url = `${carnetRougeApi}/annuaire/public/moniteurs/${resort}/${lang}/by-tags`;
|
|
47
|
+
return fetcher(url, {
|
|
44
48
|
tags,
|
|
45
49
|
size: nbInstructor
|
|
46
50
|
});
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as API from "./api";
|
|
2
|
+
import Book from "./book";
|
|
3
|
+
import Sheet from "./sheet";
|
|
4
|
+
import Suggestions from "./suggestions";
|
|
5
|
+
import prefixes from "./prefixes";
|
|
6
|
+
export { Book, Sheet, Suggestions, API, prefixes };
|
|
@@ -22,8 +22,8 @@ export default function Instructor({
|
|
|
22
22
|
lang
|
|
23
23
|
} = useUbloContext();
|
|
24
24
|
const {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
prenom,
|
|
26
|
+
nom,
|
|
27
27
|
photo,
|
|
28
28
|
uri
|
|
29
29
|
} = instructor;
|
|
@@ -66,7 +66,7 @@ export default function Instructor({
|
|
|
66
66
|
loading: "lazy",
|
|
67
67
|
src: picture,
|
|
68
68
|
className: css.imageBackground,
|
|
69
|
-
alt: `${
|
|
69
|
+
alt: `${prenom} ${nom}`,
|
|
70
70
|
width: "170",
|
|
71
71
|
height: "220"
|
|
72
72
|
}), picture ? _jsxs(_Fragment, {
|
|
@@ -76,7 +76,7 @@ export default function Instructor({
|
|
|
76
76
|
loading: "lazy",
|
|
77
77
|
src: picture,
|
|
78
78
|
className: css.image,
|
|
79
|
-
alt: `${
|
|
79
|
+
alt: `${prenom} ${nom}`,
|
|
80
80
|
onLoad: stopLoading,
|
|
81
81
|
onError: setFallbackPicture,
|
|
82
82
|
width: "170",
|
|
@@ -94,10 +94,10 @@ export default function Instructor({
|
|
|
94
94
|
className: css.name,
|
|
95
95
|
children: [_jsxs("span", {
|
|
96
96
|
className: css.firstName,
|
|
97
|
-
children: [Utils.formatNames(
|
|
97
|
+
children: [Utils.formatNames(prenom), " "]
|
|
98
98
|
}), _jsx("span", {
|
|
99
99
|
className: css.lastName,
|
|
100
|
-
children: Utils.formatNames(
|
|
100
|
+
children: Utils.formatNames(nom)
|
|
101
101
|
})]
|
|
102
102
|
})
|
|
103
103
|
})]
|
|
@@ -1,178 +1,47 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { filter } from "./list-utils";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { useUbloContext } from "ublo/with-ublo";
|
|
4
|
+
import * as Utils from "./utils";
|
|
5
|
+
import Instructor from "./instructor";
|
|
6
|
+
import { message } from "./messages";
|
|
7
|
+
import css from "./list.module.css";
|
|
9
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export default function List({
|
|
11
|
+
search = "",
|
|
13
12
|
instructors,
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
fromSuggestions,
|
|
14
|
+
formSendFunction,
|
|
15
|
+
formFields,
|
|
16
16
|
trombi,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const displayedInstructors = filter(instructors, search);
|
|
28
|
-
setDisplayedInstructors(displayedInstructors);
|
|
29
|
-
}, [instructors, search]);
|
|
30
|
-
const changeFilter = filter => e => {
|
|
31
|
-
if (selectFilter !== undefined) {
|
|
32
|
-
selectFilter(filter, e.target.value);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const renderHeader = () => {
|
|
36
|
-
return _jsxs("div", {
|
|
37
|
-
className: "instructors-book-list__top",
|
|
38
|
-
children: [_jsxs("div", {
|
|
39
|
-
className: "instructors-book-list__top-left",
|
|
40
|
-
children: [_jsx("h2", {
|
|
41
|
-
className: "instructors-book-list__title",
|
|
42
|
-
children: texts["instructors-book-title-1"]
|
|
43
|
-
}), _jsx("div", {
|
|
44
|
-
className: "instructors-book-list__tagline",
|
|
45
|
-
children: texts["instructors-book-title-2"]
|
|
46
|
-
}), _jsx("div", {
|
|
47
|
-
className: "instructors-book-list__helper",
|
|
48
|
-
children: texts["instructors-book-intro"]
|
|
49
|
-
})]
|
|
50
|
-
}), _jsxs("div", {
|
|
51
|
-
className: "instructors-book-list__filters",
|
|
52
|
-
children: [_jsxs("div", {
|
|
53
|
-
className: "instructors-book-list__filters-title",
|
|
54
|
-
children: [texts["instructors-book-search-1"], " ", _jsx("span", {
|
|
55
|
-
className: "instructors-book-list__filters-title-span",
|
|
56
|
-
children: texts["instructors-book-search-2"]
|
|
57
|
-
})]
|
|
58
|
-
}), _jsx("div", {
|
|
59
|
-
className: "instructors-book-list__input-filler",
|
|
60
|
-
children: _jsx("input", {
|
|
61
|
-
value: search,
|
|
62
|
-
className: "instructors-book-list__input",
|
|
63
|
-
placeholder: texts["instructors-book-placeholder-search"],
|
|
64
|
-
onChange: e => setSearch(e.target.value.toLowerCase())
|
|
65
|
-
})
|
|
66
|
-
}), _jsx("label", {
|
|
67
|
-
htmlFor: "instructors-book-practice-filter",
|
|
68
|
-
className: "instructors-book-list__label",
|
|
69
|
-
children: texts["instructors-book-filter-activity"]
|
|
70
|
-
}), _jsx("div", {
|
|
71
|
-
className: "instructors-book-list__input-filler instructors-book-list__input-filler--select",
|
|
72
|
-
children: _jsxs("select", {
|
|
73
|
-
value: activity,
|
|
74
|
-
id: "instructors-book-practice-filter",
|
|
75
|
-
className: "instructors-book-list__input instructors-book-list__input--select",
|
|
76
|
-
onChange: changeFilter("activity"),
|
|
77
|
-
children: [_jsx("option", {
|
|
78
|
-
value: "",
|
|
79
|
-
children: texts["instructors-book-placeholder-activity"]
|
|
80
|
-
}), activities && activities.map(({
|
|
81
|
-
code,
|
|
82
|
-
label
|
|
83
|
-
}) => _jsx("option", {
|
|
84
|
-
value: code,
|
|
85
|
-
children: label
|
|
86
|
-
}, code))]
|
|
87
|
-
})
|
|
88
|
-
}), _jsx("label", {
|
|
89
|
-
htmlFor: "instructors-book-language-filter",
|
|
90
|
-
className: "instructors-book-list__label",
|
|
91
|
-
children: texts["instructors-book-filter-language"]
|
|
92
|
-
}), _jsx("div", {
|
|
93
|
-
className: "instructors-book-list__input-filler instructors-book-list__input-filler--select",
|
|
94
|
-
children: _jsxs("select", {
|
|
95
|
-
value: language,
|
|
96
|
-
id: "instructors-book-language-filter",
|
|
97
|
-
className: "instructors-book-list__input instructors-book-list__input--select",
|
|
98
|
-
onChange: changeFilter("language"),
|
|
99
|
-
children: [_jsx("option", {
|
|
100
|
-
value: "",
|
|
101
|
-
children: texts["instructors-book-placeholder-language"]
|
|
102
|
-
}), languages && languages.map(({
|
|
103
|
-
code,
|
|
104
|
-
label
|
|
105
|
-
}) => _jsx("option", {
|
|
106
|
-
value: code,
|
|
107
|
-
children: label
|
|
108
|
-
}, code))]
|
|
109
|
-
})
|
|
110
|
-
})]
|
|
111
|
-
})]
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
const renderInstructor = (instructor, index) => {
|
|
115
|
-
const {
|
|
116
|
-
firstname,
|
|
117
|
-
lastname,
|
|
118
|
-
photo,
|
|
119
|
-
activities,
|
|
120
|
-
languages,
|
|
121
|
-
uri
|
|
122
|
-
} = instructor;
|
|
123
|
-
return _jsxs(Container, {
|
|
124
|
-
trombi: trombi,
|
|
125
|
-
className: "instructors-book-list__instructor",
|
|
126
|
-
...selectInstructor(uri),
|
|
127
|
-
children: [_jsxs("div", {
|
|
128
|
-
className: "instructors-book-list__instructor-image-container",
|
|
129
|
-
children: [!trombi && _jsx("div", {
|
|
130
|
-
className: "instructors-book-list__instructor-overlay",
|
|
131
|
-
children: _jsx(OverlayIcon, {
|
|
132
|
-
className: "instructors-book-list__instructor-overlay-icon"
|
|
133
|
-
})
|
|
134
|
-
}), photo ? _jsx("img", {
|
|
135
|
-
loading: "lazy",
|
|
136
|
-
src: photo,
|
|
137
|
-
className: "instructors-book-list__instructor-image",
|
|
138
|
-
alt: `${firstname} ${lastname}`
|
|
139
|
-
}) : _jsx(PersonIcon, {
|
|
140
|
-
className: "instructors-book-list__instructor-imageplaceholder"
|
|
141
|
-
})]
|
|
142
|
-
}), _jsxs("div", {
|
|
143
|
-
className: "instructors-book-list__instructor-name",
|
|
144
|
-
children: [formatNames(firstname), " ", _jsx("span", {
|
|
145
|
-
className: "instructors-book-list__instructor-lastname",
|
|
146
|
-
children: formatNames(lastname)
|
|
147
|
-
})]
|
|
148
|
-
}), trombi && _jsxs(_Fragment, {
|
|
149
|
-
children: [_jsx("div", {
|
|
150
|
-
className: "instructors-book-list__instructor-practices",
|
|
151
|
-
children: activities && activities.map(({
|
|
152
|
-
label
|
|
153
|
-
}) => label).join(" - ")
|
|
154
|
-
}), _jsx("div", {
|
|
155
|
-
className: "instructors-book-list__instructor-langs",
|
|
156
|
-
children: languages && languages.map(({
|
|
157
|
-
code,
|
|
158
|
-
label
|
|
159
|
-
}) => {
|
|
160
|
-
const Flag = flags[code];
|
|
161
|
-
return _jsx(Flag, {
|
|
162
|
-
className: "instructors-book-list__instructor-lang",
|
|
163
|
-
title: label
|
|
164
|
-
}, code);
|
|
165
|
-
})
|
|
166
|
-
})]
|
|
167
|
-
})]
|
|
168
|
-
}, uri || `instructor-${index}`);
|
|
169
|
-
};
|
|
17
|
+
popup
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
lang
|
|
21
|
+
} = useUbloContext();
|
|
22
|
+
const displayedInstructors = fromSuggestions ? instructors : Utils.filter(instructors, search);
|
|
23
|
+
const listCountMessageCode = displayedInstructors?.length > 1 ? "instructors" : "instructor";
|
|
24
|
+
const classes = classNames(css.container, {
|
|
25
|
+
[css.containerSuggestions]: fromSuggestions
|
|
26
|
+
});
|
|
170
27
|
return _jsxs("div", {
|
|
171
|
-
className:
|
|
172
|
-
children: [
|
|
173
|
-
className:
|
|
174
|
-
children:
|
|
28
|
+
className: classes,
|
|
29
|
+
children: [!fromSuggestions && _jsxs("div", {
|
|
30
|
+
className: css.listCount,
|
|
31
|
+
children: [_jsx("b", {
|
|
32
|
+
children: displayedInstructors.length
|
|
33
|
+
}), " ", message(lang, listCountMessageCode)]
|
|
34
|
+
}), _jsx("div", {
|
|
35
|
+
className: css.inner,
|
|
36
|
+
children: displayedInstructors?.map(instructor => {
|
|
37
|
+
return _jsx(Instructor, {
|
|
38
|
+
instructor: instructor,
|
|
39
|
+
trombi: trombi,
|
|
40
|
+
formFields: formFields,
|
|
41
|
+
formSendFunction: formSendFunction,
|
|
42
|
+
popup: popup
|
|
43
|
+
}, instructor.uri);
|
|
44
|
+
})
|
|
175
45
|
})]
|
|
176
46
|
});
|
|
177
|
-
}
|
|
178
|
-
export default List;
|
|
47
|
+
}
|
|
@@ -1,42 +1,41 @@
|
|
|
1
|
-
const
|
|
1
|
+
const locales = {
|
|
2
2
|
fr: {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
3
|
+
"search-label": "Chercher un moniteur",
|
|
4
|
+
"search-placeholder": "Nom, prénom...",
|
|
5
|
+
"activity-label": "Quelle pratique ?",
|
|
6
|
+
"language-label": "Quelle langue ?",
|
|
7
|
+
instructors: "moniteurs trouvés",
|
|
8
|
+
instructor: "moniteur trouvé",
|
|
9
|
+
activities: "Activités pratiquées",
|
|
10
|
+
and: "et",
|
|
11
|
+
languages: "Langues parlées",
|
|
12
|
+
about: "À propos",
|
|
13
|
+
contact: "Quand souhaitez-vous skier avec moi ?",
|
|
14
|
+
"suggestions-title": "Les moniteurs qui vous proposent ce cours",
|
|
15
|
+
"suggestions-button": "Voir tous les moniteurs",
|
|
16
|
+
"see-more": "Voir plus",
|
|
17
|
+
"go-back": "Retour"
|
|
17
18
|
},
|
|
18
19
|
en: {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
20
|
+
"search-label": "Search an instructor",
|
|
21
|
+
"search-placeholder": "Lastname, firstname...",
|
|
22
|
+
"activity-label": "Which activity?",
|
|
23
|
+
"language-label": "Which language?",
|
|
24
|
+
instructors: "instructors found",
|
|
25
|
+
instructor: "instructor found",
|
|
26
|
+
activities: "Activities",
|
|
27
|
+
and: "and",
|
|
28
|
+
languages: "Spoken languages",
|
|
29
|
+
about: "About",
|
|
30
|
+
contact: "When would you like to ski with me?",
|
|
31
|
+
"suggestions-title": "The instructors who offer you this course",
|
|
32
|
+
"suggestions-button": "See all instructors",
|
|
33
|
+
"see-more": "See more",
|
|
34
|
+
"go-back": "Go back"
|
|
33
35
|
}
|
|
34
36
|
};
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
export default getMessage;
|
|
37
|
+
export const message = (lang, id) => {
|
|
38
|
+
const locale = lang === "fr" ? "fr" : "en";
|
|
39
|
+
const messages = locales[locale];
|
|
40
|
+
return messages[id] || `??${id}??`;
|
|
41
|
+
};
|
|
@@ -21,11 +21,11 @@ export default function Sheet({
|
|
|
21
21
|
bookUrl
|
|
22
22
|
}) {
|
|
23
23
|
const {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
prenom,
|
|
25
|
+
nom,
|
|
26
26
|
photo,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
langues,
|
|
28
|
+
disciplines,
|
|
29
29
|
introduction,
|
|
30
30
|
description,
|
|
31
31
|
uri
|
|
@@ -65,7 +65,7 @@ export default function Sheet({
|
|
|
65
65
|
loading: "lazy",
|
|
66
66
|
src: picture,
|
|
67
67
|
className: css.imageBackground,
|
|
68
|
-
alt: `${
|
|
68
|
+
alt: `${prenom} ${nom}`,
|
|
69
69
|
width: "170",
|
|
70
70
|
height: "220"
|
|
71
71
|
}), picture ? _jsxs(_Fragment, {
|
|
@@ -75,7 +75,7 @@ export default function Sheet({
|
|
|
75
75
|
loading: "lazy",
|
|
76
76
|
src: picture,
|
|
77
77
|
className: css.image,
|
|
78
|
-
alt: `${
|
|
78
|
+
alt: `${prenom} ${nom}`,
|
|
79
79
|
onLoad: stopLoading,
|
|
80
80
|
onError: setFallbackPicture,
|
|
81
81
|
width: "190",
|
|
@@ -93,24 +93,24 @@ export default function Sheet({
|
|
|
93
93
|
className: css.name,
|
|
94
94
|
children: [_jsxs("span", {
|
|
95
95
|
className: css.firstName,
|
|
96
|
-
children: [Utils.formatNames(
|
|
96
|
+
children: [Utils.formatNames(prenom), " "]
|
|
97
97
|
}), _jsx("span", {
|
|
98
98
|
className: css.lastName,
|
|
99
|
-
children: Utils.formatNames(
|
|
99
|
+
children: Utils.formatNames(nom)
|
|
100
100
|
})]
|
|
101
|
-
}),
|
|
101
|
+
}), disciplines && _jsxs("div", {
|
|
102
102
|
className: css.activities,
|
|
103
103
|
children: [_jsx("div", {
|
|
104
104
|
className: css.activitiesTitle,
|
|
105
105
|
children: message(lang, "activities")
|
|
106
106
|
}), _jsx("div", {
|
|
107
107
|
className: css.activitiesList,
|
|
108
|
-
children:
|
|
108
|
+
children: disciplines.map((discipline, i) => {
|
|
109
109
|
const {
|
|
110
110
|
code,
|
|
111
111
|
label
|
|
112
|
-
} =
|
|
113
|
-
const length =
|
|
112
|
+
} = discipline;
|
|
113
|
+
const length = disciplines.length;
|
|
114
114
|
return _jsxs("span", {
|
|
115
115
|
className: css.activity,
|
|
116
116
|
children: [_jsx("span", {
|
|
@@ -119,19 +119,19 @@ export default function Sheet({
|
|
|
119
119
|
}, code);
|
|
120
120
|
})
|
|
121
121
|
})]
|
|
122
|
-
}),
|
|
122
|
+
}), langues && _jsxs("div", {
|
|
123
123
|
className: css.languages,
|
|
124
124
|
children: [_jsx("div", {
|
|
125
125
|
className: css.languagesTitle,
|
|
126
126
|
children: message(lang, "languages")
|
|
127
127
|
}), _jsx("div", {
|
|
128
128
|
className: css.languagesList,
|
|
129
|
-
children:
|
|
129
|
+
children: langues.map((langue, i) => {
|
|
130
130
|
const {
|
|
131
131
|
code,
|
|
132
132
|
label
|
|
133
|
-
} =
|
|
134
|
-
const length =
|
|
133
|
+
} = langue;
|
|
134
|
+
const length = langues.length;
|
|
135
135
|
return _jsxs("span", {
|
|
136
136
|
className: css.language,
|
|
137
137
|
children: [label, " ", i < length - 1 ? " - " : ""]
|
|
@@ -171,7 +171,7 @@ export default function Sheet({
|
|
|
171
171
|
fields: formFields,
|
|
172
172
|
className: css.form,
|
|
173
173
|
innerClassName: css.formInner,
|
|
174
|
-
customSend: formSendFunction(
|
|
174
|
+
customSend: formSendFunction(prenom, nom)
|
|
175
175
|
})]
|
|
176
176
|
})]
|
|
177
177
|
});
|
|
@@ -1,5 +1,51 @@
|
|
|
1
|
+
const SLASH = "/";
|
|
2
|
+
export function truncate(input, lenght = 140) {
|
|
3
|
+
return input.length > lenght ? `${input.substring(0, lenght)}...` : input;
|
|
4
|
+
}
|
|
5
|
+
export function sanitizeHTML(text) {
|
|
6
|
+
const element = document.createElement("div");
|
|
7
|
+
element.innerHTML = text;
|
|
8
|
+
return element.textContent;
|
|
9
|
+
}
|
|
10
|
+
export function propsFromQueryString() {
|
|
11
|
+
if (typeof window === "undefined") return {};
|
|
12
|
+
const params = new URLSearchParams(document.location.search);
|
|
13
|
+
const activity = params.get("activity") || undefined;
|
|
14
|
+
const language = params.get("language") || undefined;
|
|
15
|
+
return {
|
|
16
|
+
activity,
|
|
17
|
+
language
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function hasTrailingSlash(path) {
|
|
21
|
+
return path.length > 1 && path.endsWith(SLASH);
|
|
22
|
+
}
|
|
1
23
|
export const formatNames = name => {
|
|
2
24
|
const lowercasedName = name && name.toLowerCase();
|
|
3
|
-
return lowercasedName.charAt(0).toUpperCase() + lowercasedName.slice(1);
|
|
25
|
+
return lowercasedName ? lowercasedName.charAt(0).toUpperCase() + lowercasedName.slice(1) : "";
|
|
4
26
|
};
|
|
5
|
-
export
|
|
27
|
+
export function includesString(source, included) {
|
|
28
|
+
source.toLowerCase().includes(included.toLowerCase());
|
|
29
|
+
}
|
|
30
|
+
function strStartWith(str1, str2) {
|
|
31
|
+
return str1.toLowerCase().trim().startsWith(str2.toLowerCase().trim());
|
|
32
|
+
}
|
|
33
|
+
function strEquals(str1, str2) {
|
|
34
|
+
return str1.toLowerCase().trim() === str2.toLowerCase().trim();
|
|
35
|
+
}
|
|
36
|
+
function match(searchingArray, entries) {
|
|
37
|
+
return searchingArray.reduce((acc, str, index) => {
|
|
38
|
+
const matched = index === searchingArray.length - 1 ? strStartWith : strEquals;
|
|
39
|
+
return acc && entries.some(entry => matched(entry, str));
|
|
40
|
+
}, true);
|
|
41
|
+
}
|
|
42
|
+
export function filter(array, search = "") {
|
|
43
|
+
const searchingArray = search.split(" ");
|
|
44
|
+
const filtered = array.all ? array.all.filter(uri => {
|
|
45
|
+
const instructor = array.byUri[uri];
|
|
46
|
+
const firstnameWords = instructor.prenom.split(" ");
|
|
47
|
+
const lastnameWords = instructor.nom.split(" ");
|
|
48
|
+
return match(searchingArray, [...firstnameWords, ...lastnameWords]);
|
|
49
|
+
}) : [];
|
|
50
|
+
return filtered.reduce((acc, uri) => [...acc, array.byUri[uri]], []);
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const buildHost = env => env === "dev" ? "http://localhost:9002" : env === "uat" ? "https://instructors-book-server-uat.carnet-rouge-esf.com" : "https://instructors-book-server.carnet-rouge-esf.com";
|
|
2
|
-
export const fetchRandomInstructors = async (school, lang, tags, nbInstructor, env) => {
|
|
3
|
-
const res = await fetch(`${buildHost(env)}/api/instructors-book/${school}/${lang}/byTags`, {
|
|
4
|
-
method: "POST",
|
|
5
|
-
headers: {
|
|
6
|
-
"content-type": "application/json;charset=utf-8",
|
|
7
|
-
Authorization: "00q2qa545018261l252gg3414t3qa2",
|
|
8
|
-
schoolcode: school
|
|
9
|
-
},
|
|
10
|
-
body: JSON.stringify({
|
|
11
|
-
tags,
|
|
12
|
-
size: nbInstructor
|
|
13
|
-
})
|
|
14
|
-
});
|
|
15
|
-
return res.json();
|
|
16
|
-
};
|