ublo-lib 1.1.15 → 1.1.17
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.
|
@@ -39,22 +39,26 @@ const ContactForm = ({
|
|
|
39
39
|
const snackbar = useSnackbar();
|
|
40
40
|
const widgetLang = lang === "fr" ? "fr" : "en";
|
|
41
41
|
const update = React.useCallback((forceTouch, name, val, overrideValidators) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
setFields(fields => {
|
|
43
|
+
const field = fields[name];
|
|
44
|
+
const value = val !== undefined ? val : field.value;
|
|
45
|
+
const touched = forceTouch || field.touched;
|
|
46
|
+
const validators = overrideValidators || field.validators;
|
|
47
|
+
const error = touched ? Validation.validate(widgetLang, name, value, validators, fields) : undefined;
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
if (field.value !== value || field.error !== error || field.touched !== touched) {
|
|
50
|
+
return { ...fields,
|
|
51
|
+
[name]: { ...field,
|
|
52
|
+
value,
|
|
53
|
+
error,
|
|
54
|
+
touched
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
} else {
|
|
58
|
+
return fields;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}, [widgetLang]);
|
|
58
62
|
React.useEffect(() => {
|
|
59
63
|
const getParams = async () => {
|
|
60
64
|
const params = await API.fetchParams(widgetLang, resort, merchant, channel, categories, integration, uat);
|
|
@@ -77,7 +81,7 @@ const ContactForm = ({
|
|
|
77
81
|
};
|
|
78
82
|
|
|
79
83
|
getParams();
|
|
80
|
-
}, [channel, integration,
|
|
84
|
+
}, [categories, channel, integration, merchant, resort, uat, update, widgetLang]);
|
|
81
85
|
|
|
82
86
|
const validateAll = () => {
|
|
83
87
|
const stayValidators = [];
|
|
@@ -78,7 +78,6 @@ const SkiPass = ({
|
|
|
78
78
|
const [filters, setFilters] = React.useState();
|
|
79
79
|
const [data, setData] = React.useState(getDefaultData(config));
|
|
80
80
|
const [presetUrl, setPresetUrl] = React.useState("");
|
|
81
|
-
const firstRender = React.useRef(true);
|
|
82
81
|
const resortData = resorts?.find(r => {
|
|
83
82
|
return r.resort === parseInt(selectedResort);
|
|
84
83
|
});
|
|
@@ -137,13 +136,13 @@ const SkiPass = ({
|
|
|
137
136
|
|
|
138
137
|
const updateField = (field, isArray) => value => {
|
|
139
138
|
if (isArray) {
|
|
140
|
-
setData({ ...data,
|
|
141
|
-
[
|
|
142
|
-
});
|
|
139
|
+
setData(data => ({ ...data,
|
|
140
|
+
[field]: value.map(v => v.value)
|
|
141
|
+
}));
|
|
143
142
|
} else {
|
|
144
|
-
setData({ ...data,
|
|
143
|
+
setData(data => ({ ...data,
|
|
145
144
|
[field]: value
|
|
146
|
-
});
|
|
145
|
+
}));
|
|
147
146
|
}
|
|
148
147
|
};
|
|
149
148
|
|