ublo-lib 1.19.32 → 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.
@@ -36,7 +36,8 @@ const CustomerForm = ({
36
36
  channel,
37
37
  merchant,
38
38
  resort,
39
- integration
39
+ integration,
40
+ categoryCode
40
41
  }) => {
41
42
  const fields = manualStay ? {
42
43
  ...Data.stayFields,
@@ -47,7 +48,7 @@ const CustomerForm = ({
47
48
  const isFormValid = Object.keys(customerData).every(key => customerData[key].validator);
48
49
  const onSubmit = async () => {
49
50
  setResponse(RESPONSE.LOADING);
50
- 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);
51
52
  const {
52
53
  error
53
54
  } = await Api.sendFile(payload, integration);
@@ -25,7 +25,8 @@ export default function LoyalCustomers({
25
25
  merchant,
26
26
  resort,
27
27
  disableVoucher,
28
- integration
28
+ integration,
29
+ categoryCode
29
30
  }) {
30
31
  const ref = React.useRef(null);
31
32
  const [rows, setRows] = useStoredRows([]);
@@ -124,7 +125,8 @@ export default function LoyalCustomers({
124
125
  channel: channel,
125
126
  merchant: merchant,
126
127
  resort: resort,
127
- integration: integration
128
+ integration: integration,
129
+ categoryCode: categoryCode
128
130
  })]
129
131
  });
130
132
  }
@@ -12,7 +12,7 @@ export const formatDate = (lang, date) => {
12
12
  year: "numeric"
13
13
  });
14
14
  };
15
- export const buildPayload = (lang, channel, resort, merchant, voucher, customerData, rows, disableVoucher) => {
15
+ export const buildPayload = (lang, channel, resort, merchant, voucher, customerData, rows, disableVoucher, categoryCode) => {
16
16
  const {
17
17
  comment,
18
18
  email,
@@ -64,6 +64,7 @@ Commentaire : ${comment.value}`;
64
64
  from: stayFrom?.value || from,
65
65
  to: stayTo?.value || to,
66
66
  message,
67
+ category: categoryCode,
67
68
  customer: {
68
69
  email: email.value,
69
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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AAa,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.32",
3
+ "version": "1.19.33",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^3.1.5",
6
6
  "leaflet": "^1.9.1",