ublo-lib 1.13.1 → 1.13.3
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.
|
@@ -60,26 +60,29 @@ function ContactForm({
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
}, [widgetLang]);
|
|
63
|
+
const handleCategory = React.useCallback(() => {
|
|
64
|
+
const needCategory = params?.categories?.length > 1;
|
|
65
|
+
setNeedCategory(needCategory);
|
|
66
|
+
if (!needCategory) {
|
|
67
|
+
if (params?.categories?.length === 1) {
|
|
68
|
+
update(true, "category", params.categories[0].code, []);
|
|
69
|
+
} else {
|
|
70
|
+
update(true, "category", undefined, []);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, [params, update]);
|
|
63
74
|
React.useEffect(() => {
|
|
64
75
|
const getParams = async () => {
|
|
65
76
|
const params = await API.fetchParams(widgetLang, resort, merchant, channel, categories, integration, uat);
|
|
66
77
|
if (params === undefined || params.error !== undefined) {
|
|
67
78
|
setHasError(true);
|
|
68
79
|
} else {
|
|
69
|
-
const needCategory = params?.categories?.length > 1;
|
|
70
80
|
setParams(params);
|
|
71
|
-
|
|
72
|
-
if (!needCategory) {
|
|
73
|
-
if (params?.categories?.length === 1) {
|
|
74
|
-
update(true, "category", params.categories[0].code, []);
|
|
75
|
-
} else {
|
|
76
|
-
update(true, "category", undefined, []);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
81
|
+
handleCategory();
|
|
79
82
|
}
|
|
80
83
|
};
|
|
81
84
|
getParams();
|
|
82
|
-
}, [categories, channel, integration, merchant, resort, uat,
|
|
85
|
+
}, [categories, channel, handleCategory, integration, merchant, resort, uat, widgetLang]);
|
|
83
86
|
const validateAll = () => {
|
|
84
87
|
Object.keys(fields).forEach(key => {
|
|
85
88
|
update(true, key, undefined, !needCategory && key === "category" ? undefined : fields[key].validators);
|
|
@@ -142,6 +145,7 @@ function ContactForm({
|
|
|
142
145
|
Subject: subject?.label
|
|
143
146
|
});
|
|
144
147
|
setFields(Data.DEFAULT_FIELDS);
|
|
148
|
+
handleCategory();
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
151
|
setSubmiting(false);
|
|
@@ -99,9 +99,11 @@ const usePackages = (defaultPopupContent, setPopupContent, cartUrl, selector = "
|
|
|
99
99
|
section.addEventListener("click", onPackageClick);
|
|
100
100
|
}, [callback, onPackageClick]);
|
|
101
101
|
const cleanup = React.useCallback(section => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
if (section) {
|
|
103
|
+
const zone = section.closest(".cms");
|
|
104
|
+
zone.removeEventListener("ublo-section-created", callback);
|
|
105
|
+
section.removeEventListener("click", onPackageClick);
|
|
106
|
+
}
|
|
105
107
|
}, [callback, onPackageClick]);
|
|
106
108
|
React.useEffect(() => {
|
|
107
109
|
const sections = Array.from(document.querySelectorAll(selector));
|