ublo-lib 1.25.28 → 1.26.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.
|
@@ -6,7 +6,7 @@ import * as Icons from "dt-design-system/es/icons";
|
|
|
6
6
|
import css from "./widget-list-item.module.css";
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
const ALLOW_PRESETS_ON_WIDGETS = ["lodging", "skiPass", "elloha", "vakario"];
|
|
9
|
+
const ALLOW_PRESETS_ON_WIDGETS = ["lodging", "skiPass", "liftJb", "elloha", "vakario"];
|
|
10
10
|
export default function WidgetListItem({
|
|
11
11
|
item,
|
|
12
12
|
preset,
|
|
@@ -21,6 +21,7 @@ export default function WidgetListItem({
|
|
|
21
21
|
name,
|
|
22
22
|
items: subs
|
|
23
23
|
} = item;
|
|
24
|
+
console.log(widget);
|
|
24
25
|
const toggleItem = () => {
|
|
25
26
|
setOpened(!opened);
|
|
26
27
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import SkiPasses from "./ski-passes";
|
|
2
|
+
import SkiPassesJb from "./ski-passes-jb";
|
|
2
3
|
import Lodgings from "./lodgings";
|
|
3
4
|
import Elloha from "./elloha";
|
|
4
5
|
import Vakario from "./vakario";
|
|
@@ -6,6 +7,7 @@ import StandardProducts from "./standard-products";
|
|
|
6
7
|
const Editor = {
|
|
7
8
|
lodging: Lodgings,
|
|
8
9
|
skiPass: SkiPasses,
|
|
10
|
+
liftJb: SkiPassesJb,
|
|
9
11
|
elloha: Elloha,
|
|
10
12
|
vakario: Vakario,
|
|
11
13
|
otherProducts: StandardProducts
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Select from "dt-design-system/es/select";
|
|
3
|
+
import Input from "dt-design-system/es/input";
|
|
4
|
+
import NumberPicker from "dt-design-system/es/number-picker";
|
|
5
|
+
import Form from "../components/form";
|
|
6
|
+
import * as API from "../services/api";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const DEFAULT_DATA = {
|
|
11
|
+
catalog: "",
|
|
12
|
+
firstSkiDate: "",
|
|
13
|
+
nbParticipants: 1
|
|
14
|
+
};
|
|
15
|
+
export default function SkiPasses({
|
|
16
|
+
preset,
|
|
17
|
+
setPreset,
|
|
18
|
+
stay,
|
|
19
|
+
setShowPresetDialog,
|
|
20
|
+
onChange,
|
|
21
|
+
testPreset,
|
|
22
|
+
baseUrl
|
|
23
|
+
}) {
|
|
24
|
+
const savedPreset = React.useRef(preset);
|
|
25
|
+
const [catalogs, setCatalogs] = React.useState(null);
|
|
26
|
+
const [catalog, setCatalog] = React.useState(preset?.options?.catalog || "");
|
|
27
|
+
const [data, setData] = React.useState(getDefaultData(preset));
|
|
28
|
+
const firstSkiDateDefaultMonth = stay?.from ? new Date(stay.from).getMonth() + 1 : undefined;
|
|
29
|
+
const {
|
|
30
|
+
merchant
|
|
31
|
+
} = preset?.options;
|
|
32
|
+
const isReady = catalogs !== null;
|
|
33
|
+
const hasCatalog = isReady && catalogs?.length > 0 && catalog !== "";
|
|
34
|
+
const cancelPreset = () => {
|
|
35
|
+
setPreset(savedPreset.current);
|
|
36
|
+
setShowPresetDialog(false);
|
|
37
|
+
};
|
|
38
|
+
const confirmPreset = () => {
|
|
39
|
+
setShowPresetDialog(false);
|
|
40
|
+
};
|
|
41
|
+
const updateField = field => value => {
|
|
42
|
+
setData(data => ({
|
|
43
|
+
...data,
|
|
44
|
+
[field]: value
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
const updateFirstSkiDate = value => {
|
|
48
|
+
updateField("firstSkiDate")(value);
|
|
49
|
+
};
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
if (!isReady) {
|
|
52
|
+
const runEffect = async () => {
|
|
53
|
+
try {
|
|
54
|
+
const catalogs = await API.getSkiPassesCatalogs(merchant);
|
|
55
|
+
setCatalogs(catalogs);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
setCatalogs([]);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
runEffect();
|
|
61
|
+
}
|
|
62
|
+
}, [isReady, merchant]);
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
setPreset((current = {}) => {
|
|
65
|
+
const newPreset = {
|
|
66
|
+
...current,
|
|
67
|
+
options: {
|
|
68
|
+
...(current?.options || {}),
|
|
69
|
+
catalog
|
|
70
|
+
},
|
|
71
|
+
presets: {
|
|
72
|
+
...(current?.presets || {}),
|
|
73
|
+
...data
|
|
74
|
+
},
|
|
75
|
+
url: baseUrl || undefined
|
|
76
|
+
};
|
|
77
|
+
onChange?.(newPreset);
|
|
78
|
+
return newPreset;
|
|
79
|
+
});
|
|
80
|
+
}, [catalog, data, baseUrl, setPreset, onChange]);
|
|
81
|
+
return _jsxs(Form, {
|
|
82
|
+
title: "Presets forfaits JB",
|
|
83
|
+
width: 420,
|
|
84
|
+
preset: preset,
|
|
85
|
+
buttonsActions: {
|
|
86
|
+
testPreset,
|
|
87
|
+
cancelPreset,
|
|
88
|
+
confirmPreset: hasCatalog ? confirmPreset : undefined
|
|
89
|
+
},
|
|
90
|
+
children: [_jsx(Select, {
|
|
91
|
+
label: "Catalogue",
|
|
92
|
+
value: catalog,
|
|
93
|
+
options: catalogs ? ["", ...catalogs] : [],
|
|
94
|
+
onValueChange: setCatalog,
|
|
95
|
+
loading: !isReady
|
|
96
|
+
}), hasCatalog && _jsxs(_Fragment, {
|
|
97
|
+
children: [_jsx(Input, {
|
|
98
|
+
type: "date",
|
|
99
|
+
label: "1er jour",
|
|
100
|
+
value: data.firstSkiDate,
|
|
101
|
+
onValueChange: updateFirstSkiDate,
|
|
102
|
+
defaultMonth: firstSkiDateDefaultMonth,
|
|
103
|
+
min: stay?.from || undefined,
|
|
104
|
+
max: stay?.to || undefined
|
|
105
|
+
}), _jsx(NumberPicker, {
|
|
106
|
+
label: "Nb de participants",
|
|
107
|
+
value: data.nbParticipants,
|
|
108
|
+
onChange: updateField("nbParticipants"),
|
|
109
|
+
min: 0,
|
|
110
|
+
withInput: true,
|
|
111
|
+
compact: true
|
|
112
|
+
})]
|
|
113
|
+
})]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function getDefaultData(preset) {
|
|
117
|
+
if (!preset?.presets) return DEFAULT_DATA;
|
|
118
|
+
const {
|
|
119
|
+
catalog
|
|
120
|
+
} = preset.options || {};
|
|
121
|
+
const {
|
|
122
|
+
firstSkiDate,
|
|
123
|
+
nbParticipants
|
|
124
|
+
} = preset.presets;
|
|
125
|
+
return {
|
|
126
|
+
catalog: catalog || DEFAULT_DATA.catalog,
|
|
127
|
+
firstSkiDate: firstSkiDate || DEFAULT_DATA.firstSkiDate,
|
|
128
|
+
nbParticipants: nbParticipants || DEFAULT_DATA.nbParticipants
|
|
129
|
+
};
|
|
130
|
+
}
|