ublo-lib 1.0.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/admin-links/admin-links.js +107 -0
- package/es/common/components/admin-links/admin-links.module.css +85 -0
- package/es/common/components/admin-links/index.js +2 -0
- package/es/common/components/analytics.js +46 -0
- package/es/common/components/breadcrumb.js +69 -0
- package/es/common/components/carousel-zone.js +61 -0
- package/es/common/components/carousel.js +365 -0
- package/es/common/components/cookie-consent/cookie-consent.js +111 -0
- package/es/common/components/cookie-consent/cookie-consent.module.css +103 -0
- package/es/common/components/cookie-consent/index.js +3 -0
- package/es/common/components/cookie-consent/messages.js +31 -0
- package/es/common/components/custom-contact-form/attachment.js +229 -0
- package/es/common/components/custom-contact-form/attachment.module.css +211 -0
- package/es/common/components/custom-contact-form/custom-contact-form.js +168 -0
- package/es/common/components/custom-contact-form/field.js +294 -0
- package/es/common/components/custom-contact-form/field.module.css +17 -0
- package/es/common/components/custom-contact-form/icons.js +55 -0
- package/es/common/components/custom-contact-form/index.js +2 -0
- package/es/common/components/custom-contact-form/index.module.css +119 -0
- package/es/common/components/custom-contact-form/messages.js +79 -0
- package/es/common/components/custom-contact-form/utils.js +132 -0
- package/es/common/components/date-picker/calendar.js +246 -0
- package/es/common/components/date-picker/calendar.module.css +123 -0
- package/es/common/components/date-picker/data.js +96 -0
- package/es/common/components/date-picker/date-item.js +127 -0
- package/es/common/components/date-picker/date-item.module.css +78 -0
- package/es/common/components/date-picker/date-picker.js +119 -0
- package/es/common/components/date-picker/date-picker.module.css +111 -0
- package/es/common/components/date-picker/helper.js +41 -0
- package/es/common/components/date-picker/helper.module.css +81 -0
- package/es/common/components/date-picker/index.js +3 -0
- package/es/common/components/date-picker/messages.js +34 -0
- package/es/common/components/date-picker/modes.js +42 -0
- package/es/common/components/date-picker/modes.module.css +90 -0
- package/es/common/components/date-picker/month.js +78 -0
- package/es/common/components/date-picker/month.module.css +54 -0
- package/es/common/components/date-picker/utils.js +121 -0
- package/es/common/components/error-404/error-404.js +51 -0
- package/es/common/components/error-404/error-404.module.css +55 -0
- package/es/common/components/error-404/index.js +2 -0
- package/es/common/components/error-404/messages.js +29 -0
- package/es/common/components/faq.js +54 -0
- package/es/common/components/info-buttons.js +116 -0
- package/es/common/components/plausible/hooks/use-plausible.js +33 -0
- package/es/common/components/plausible/index.js +7 -0
- package/es/common/components/plausible/plausible.js +20 -0
- package/es/common/components/plausible/services/callback.js +63 -0
- package/es/common/components/plausible/services/load.js +7 -0
- package/es/common/components/plausible/services/send-goal.js +10 -0
- package/es/common/components/popup.js +90 -0
- package/es/common/components/scroll-spy.js +53 -0
- package/es/common/components/tabbed-zones.js +110 -0
- package/es/common/components/unsupported-browser.js +158 -0
- package/es/common/components/video-player/controls.js +125 -0
- package/es/common/components/video-player/icons.js +45 -0
- package/es/common/components/video-player/index.js +1 -0
- package/es/common/components/video-player/player.module.css +151 -0
- package/es/common/components/video-player/utils.js +43 -0
- package/es/common/components/video-player/video-player.js +111 -0
- package/es/common/hooks/use-faq.js +44 -0
- package/es/common/hooks/use-in-view.js +73 -0
- package/es/common/hooks/use-injected-cms-markup.js +50 -0
- package/es/common/hooks/use-packages.js +127 -0
- package/es/common/hooks/use-scroll-direction.js +44 -0
- package/es/common/hooks/use-stay.js +32 -0
- package/es/common/hooks/use-sticky.js +38 -0
- package/es/common/hooks/use-tunnel.js +50 -0
- package/es/common/hooks/use-window-sizes.js +37 -0
- package/es/common/hooks/use-youtube-popup.js +62 -0
- package/es/common/hooks/use-zone-sync.js +65 -0
- package/es/common/utils/cookies.js +13 -0
- package/es/common/utils/copy.js +11 -0
- package/es/common/utils/dates.js +8 -0
- package/es/common/utils/events.js +25 -0
- package/es/common/utils/fetcher.js +37 -0
- package/es/common/utils/file-manager.js +14 -0
- package/es/common/utils/load-js.js +11 -0
- package/es/common/utils/msem-widget.js +16 -0
- package/es/common/utils/touch-device.js +1 -0
- package/es/common/utils/url-parameters.js +12 -0
- package/es/empty.d.ts +4 -0
- package/es/empty.d.ts.map +1 -0
- package/es/empty.js +6 -0
- package/es/esf/components/booking-form/data.js +213 -0
- package/es/esf/components/booking-form/field.js +140 -0
- package/es/esf/components/booking-form/hooks/use-custom-fields.js +20 -0
- package/es/esf/components/booking-form/hooks/use-stay.js +12 -0
- package/es/esf/components/booking-form/icons.js +50 -0
- package/es/esf/components/booking-form/index.js +78 -0
- package/es/esf/components/booking-form/lesson.js +59 -0
- package/es/esf/components/booking-form/lessons.js +93 -0
- package/es/esf/components/booking-form/messages.js +52 -0
- package/es/esf/components/booking-form/personal-data.js +73 -0
- package/es/esf/components/booking-form/progress-bar.js +35 -0
- package/es/esf/components/booking-form/response.js +42 -0
- package/es/esf/components/booking-form/steps.js +81 -0
- package/es/esf/components/booking-form/summary.js +138 -0
- package/es/esf/components/booking-form/utils.js +72 -0
- package/es/esf/components/contact-form/api.js +36 -0
- package/es/esf/components/contact-form/contact-form.js +293 -0
- package/es/esf/components/contact-form/contact-form.module.css +51 -0
- package/es/esf/components/contact-form/data.js +53 -0
- package/es/esf/components/contact-form/index.js +2 -0
- package/es/esf/components/contact-form/messages.js +75 -0
- package/es/esf/components/contact-form/validation.js +63 -0
- package/es/esf/components/covid-link/index.js +119 -0
- package/es/esf/components/covid-link/index.module.css +108 -0
- package/es/esf/components/covid-link/mask-icon.js +17 -0
- package/es/esf/components/covid-link/vax-pass-icon.js +34 -0
- package/es/esf/components/cp-form.js +65 -0
- package/es/esf/components/instructor-suggestions/fetcher.js +17 -0
- package/es/esf/components/instructor-suggestions/icons.js +266 -0
- package/es/esf/components/instructor-suggestions/index.js +181 -0
- package/es/esf/components/instructor-suggestions/loader.js +10 -0
- package/es/esf/components/instructor-suggestions/messages.js +16 -0
- package/es/esf/components/instructors-book/container.js +18 -0
- package/es/esf/components/instructors-book/details.js +120 -0
- package/es/esf/components/instructors-book/icons.js +266 -0
- package/es/esf/components/instructors-book/index.js +15 -0
- package/es/esf/components/instructors-book/link.js +17 -0
- package/es/esf/components/instructors-book/list-utils.js +21 -0
- package/es/esf/components/instructors-book/list.js +184 -0
- package/es/esf/components/instructors-book/loader.js +10 -0
- package/es/esf/components/instructors-book/messages.js +44 -0
- package/es/esf/components/instructors-book/utils.js +5 -0
- package/es/esf/components/levels.js +265 -0
- package/es/esf/components/loyal-customers/api.js +24 -0
- package/es/esf/components/loyal-customers/components/bin-icon.js +31 -0
- package/es/esf/components/loyal-customers/components/bin-icon.module.css +9 -0
- package/es/esf/components/loyal-customers/components/customer-form.js +105 -0
- package/es/esf/components/loyal-customers/components/customer-form.module.css +40 -0
- package/es/esf/components/loyal-customers/components/field.js +119 -0
- package/es/esf/components/loyal-customers/components/field.module.css +3 -0
- package/es/esf/components/loyal-customers/components/row.js +77 -0
- package/es/esf/components/loyal-customers/components/row.module.css +95 -0
- package/es/esf/components/loyal-customers/components/rows.js +38 -0
- package/es/esf/components/loyal-customers/components/rows.module.css +11 -0
- package/es/esf/components/loyal-customers/components/stay.js +37 -0
- package/es/esf/components/loyal-customers/components/stay.module.css +18 -0
- package/es/esf/components/loyal-customers/components/student-form.js +105 -0
- package/es/esf/components/loyal-customers/components/student-form.module.css +68 -0
- package/es/esf/components/loyal-customers/components/voucher.js +26 -0
- package/es/esf/components/loyal-customers/components/voucher.module.css +7 -0
- package/es/esf/components/loyal-customers/content.js +55 -0
- package/es/esf/components/loyal-customers/data.js +131 -0
- package/es/esf/components/loyal-customers/hooks/use-stored-rows.js +14 -0
- package/es/esf/components/loyal-customers/index.js +2 -0
- package/es/esf/components/loyal-customers/loyal-customers.js +141 -0
- package/es/esf/components/loyal-customers/loyal-customers.module.css +62 -0
- package/es/esf/components/loyal-customers/messages.js +59 -0
- package/es/esf/components/loyal-customers/utils.js +81 -0
- package/es/esf/components/village-maps/icons.js +35 -0
- package/es/esf/components/village-maps/index.js +214 -0
- package/es/esf/components/village-maps/messages.js +19 -0
- package/es/esf/components/village-maps/utils.js +26 -0
- package/es/esf/components/week-picker/index.js +244 -0
- package/es/esf/components/week-picker/messages.js +36 -0
- package/es/esf/components/week-picker/utils.js +65 -0
- package/es/esf/components/week-picker/week.js +52 -0
- package/es/esf/components/week-picker-2/index.js +283 -0
- package/es/esf/components/week-picker-2/messages.js +27 -0
- package/es/esf/components/week-picker-2/utils.js +65 -0
- package/es/esf/components/week-picker-2/week.js +55 -0
- package/es/esf/hooks/use-affiliation.js +26 -0
- package/es/esf/hooks/use-booking-links.js +36 -0
- package/es/esf/hooks/use-reviews.js +28 -0
- package/es/esf/hooks/use-season-products.js +100 -0
- package/package.json +51 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useState, useEffect, useRef } from "react";
|
|
3
|
+
import ProgressBar from "./progress-bar";
|
|
4
|
+
import Steps from "./steps";
|
|
5
|
+
import Response from "./response";
|
|
6
|
+
import useCustomFields from "./hooks/use-custom-fields";
|
|
7
|
+
import { FIELDS, STEPS } from "./data";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
const BookingForm = ({
|
|
12
|
+
lang,
|
|
13
|
+
resort,
|
|
14
|
+
channel = "ESF",
|
|
15
|
+
merchant,
|
|
16
|
+
integration = false,
|
|
17
|
+
uat = false,
|
|
18
|
+
noInitialScroll
|
|
19
|
+
}) => {
|
|
20
|
+
const ref = useRef();
|
|
21
|
+
const [fields, setFields] = useState(FIELDS);
|
|
22
|
+
const [step, setStep] = useState(STEPS.LESSONS);
|
|
23
|
+
const [lessons, setLessons] = useState([]);
|
|
24
|
+
const [personalData, setPersonalData] = useState({});
|
|
25
|
+
const [response, setResponse] = useState();
|
|
26
|
+
|
|
27
|
+
const _lang = lang === "fr" ? "fr" : "en";
|
|
28
|
+
|
|
29
|
+
const clearForm = () => {
|
|
30
|
+
setStep(STEPS.LESSONS);
|
|
31
|
+
setLessons([]);
|
|
32
|
+
setPersonalData({});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const bookinForm = ref.current;
|
|
37
|
+
if (noInitialScroll || !bookinForm) return;
|
|
38
|
+
bookinForm.scrollIntoView(true);
|
|
39
|
+
}, [noInitialScroll, step]);
|
|
40
|
+
useCustomFields(FIELDS, setFields);
|
|
41
|
+
return _jsxs("div", {
|
|
42
|
+
className: "booking-form",
|
|
43
|
+
children: [_jsx("div", {
|
|
44
|
+
ref: ref,
|
|
45
|
+
className: "booking-form__anchor"
|
|
46
|
+
}), _jsxs("div", {
|
|
47
|
+
className: "booking-form__inner",
|
|
48
|
+
children: [_jsx(ProgressBar, {
|
|
49
|
+
lang: _lang,
|
|
50
|
+
step: step
|
|
51
|
+
}), _jsx(Steps, {
|
|
52
|
+
lang: lang,
|
|
53
|
+
step: step,
|
|
54
|
+
setStep: setStep,
|
|
55
|
+
fields: fields,
|
|
56
|
+
lessons: lessons,
|
|
57
|
+
setLessons: setLessons,
|
|
58
|
+
personalData: personalData,
|
|
59
|
+
setPersonalData: setPersonalData,
|
|
60
|
+
setResponse: setResponse,
|
|
61
|
+
config: {
|
|
62
|
+
channel,
|
|
63
|
+
resort,
|
|
64
|
+
merchant,
|
|
65
|
+
integration,
|
|
66
|
+
uat
|
|
67
|
+
}
|
|
68
|
+
})]
|
|
69
|
+
}), _jsx(Response, {
|
|
70
|
+
lang: lang,
|
|
71
|
+
response: response,
|
|
72
|
+
setResponse: setResponse,
|
|
73
|
+
clearForm: clearForm
|
|
74
|
+
})]
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default BookingForm;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useState, Fragment } from "react";
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
import Field from "./field";
|
|
5
|
+
import { message } from "./messages";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
const Lesson = ({
|
|
10
|
+
lang,
|
|
11
|
+
index,
|
|
12
|
+
fields,
|
|
13
|
+
lesson,
|
|
14
|
+
lessons,
|
|
15
|
+
setLessons
|
|
16
|
+
}) => {
|
|
17
|
+
const [removing, setRemoving] = useState(false);
|
|
18
|
+
const {
|
|
19
|
+
groupLessons
|
|
20
|
+
} = fields;
|
|
21
|
+
|
|
22
|
+
const removeLesson = () => {
|
|
23
|
+
const newLessons = [...lessons];
|
|
24
|
+
newLessons.splice(index, 1);
|
|
25
|
+
setRemoving(true);
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
setRemoving(false);
|
|
28
|
+
setLessons(newLessons);
|
|
29
|
+
}, 160);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const classes = classnames("lesson", {
|
|
33
|
+
"lesson--removing": removing
|
|
34
|
+
});
|
|
35
|
+
return _jsxs("div", {
|
|
36
|
+
className: classes,
|
|
37
|
+
children: [_jsxs("div", {
|
|
38
|
+
className: "lesson__title",
|
|
39
|
+
children: [message(lang, "lesson"), " n\xB0", index + 1, " ", _jsx("button", {
|
|
40
|
+
onClick: removeLesson,
|
|
41
|
+
children: message(lang, "remove")
|
|
42
|
+
})]
|
|
43
|
+
}), _jsx("div", {
|
|
44
|
+
className: "lesson__inner",
|
|
45
|
+
children: Object.keys(groupLessons).map((key, i) => _jsxs(Fragment, {
|
|
46
|
+
children: [_jsx(Field, {
|
|
47
|
+
lang: lang,
|
|
48
|
+
index: index,
|
|
49
|
+
name: key,
|
|
50
|
+
field: groupLessons[key],
|
|
51
|
+
data: lessons,
|
|
52
|
+
setData: setLessons
|
|
53
|
+
}, `${key}-${index}`), key === "birthDate" && _jsx("hr", {})]
|
|
54
|
+
}, i))
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default Lesson;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import Lesson from "./lesson";
|
|
4
|
+
import { AddIcon, ArrowIcon } from "./icons";
|
|
5
|
+
import { message } from "./messages";
|
|
6
|
+
import { validate } from "./utils";
|
|
7
|
+
import { STEPS } from "./data";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
const Lessons = ({
|
|
12
|
+
lang,
|
|
13
|
+
fields,
|
|
14
|
+
lessons,
|
|
15
|
+
setLessons,
|
|
16
|
+
setStep,
|
|
17
|
+
personalData,
|
|
18
|
+
setPersonalData,
|
|
19
|
+
step1Valid
|
|
20
|
+
}) => {
|
|
21
|
+
const addLesson = () => {
|
|
22
|
+
const {
|
|
23
|
+
groupLessons
|
|
24
|
+
} = fields;
|
|
25
|
+
const lesson = Object.keys(groupLessons).reduce((acc, key) => {
|
|
26
|
+
return { ...acc,
|
|
27
|
+
[key]: {
|
|
28
|
+
value: "",
|
|
29
|
+
validator: validate(groupLessons[key].type, "")
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}, {});
|
|
33
|
+
setLessons([...lessons, lesson]);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const generatePersonalData = () => {
|
|
37
|
+
if (Object.keys(personalData).length > 0) return;
|
|
38
|
+
const {
|
|
39
|
+
data
|
|
40
|
+
} = fields;
|
|
41
|
+
const newData = Object.keys(data).reduce((acc, key) => {
|
|
42
|
+
return { ...acc,
|
|
43
|
+
[key]: {
|
|
44
|
+
value: "",
|
|
45
|
+
validator: validate(data[key].type, "")
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}, {});
|
|
49
|
+
setPersonalData(newData);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const nextStep = () => {
|
|
53
|
+
if (!step1Valid) return;
|
|
54
|
+
generatePersonalData();
|
|
55
|
+
setStep(STEPS.PERSONAL_DATA);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const nextStepButtonClasses = classnames("lessons__next-step", {
|
|
59
|
+
"lessons__next-step--disabled": !step1Valid
|
|
60
|
+
});
|
|
61
|
+
const title = `${lessons.length} ${lessons.length === 1 ? message(lang, "your-lesson") : message(lang, "your-lessons")}`;
|
|
62
|
+
return _jsxs("div", {
|
|
63
|
+
className: "lessons",
|
|
64
|
+
children: [lessons.length === 0 && _jsx("div", {
|
|
65
|
+
className: "lessons__placeholder",
|
|
66
|
+
children: message(lang, "lessons-placeholder")
|
|
67
|
+
}), lessons.length !== 0 && _jsx("div", {
|
|
68
|
+
className: "lessons__title",
|
|
69
|
+
children: title
|
|
70
|
+
}), lessons.map((lesson, i) => _jsx(Lesson, {
|
|
71
|
+
index: i,
|
|
72
|
+
lang: lang,
|
|
73
|
+
fields: fields,
|
|
74
|
+
lesson: lesson,
|
|
75
|
+
lessons: lessons,
|
|
76
|
+
setLessons: setLessons
|
|
77
|
+
}, i)), _jsxs("div", {
|
|
78
|
+
className: "lessons__buttons",
|
|
79
|
+
children: [_jsxs("button", {
|
|
80
|
+
className: "lessons__add",
|
|
81
|
+
onClick: addLesson,
|
|
82
|
+
children: [_jsx(AddIcon, {}), message(lang, "add-lesson")]
|
|
83
|
+
}), _jsxs("button", {
|
|
84
|
+
className: nextStepButtonClasses,
|
|
85
|
+
disabled: step1Valid ? undefined : true,
|
|
86
|
+
onClick: nextStep,
|
|
87
|
+
children: [message(lang, "next-step"), _jsx(ArrowIcon, {})]
|
|
88
|
+
})]
|
|
89
|
+
})]
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default Lessons;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const locales = {
|
|
2
|
+
fr: {
|
|
3
|
+
"step-1": "Choix des prestations",
|
|
4
|
+
"step-2": "Séjour & coordonnées",
|
|
5
|
+
"step-3": "Récapitulatif",
|
|
6
|
+
"lessons-placeholder": 'Cliquez sur "Ajouter un cours" pour commencer. Vous pouvez ajouter plusieurs cours dans une même demande.',
|
|
7
|
+
"your-lesson": "prestation",
|
|
8
|
+
"your-lessons": "prestations",
|
|
9
|
+
"add-lesson": "Ajouter un cours",
|
|
10
|
+
"previous-step": "Etape précédente",
|
|
11
|
+
"next-step": "Etape suivante",
|
|
12
|
+
"i-forgot-something": "J'ai oublié quelque chose",
|
|
13
|
+
lesson: "Prestation",
|
|
14
|
+
select: "Sélectionner",
|
|
15
|
+
remove: "Supprimer",
|
|
16
|
+
"personal-data": "Séjour et coordonnées",
|
|
17
|
+
summary: "Récapitulatif",
|
|
18
|
+
send: "Envoyer ma demande",
|
|
19
|
+
"response-error": "Une erreur est survenue, veuillez réessayer.",
|
|
20
|
+
"response-success": "Votre demande a bien été envoyée, nous vous recontacterons dans les plus brefs délais.",
|
|
21
|
+
"year-old": "ans",
|
|
22
|
+
optional: "optionnel"
|
|
23
|
+
},
|
|
24
|
+
en: {
|
|
25
|
+
"step-1": "Choice of lessons",
|
|
26
|
+
"step-2": "Stay & contact details",
|
|
27
|
+
"step-3": "Summary",
|
|
28
|
+
"lessons-placeholder": 'Click on "Add a lesson" to start. You can add several lessons in each request.',
|
|
29
|
+
"your-lesson": "lesson",
|
|
30
|
+
"your-lessons": "lessons",
|
|
31
|
+
"add-lesson": "Add a lesson",
|
|
32
|
+
"previous-step": "Previous step",
|
|
33
|
+
"next-step": "Next step",
|
|
34
|
+
"i-forgot-something": "I forgot something",
|
|
35
|
+
lesson: "Lesson",
|
|
36
|
+
select: "Select",
|
|
37
|
+
remove: "Remove",
|
|
38
|
+
"personal-data": "Stay & contact details",
|
|
39
|
+
summary: "summary",
|
|
40
|
+
send: "Send",
|
|
41
|
+
"response-error": "An error occured, please try again.",
|
|
42
|
+
"response-success": "Your request has been sent, we will get back to you as soon as possible.",
|
|
43
|
+
"year-old": "years old",
|
|
44
|
+
optional: "optional"
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export const message = (lang, id) => {
|
|
48
|
+
const _lang = lang === "fr" ? "fr" : "en";
|
|
49
|
+
|
|
50
|
+
if (!locales || !locales[_lang]) return id;
|
|
51
|
+
return locales[_lang][id] || `??${id}??`;
|
|
52
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
import Field from "./field";
|
|
5
|
+
import { ArrowIcon } from "./icons";
|
|
6
|
+
import { message } from "./messages";
|
|
7
|
+
import useStay from "./hooks/use-stay";
|
|
8
|
+
import { STEPS } from "./data";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
|
|
12
|
+
const PersonalData = ({
|
|
13
|
+
lang,
|
|
14
|
+
fields,
|
|
15
|
+
personalData,
|
|
16
|
+
setPersonalData,
|
|
17
|
+
setStep,
|
|
18
|
+
step2Valid
|
|
19
|
+
}) => {
|
|
20
|
+
const {
|
|
21
|
+
data
|
|
22
|
+
} = fields;
|
|
23
|
+
|
|
24
|
+
const previousStep = () => setStep(STEPS.LESSONS);
|
|
25
|
+
|
|
26
|
+
const nextStep = () => {
|
|
27
|
+
if (!step2Valid) return;
|
|
28
|
+
setStep(STEPS.SUMMARY);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const [stay] = useStay();
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!stay || personalData.stayFrom !== "" || personalData.stayTo !== "") return;
|
|
34
|
+
setPersonalData({ ...personalData,
|
|
35
|
+
stayFrom: stay.from,
|
|
36
|
+
stayTo: stay.to
|
|
37
|
+
});
|
|
38
|
+
}, [personalData, setPersonalData, stay]);
|
|
39
|
+
const nextStepButtonClasses = classnames("personal-data__next-step", {
|
|
40
|
+
"personal-data__next-step--disabled": !step2Valid
|
|
41
|
+
});
|
|
42
|
+
return _jsxs("div", {
|
|
43
|
+
className: "personal-data",
|
|
44
|
+
children: [_jsx("div", {
|
|
45
|
+
className: "personal-data__title",
|
|
46
|
+
children: message(lang, "personal-data")
|
|
47
|
+
}), _jsx("div", {
|
|
48
|
+
className: "personal-data__inner",
|
|
49
|
+
children: Object.keys(data).map(key => _jsx(Field, {
|
|
50
|
+
lang: lang,
|
|
51
|
+
index: "step-2",
|
|
52
|
+
name: key,
|
|
53
|
+
field: data[key],
|
|
54
|
+
data: personalData,
|
|
55
|
+
setData: setPersonalData
|
|
56
|
+
}, `${key}`))
|
|
57
|
+
}), _jsxs("div", {
|
|
58
|
+
className: "personal-data__buttons",
|
|
59
|
+
children: [_jsx("button", {
|
|
60
|
+
className: "personal-data__previous-step",
|
|
61
|
+
onClick: previousStep,
|
|
62
|
+
children: message(lang, "previous-step")
|
|
63
|
+
}), _jsxs("button", {
|
|
64
|
+
className: nextStepButtonClasses,
|
|
65
|
+
disabled: step2Valid ? undefined : true,
|
|
66
|
+
onClick: nextStep,
|
|
67
|
+
children: [message(lang, "next-step"), _jsx(ArrowIcon, {})]
|
|
68
|
+
})]
|
|
69
|
+
})]
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default PersonalData;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import { message } from "./messages";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
const ProgressBar = ({
|
|
8
|
+
lang,
|
|
9
|
+
step
|
|
10
|
+
}) => {
|
|
11
|
+
const transform = `scaleX(${step === 1 ? 0 : step === 2 ? "0.5" : 1})`;
|
|
12
|
+
return _jsxs("div", {
|
|
13
|
+
className: "progress-bar",
|
|
14
|
+
children: [_jsx("div", {
|
|
15
|
+
className: "progress-bar__filler",
|
|
16
|
+
style: {
|
|
17
|
+
transform
|
|
18
|
+
}
|
|
19
|
+
}), [...new Array(3)].map((_, i) => {
|
|
20
|
+
const index = i + 1;
|
|
21
|
+
const classes = classnames("progress-bar__dot", {
|
|
22
|
+
"progress-bar__dot--past": step > index,
|
|
23
|
+
"progress-bar__dot--current": step === index
|
|
24
|
+
});
|
|
25
|
+
return _jsx("div", {
|
|
26
|
+
className: classes,
|
|
27
|
+
children: _jsx("span", {
|
|
28
|
+
children: message(lang, `step-${index}`)
|
|
29
|
+
})
|
|
30
|
+
}, index);
|
|
31
|
+
})]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default ProgressBar;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { SuccessIcon, ErrorIcon, CloseIcon } from "./icons";
|
|
3
|
+
import { message } from "./messages";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
const Response = ({
|
|
8
|
+
lang,
|
|
9
|
+
response,
|
|
10
|
+
setResponse,
|
|
11
|
+
clearForm
|
|
12
|
+
}) => {
|
|
13
|
+
if (response === undefined) return null;
|
|
14
|
+
|
|
15
|
+
const close = () => {
|
|
16
|
+
if (response) {
|
|
17
|
+
clearForm();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
setResponse(undefined);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const code = response ? "success" : "error";
|
|
24
|
+
const Icon = response ? SuccessIcon : ErrorIcon;
|
|
25
|
+
return _jsxs("div", {
|
|
26
|
+
className: `response response--${code}`,
|
|
27
|
+
children: [_jsx("div", {
|
|
28
|
+
className: "response__overlay",
|
|
29
|
+
onClick: close
|
|
30
|
+
}), _jsxs("div", {
|
|
31
|
+
className: "response__message",
|
|
32
|
+
children: [_jsx(CloseIcon, {
|
|
33
|
+
className: "response__close",
|
|
34
|
+
onClick: close
|
|
35
|
+
}), _jsx(Icon, {
|
|
36
|
+
className: "response__icon"
|
|
37
|
+
}), message(lang, `response-${code}`)]
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default Response;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
import Lessons from "./lessons";
|
|
4
|
+
import PersonalData from "./personal-data";
|
|
5
|
+
import Summary from "./summary";
|
|
6
|
+
import { STEPS } from "./data";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
const Steps = ({
|
|
11
|
+
lang,
|
|
12
|
+
step,
|
|
13
|
+
setStep,
|
|
14
|
+
fields,
|
|
15
|
+
lessons,
|
|
16
|
+
setLessons,
|
|
17
|
+
personalData,
|
|
18
|
+
setPersonalData,
|
|
19
|
+
setResponse,
|
|
20
|
+
config
|
|
21
|
+
}) => {
|
|
22
|
+
const [step1Valid, setStep1Valid] = useState(false);
|
|
23
|
+
const [step2Valid, setStep2Valid] = useState(false);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (lessons.length > 0) {
|
|
26
|
+
setStep1Valid(true);
|
|
27
|
+
lessons.forEach(lesson => {
|
|
28
|
+
Object.keys(lesson).forEach(key => {
|
|
29
|
+
if (!fields.groupLessons[key].hidden && fields.groupLessons[key].required && !lesson[key].validator) {
|
|
30
|
+
setStep1Valid(false);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
setStep1Valid(false);
|
|
36
|
+
}
|
|
37
|
+
}, [fields.groupLessons, lessons, step1Valid]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (Object.keys(personalData).length > 0) {
|
|
40
|
+
setStep2Valid(true);
|
|
41
|
+
Object.keys(personalData).forEach(key => {
|
|
42
|
+
if (!fields.data[key].hidden && fields.data[key].required && !personalData[key].validator) {
|
|
43
|
+
setStep2Valid(false);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}, [fields.data, personalData, step2Valid]);
|
|
48
|
+
return _jsx("div", {
|
|
49
|
+
className: "steps",
|
|
50
|
+
children: _jsxs("div", {
|
|
51
|
+
className: "steps__inner",
|
|
52
|
+
children: [step === STEPS.LESSONS && _jsx(Lessons, {
|
|
53
|
+
lang: lang,
|
|
54
|
+
fields: fields,
|
|
55
|
+
lessons: lessons,
|
|
56
|
+
setLessons: setLessons,
|
|
57
|
+
setStep: setStep,
|
|
58
|
+
personalData: personalData,
|
|
59
|
+
setPersonalData: setPersonalData,
|
|
60
|
+
step1Valid: step1Valid
|
|
61
|
+
}), step === STEPS.PERSONAL_DATA && _jsx(PersonalData, {
|
|
62
|
+
lang: lang,
|
|
63
|
+
fields: fields,
|
|
64
|
+
personalData: personalData,
|
|
65
|
+
setPersonalData: setPersonalData,
|
|
66
|
+
setStep: setStep,
|
|
67
|
+
step2Valid: step2Valid
|
|
68
|
+
}), step === STEPS.SUMMARY && _jsx(Summary, {
|
|
69
|
+
lang: lang,
|
|
70
|
+
fields: fields,
|
|
71
|
+
lessons: lessons,
|
|
72
|
+
personalData: personalData,
|
|
73
|
+
setStep: setStep,
|
|
74
|
+
setResponse: setResponse,
|
|
75
|
+
config: config
|
|
76
|
+
})]
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default Steps;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Fragment, useRef } from "react";
|
|
3
|
+
import { CheckIcon } from "./icons";
|
|
4
|
+
import { message } from "./messages";
|
|
5
|
+
import { send, calculateAge, formatDate } from "./utils";
|
|
6
|
+
import { gescoFields, STEPS } from "./data";
|
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
const getChildren = (lang, key, type, label, value, isName, age) => {
|
|
12
|
+
if (key === "birthDate") return _jsxs(_Fragment, {
|
|
13
|
+
children: [_jsxs("span", {
|
|
14
|
+
children: [label, " :"]
|
|
15
|
+
}), " ", formatDate(lang, value), " ", age]
|
|
16
|
+
});
|
|
17
|
+
if (type === "date") return _jsxs(_Fragment, {
|
|
18
|
+
children: [_jsxs("span", {
|
|
19
|
+
children: [label, " :"]
|
|
20
|
+
}), " ", formatDate(lang, value)]
|
|
21
|
+
});
|
|
22
|
+
if (isName) return value + " ";
|
|
23
|
+
return _jsxs(_Fragment, {
|
|
24
|
+
children: [_jsxs("span", {
|
|
25
|
+
children: [label, " :"]
|
|
26
|
+
}), " ", value]
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const Summary = ({
|
|
31
|
+
lang,
|
|
32
|
+
fields,
|
|
33
|
+
lessons,
|
|
34
|
+
personalData,
|
|
35
|
+
setStep,
|
|
36
|
+
setResponse,
|
|
37
|
+
config
|
|
38
|
+
}) => {
|
|
39
|
+
const ref = useRef();
|
|
40
|
+
const {
|
|
41
|
+
groupLessons,
|
|
42
|
+
data
|
|
43
|
+
} = fields;
|
|
44
|
+
const {
|
|
45
|
+
channel,
|
|
46
|
+
resort,
|
|
47
|
+
merchant,
|
|
48
|
+
integration,
|
|
49
|
+
uat
|
|
50
|
+
} = config;
|
|
51
|
+
|
|
52
|
+
const previousStep = () => setStep(STEPS.PERSONAL_DATA);
|
|
53
|
+
|
|
54
|
+
const goToStep1 = () => setStep(STEPS.LESSONS);
|
|
55
|
+
|
|
56
|
+
const submit = async () => {
|
|
57
|
+
const fields = gescoFields(personalData, ref);
|
|
58
|
+
const result = await send(lang, channel, resort, merchant, integration, uat, fields);
|
|
59
|
+
setResponse(result);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return _jsxs("div", {
|
|
63
|
+
className: "summary",
|
|
64
|
+
children: [_jsx("div", {
|
|
65
|
+
className: "summary__title",
|
|
66
|
+
children: message(lang, "summary")
|
|
67
|
+
}), _jsxs("div", {
|
|
68
|
+
ref: ref,
|
|
69
|
+
className: "summary__inner",
|
|
70
|
+
children: [_jsx("div", {
|
|
71
|
+
className: "summary__sub-title",
|
|
72
|
+
children: message(lang, "personal-data")
|
|
73
|
+
}), Object.keys(personalData).map(key => {
|
|
74
|
+
const {
|
|
75
|
+
type,
|
|
76
|
+
label,
|
|
77
|
+
hidden
|
|
78
|
+
} = data[key];
|
|
79
|
+
if (hidden) return null;
|
|
80
|
+
const {
|
|
81
|
+
value
|
|
82
|
+
} = personalData[key];
|
|
83
|
+
const props = {
|
|
84
|
+
key,
|
|
85
|
+
className: "summary__row",
|
|
86
|
+
children: getChildren(lang, key, type, label[lang], value)
|
|
87
|
+
};
|
|
88
|
+
return _jsx("div", { ...props
|
|
89
|
+
});
|
|
90
|
+
}), _jsx("hr", {}), lessons.map((lesson, i) => {
|
|
91
|
+
return _jsxs(Fragment, {
|
|
92
|
+
children: [_jsx("br", {}), _jsxs("div", {
|
|
93
|
+
className: "summary__sub-title",
|
|
94
|
+
children: [message(lang, "lesson"), " n\xB0", i + 1]
|
|
95
|
+
}), Object.keys(lesson).map(key => {
|
|
96
|
+
const {
|
|
97
|
+
type,
|
|
98
|
+
label,
|
|
99
|
+
hidden
|
|
100
|
+
} = groupLessons[key];
|
|
101
|
+
if (hidden) return null;
|
|
102
|
+
const {
|
|
103
|
+
value
|
|
104
|
+
} = lesson[key];
|
|
105
|
+
const [birthDate, stayFrom] = [lesson.birthDate.value, personalData.stayFrom.value];
|
|
106
|
+
const age = key === "birthDate" && `(${calculateAge(birthDate, stayFrom)} ${message(lang, "year-old")})`;
|
|
107
|
+
const isName = key === "firstName" || key === "lastName";
|
|
108
|
+
const Tag = isName ? "span" : "div";
|
|
109
|
+
const props = {
|
|
110
|
+
key,
|
|
111
|
+
className: `summary__row summary__row--${key}`,
|
|
112
|
+
children: getChildren(lang, key, type, label[lang], value, isName, age)
|
|
113
|
+
};
|
|
114
|
+
return _jsx(Tag, { ...props
|
|
115
|
+
});
|
|
116
|
+
})]
|
|
117
|
+
}, i);
|
|
118
|
+
})]
|
|
119
|
+
}), _jsxs("div", {
|
|
120
|
+
className: "summary__buttons",
|
|
121
|
+
children: [_jsx("button", {
|
|
122
|
+
className: "summary__previous-step",
|
|
123
|
+
onClick: previousStep,
|
|
124
|
+
children: message(lang, "previous-step")
|
|
125
|
+
}), _jsx("button", {
|
|
126
|
+
className: "summary__go-to-step",
|
|
127
|
+
onClick: goToStep1,
|
|
128
|
+
children: message(lang, "add-lesson")
|
|
129
|
+
}), _jsxs("button", {
|
|
130
|
+
className: "summary__send",
|
|
131
|
+
onClick: submit,
|
|
132
|
+
children: [_jsx(CheckIcon, {}), message(lang, "send")]
|
|
133
|
+
})]
|
|
134
|
+
})]
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export default Summary;
|