ublo-lib 1.19.31 → 1.19.33

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.
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
- import * as ReactDOM from "react-dom";
3
- import Popup from "../../../../common/components/popup";
2
+ import Dialog from "dt-design-system/es/dialog";
4
3
  import Button from "dt-design-system/es/button";
5
4
  import * as DTIcons from "dt-design-system/es/icons";
6
5
  import Field from "./field";
@@ -37,7 +36,8 @@ const CustomerForm = ({
37
36
  channel,
38
37
  merchant,
39
38
  resort,
40
- integration
39
+ integration,
40
+ categoryCode
41
41
  }) => {
42
42
  const fields = manualStay ? {
43
43
  ...Data.stayFields,
@@ -48,7 +48,7 @@ const CustomerForm = ({
48
48
  const isFormValid = Object.keys(customerData).every(key => customerData[key].validator);
49
49
  const onSubmit = async () => {
50
50
  setResponse(RESPONSE.LOADING);
51
- const payload = Utils.buildPayload(lang, channel, resort, merchant, voucher, customerData, rows, disableVoucher);
51
+ const payload = Utils.buildPayload(lang, channel, resort, merchant, voucher, customerData, rows, disableVoucher, categoryCode);
52
52
  const {
53
53
  error
54
54
  } = await Api.sendFile(payload, integration);
@@ -61,14 +61,17 @@ const CustomerForm = ({
61
61
  setVoucher("");
62
62
  setResponse(RESPONSE.OK);
63
63
  };
64
- if (!open) return null;
65
- return ReactDOM.createPortal(_jsx(Popup, {
64
+ return _jsx(Dialog, {
66
65
  className: styles.popup,
67
66
  close: close,
67
+ isOpened: open,
68
68
  title: Messages.get(lang, "customer-information"),
69
69
  children: _jsxs("div", {
70
70
  className: styles.inner,
71
- children: [_jsx(Stay, {
71
+ children: [_jsx("div", {
72
+ className: styles.title,
73
+ children: Messages.get(lang, "customer-information")
74
+ }), _jsx(Stay, {
72
75
  lang: lang
73
76
  }), _jsx("div", {
74
77
  className: styles.form,
@@ -95,6 +98,6 @@ const CustomerForm = ({
95
98
  })]
96
99
  })]
97
100
  })
98
- }), document.body);
101
+ });
99
102
  };
100
103
  export default CustomerForm;
@@ -1,13 +1,26 @@
1
- .popup > div {
2
- width: max-content;
1
+ .popup {
2
+ --ds-secondary: #cc0900;
3
+ --ds-primary: #bb0b02;
4
+
5
+ padding: 10px 16px;
6
+ }
7
+
8
+ .inner {
9
+ padding: 10px 0;
3
10
  }
4
11
 
5
12
  @media (min-width: 992px) {
6
13
  .inner {
7
- padding: 0 30px 10px 30px;
14
+ padding: 10px 30px 10px 30px;
8
15
  }
9
16
  }
10
17
 
18
+ .title {
19
+ margin-bottom: 20px;
20
+ font-size: 18px;
21
+ font-weight: 700;
22
+ }
23
+
11
24
  .form {
12
25
  display: flex;
13
26
  flex-direction: column;
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
- import * as ReactDOM from "react-dom";
3
- import Popup from "../../../../common/components/popup";
2
+ import Dialog from "dt-design-system/es/dialog";
4
3
  import Field from "./field";
5
4
  import Button from "dt-design-system/es/button";
6
5
  import * as DTIcons from "dt-design-system/es/icons";
@@ -21,7 +20,8 @@ const StudentForm = ({
21
20
  close,
22
21
  studentData,
23
22
  levels,
24
- setRows
23
+ setRows,
24
+ recapFormRef
25
25
  }) => {
26
26
  const fields = Data.studentFormFields(studentData.productCategory ? levels[studentData.productCategory] : levels);
27
27
  const [formData, setFormData] = React.useState(getInitialState(fields));
@@ -37,21 +37,35 @@ const StudentForm = ({
37
37
  formData
38
38
  }]);
39
39
  onClose();
40
+ const recapForm = recapFormRef.current;
41
+ if (recapForm) {
42
+ requestAnimationFrame(() => {
43
+ requestAnimationFrame(() => {
44
+ recapForm.scrollIntoView({
45
+ behavior: "smooth"
46
+ });
47
+ });
48
+ });
49
+ }
40
50
  };
41
- if (!dataKeys.length) return null;
42
51
  const {
43
52
  details,
44
53
  price,
45
54
  selectedOption,
46
55
  title
47
56
  } = studentData;
48
- return ReactDOM.createPortal(_jsx(Popup, {
57
+ return _jsx(Dialog, {
49
58
  className: styles.popup,
50
59
  close: onClose,
60
+ isOpened: Boolean(dataKeys.length),
51
61
  title: Messages.get(lang, "student-information"),
62
+ showCloseButton: true,
52
63
  children: _jsxs("div", {
53
64
  className: styles.inner,
54
- children: [_jsxs("div", {
65
+ children: [_jsx("div", {
66
+ className: styles.title,
67
+ children: Messages.get(lang, "student-information")
68
+ }), _jsxs("div", {
55
69
  className: styles.header,
56
70
  children: [_jsx("div", {
57
71
  className: styles.title,
@@ -96,6 +110,6 @@ const StudentForm = ({
96
110
  })
97
111
  })]
98
112
  })
99
- }), document.body);
113
+ });
100
114
  };
101
115
  export default StudentForm;
@@ -1,13 +1,20 @@
1
- .popup > div {
1
+ .popup {
2
2
  --ds-secondary: #cc0900;
3
3
  --ds-primary: #bb0b02;
4
4
 
5
- width: max-content;
5
+ padding: 10px 16px;
6
6
  }
7
7
 
8
8
  .inner {
9
9
  width: 420px;
10
10
  max-width: 100%;
11
+ padding: 10px 0;
12
+ }
13
+
14
+ .title {
15
+ margin-bottom: 20px;
16
+ font-size: 18px;
17
+ font-weight: 700;
11
18
  }
12
19
 
13
20
  .header {
@@ -6,14 +6,13 @@ import StudentForm from "./components/student-form";
6
6
  import CustomerForm from "./components/customer-form";
7
7
  import * as Messages from "./messages";
8
8
  import * as Content from "./content";
9
- import * as Utils from "./utils";
10
9
  import Button from "dt-design-system/es/button";
11
10
  import * as DTIcons from "dt-design-system/es/icons";
12
11
  import useStoredRows from "./hooks/use-stored-rows";
13
12
  import styles from "./loyal-customers.module.css";
14
13
  import { jsx as _jsx } from "react/jsx-runtime";
15
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
- const LoyalCustomers = ({
15
+ export default function LoyalCustomers({
17
16
  lang,
18
17
  cmsMode,
19
18
  selectors,
@@ -26,14 +25,15 @@ const LoyalCustomers = ({
26
25
  merchant,
27
26
  resort,
28
27
  disableVoucher,
29
- integration
30
- }) => {
28
+ integration,
29
+ categoryCode
30
+ }) {
31
+ const ref = React.useRef(null);
31
32
  const [rows, setRows] = useStoredRows([]);
32
33
  const [openedRow, setOpenedRow] = React.useState();
33
34
  const [voucher, setVoucher] = React.useState("");
34
35
  const [studentData, setStudentData] = React.useState({});
35
36
  const [customerFormOpen, setCustomerFormOpen] = React.useState(false);
36
- Utils.showHelper();
37
37
  const total = rows.reduce((acc, row) => acc + row.price, 0);
38
38
  const closeStudentForm = () => setStudentData({});
39
39
  const closeCustomerForm = () => setCustomerFormOpen(false);
@@ -76,6 +76,7 @@ const LoyalCustomers = ({
76
76
  }, [cleanup, cmsMode, init, selectors]);
77
77
  const classes = classNames(styles.index, className);
78
78
  return _jsxs("div", {
79
+ ref: ref,
79
80
  className: classes,
80
81
  children: [_jsx("div", {
81
82
  className: styles.title,
@@ -109,7 +110,8 @@ const LoyalCustomers = ({
109
110
  close: closeStudentForm,
110
111
  studentData: studentData,
111
112
  levels: levels,
112
- setRows: setRows
113
+ setRows: setRows,
114
+ recapFormRef: ref
113
115
  }), _jsx(CustomerForm, {
114
116
  lang: lang,
115
117
  close: closeCustomerForm,
@@ -123,8 +125,8 @@ const LoyalCustomers = ({
123
125
  channel: channel,
124
126
  merchant: merchant,
125
127
  resort: resort,
126
- integration: integration
128
+ integration: integration,
129
+ categoryCode: categoryCode
127
130
  })]
128
131
  });
129
- };
130
- export default LoyalCustomers;
132
+ }
@@ -12,12 +12,7 @@ export const formatDate = (lang, date) => {
12
12
  year: "numeric"
13
13
  });
14
14
  };
15
- export const showHelper = () => {
16
- if (process.env.NODE_ENV !== "production") {
17
- console.info("LoyalCustomers: See https://github.com/valraiso-esf/documentation-sites-marchands/tree/master/loyal-customers for more information.");
18
- }
19
- };
20
- export const buildPayload = (lang, channel, resort, merchant, voucher, customerData, rows, disableVoucher) => {
15
+ export const buildPayload = (lang, channel, resort, merchant, voucher, customerData, rows, disableVoucher, categoryCode) => {
21
16
  const {
22
17
  comment,
23
18
  email,
@@ -69,6 +64,7 @@ Commentaire : ${comment.value}`;
69
64
  from: stayFrom?.value || from,
70
65
  to: stayTo?.value || to,
71
66
  message,
67
+ category: categoryCode,
72
68
  customer: {
73
69
  email: email.value,
74
70
  title: title.value,
@@ -4,7 +4,7 @@ import Button from "dt-design-system/es/button";
4
4
  import * as Icons from "dt-design-system/es/icons";
5
5
  import { message } from "./messages";
6
6
  import { loadWigetMseM, preview } from "./services/widgets";
7
- import * as Plausible from "../../../common/components/plausible";
7
+ import * as Plausible from "ublo-lib/es/common/components/plausible";
8
8
  import css from "./booking.module.css";
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -61,7 +61,8 @@ const Booking = ({
61
61
  fullWidth: true,
62
62
  groundedTo: "#msem-magic-box",
63
63
  analytics: Plausible.callback,
64
- show: ["vel"]
64
+ show: ["vel"],
65
+ categoryCode: values.categories
65
66
  };
66
67
  const presets = {
67
68
  kind: "CP",
@@ -76,7 +77,7 @@ const Booking = ({
76
77
  });
77
78
  };
78
79
  init();
79
- }, [cartUrl, channel, cmsMode, engagement, engagementPresets, lang, resort, stay?.from, stay?.to]);
80
+ }, [cartUrl, channel, cmsMode, engagement, engagementPresets, lang, resort, stay.from, stay.to, values.categories]);
80
81
  return _jsxs("div", {
81
82
  className: css.root,
82
83
  children: [_jsxs(Button, {
@@ -13,9 +13,10 @@ type Props = {
13
13
  minDays?: number;
14
14
  maxDays?: number;
15
15
  allowedActivities?: string[];
16
+ categories?: string[];
16
17
  children?: React.ReactNode;
17
18
  };
18
19
  declare const _default: React.MemoExoticComponent<typeof MagicBox>;
19
20
  export default _default;
20
- declare function MagicBox({ stay, cartUrl, channel, className, alignContent, maxCPDuration, minDays, maxDays, allowedActivities, children, }: Props): import("react/jsx-runtime").JSX.Element;
21
+ declare function MagicBox({ stay, cartUrl, channel, className, alignContent, maxCPDuration, minDays, maxDays, allowedActivities, categories, children, }: Props): import("react/jsx-runtime").JSX.Element;
21
22
  //# sourceMappingURL=magic-box.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"magic-box.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/magic-box/magic-box.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;;AAIF,wBAAoC;AAEpC,iBAAS,QAAQ,CAAC,EAChB,IAAI,EACJ,OAAO,EACP,OAAe,EACf,SAAS,EACT,YAAY,EACZ,aAAa,EACb,OAAW,EACX,OAAkB,EAClB,iBAAiB,EACjB,QAAQ,GACT,EAAE,KAAK,2CA8HP"}
1
+ {"version":3,"file":"magic-box.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/magic-box/magic-box.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;;AAIF,wBAAoC;AAEpC,iBAAS,QAAQ,CAAC,EAChB,IAAI,EACJ,OAAO,EACP,OAAe,EACf,SAAS,EACT,YAAY,EACZ,aAAa,EACb,OAAW,EACX,OAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,QAAQ,GACT,EAAE,KAAK,2CAkJP"}
@@ -10,12 +10,12 @@ import { message } from "./messages";
10
10
  import * as API from "./services/api";
11
11
  import css from "./magic-box.module.css";
12
12
  export default React.memo(MagicBox);
13
- function MagicBox({ stay, cartUrl, channel = "ESF", className, alignContent, maxCPDuration, minDays = 0, maxDays = Infinity, allowedActivities, children, }) {
13
+ function MagicBox({ stay, cartUrl, channel = "ESF", className, alignContent, maxCPDuration, minDays = 0, maxDays = Infinity, allowedActivities, categories, children, }) {
14
14
  const [filters, setFilters] = React.useState();
15
15
  const [values, setValues] = React.useState();
16
16
  const [currentStep, setCurrentStep] = React.useState(0);
17
17
  const { lang, config } = useUbloContext();
18
- const { resort } = config;
18
+ const { resort, merchant } = config;
19
19
  const validate = React.useCallback(() => {
20
20
  let valid = true;
21
21
  if (stay && filters && values) {
@@ -33,13 +33,17 @@ function MagicBox({ stay, cartUrl, channel = "ESF", className, alignContent, max
33
33
  const refreshFilters = React.useCallback(async () => {
34
34
  if (stay) {
35
35
  const { from: stayFrom, to: stayTo } = stay;
36
- const welcomeResult = await API.fetchWelcome({
37
- lang,
38
- resort,
39
- stayFrom,
40
- stayTo,
41
- });
36
+ const [welcomeResult, paramsResult] = await Promise.all([
37
+ API.fetchWelcome({
38
+ lang,
39
+ resort,
40
+ stayFrom,
41
+ stayTo,
42
+ }),
43
+ API.fetchParams(lang, resort, merchant, channel, categories),
44
+ ]);
42
45
  const { season: currentSeason, availableSeasons } = welcomeResult;
46
+ const { categories: categoryList } = paramsResult;
43
47
  const season = currentSeason || availableSeasons[0] || "2022";
44
48
  const filtersResult = await API.fetchFilters({
45
49
  lang,
@@ -71,11 +75,27 @@ function MagicBox({ stay, cartUrl, channel = "ESF", className, alignContent, max
71
75
  const filterWithoutRestricted = filter.filter((item) => !item.restricted);
72
76
  return { ...acc, [key]: filterWithoutRestricted };
73
77
  }, {});
74
- setFilters(newFilters);
75
- const defaultValues = getDefaultValues(newFilters);
78
+ const formatedCategories = categoryList?.map(({ code, label }) => {
79
+ return { value: code, libelle: label };
80
+ });
81
+ const allFilters = categories
82
+ ? { ...newFilters, categories: formatedCategories }
83
+ : newFilters;
84
+ setFilters(allFilters);
85
+ const defaultValues = getDefaultValues(allFilters);
76
86
  setValues(defaultValues);
77
87
  }
78
- }, [lang, maxDays, minDays, resort, stay]);
88
+ }, [
89
+ allowedActivities,
90
+ categories,
91
+ channel,
92
+ lang,
93
+ maxDays,
94
+ merchant,
95
+ minDays,
96
+ resort,
97
+ stay,
98
+ ]);
79
99
  React.useEffect(() => {
80
100
  refreshFilters();
81
101
  setCurrentStep(0);
@@ -7,7 +7,8 @@ const locales = {
7
7
  languages: " en ",
8
8
  startDates: " J'aimerais commencer à partir du ",
9
9
  days: " pendant ",
10
- durations: " sur des cours de "
10
+ durations: " sur des cours de ",
11
+ categories: " à "
11
12
  },
12
13
  en: {
13
14
  confirm: "Find an instructor",
@@ -17,7 +18,8 @@ const locales = {
17
18
  languages: " in ",
18
19
  startDates: " I'd like to start from ",
19
20
  days: " for ",
20
- durations: " with lessons of "
21
+ durations: " with lessons of ",
22
+ categories: " at "
21
23
  }
22
24
  };
23
25
  export const message = (lang, id) => {
@@ -1,17 +1,20 @@
1
1
  import * as Fetcher from "../../../../common/utils/fetcher";
2
2
  const velApi = "https://services.msem.tech/api/esf";
3
- export const fetchWelcome = ({
3
+ const msemAdminApi = "https://admin.mon-sejour-en-montagne.com/api/gesco";
4
+ export function fetchWelcome({
4
5
  lang,
5
6
  resort,
6
7
  stayFrom,
7
8
  stayTo
8
- }) => Fetcher.post(`${velApi}/welcome`, {
9
- resort,
10
- lang,
11
- stayFrom,
12
- stayTo
13
- });
14
- export const fetchFilters = async ({
9
+ }) {
10
+ return Fetcher.post(`${velApi}/welcome`, {
11
+ resort,
12
+ lang,
13
+ stayFrom,
14
+ stayTo
15
+ });
16
+ }
17
+ export async function fetchFilters({
15
18
  lang,
16
19
  resort,
17
20
  season,
@@ -19,7 +22,7 @@ export const fetchFilters = async ({
19
22
  stayTo,
20
23
  kinds = ["CP"],
21
24
  engagement = true
22
- }) => {
25
+ }) {
23
26
  return Fetcher.post(`${velApi}/filters`, {
24
27
  lang,
25
28
  resort,
@@ -29,4 +32,20 @@ export const fetchFilters = async ({
29
32
  kinds,
30
33
  engagement
31
34
  });
32
- };
35
+ }
36
+ export async function fetchParams(lang, resort, merchant, channel, categories) {
37
+ const res = await fetch(`${msemAdminApi}/contact/parameters`, {
38
+ method: "POST",
39
+ headers: {
40
+ "content-type": "application/json;charset=utf-8"
41
+ },
42
+ body: JSON.stringify({
43
+ lang,
44
+ resort,
45
+ merchant,
46
+ channel,
47
+ categories
48
+ })
49
+ });
50
+ return res.json();
51
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.19.31",
3
+ "version": "1.19.33",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^3.1.5",
6
6
  "leaflet": "^1.9.1",