ublo-lib 1.13.2 → 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
- setNeedCategory(needCategory);
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, update, widgetLang]);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.13.2",
3
+ "version": "1.13.3",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^2.1.0",
6
6
  "leaflet": "^1.9.1",