@open-tender/utils 0.5.27 → 0.5.29
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.
|
@@ -37,11 +37,13 @@ const useAllergenForm = (allergens, selectedAllergens, isLoading = false, error,
|
|
|
37
37
|
var _a, _b;
|
|
38
38
|
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
39
39
|
setSubmitting(updateAllergens !== null);
|
|
40
|
-
setAllergens(data);
|
|
41
40
|
if (updateAllergens) {
|
|
42
41
|
const newData = data.map(i => ({ allergen_id: i.allergen_id }));
|
|
43
42
|
updateAllergens(newData);
|
|
44
43
|
}
|
|
44
|
+
else {
|
|
45
|
+
setAllergens(data);
|
|
46
|
+
}
|
|
45
47
|
if (callback)
|
|
46
48
|
callback();
|
|
47
49
|
((_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.blur) && ((_b = submitRef.current) === null || _b === void 0 ? void 0 : _b.blur());
|
|
@@ -40,8 +40,7 @@ const useProfileForm = (profile, loading, error, update, callback, optionalField
|
|
|
40
40
|
return allFields.filter(i => !toRemove.includes(i.name));
|
|
41
41
|
}, [toRemove]);
|
|
42
42
|
(0, react_1.useEffect)(() => {
|
|
43
|
-
if (loading === 'idle') {
|
|
44
|
-
isSubmitting.current = false;
|
|
43
|
+
if (loading === 'idle' && isSubmitting.current) {
|
|
45
44
|
if (error) {
|
|
46
45
|
const errs = (0, utils_1.makeFormErrors)(error);
|
|
47
46
|
if (errs.birth_date) {
|
|
@@ -50,11 +49,12 @@ const useProfileForm = (profile, loading, error, update, callback, optionalField
|
|
|
50
49
|
}
|
|
51
50
|
setErrors(errs);
|
|
52
51
|
}
|
|
53
|
-
else if (callback
|
|
52
|
+
else if (callback) {
|
|
54
53
|
const payload = makePayload(fields, data);
|
|
55
54
|
if (payload)
|
|
56
55
|
callback(payload);
|
|
57
56
|
}
|
|
57
|
+
isSubmitting.current = false;
|
|
58
58
|
}
|
|
59
59
|
}, [loading, error, callback, fields, data]);
|
|
60
60
|
(0, react_1.useEffect)(() => {
|
|
@@ -34,11 +34,13 @@ export const useAllergenForm = (allergens, selectedAllergens, isLoading = false,
|
|
|
34
34
|
var _a, _b;
|
|
35
35
|
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
36
36
|
setSubmitting(updateAllergens !== null);
|
|
37
|
-
setAllergens(data);
|
|
38
37
|
if (updateAllergens) {
|
|
39
38
|
const newData = data.map(i => ({ allergen_id: i.allergen_id }));
|
|
40
39
|
updateAllergens(newData);
|
|
41
40
|
}
|
|
41
|
+
else {
|
|
42
|
+
setAllergens(data);
|
|
43
|
+
}
|
|
42
44
|
if (callback)
|
|
43
45
|
callback();
|
|
44
46
|
((_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.blur) && ((_b = submitRef.current) === null || _b === void 0 ? void 0 : _b.blur());
|
|
@@ -37,8 +37,7 @@ export const useProfileForm = (profile, loading, error, update, callback, option
|
|
|
37
37
|
return allFields.filter(i => !toRemove.includes(i.name));
|
|
38
38
|
}, [toRemove]);
|
|
39
39
|
useEffect(() => {
|
|
40
|
-
if (loading === 'idle') {
|
|
41
|
-
isSubmitting.current = false;
|
|
40
|
+
if (loading === 'idle' && isSubmitting.current) {
|
|
42
41
|
if (error) {
|
|
43
42
|
const errs = makeFormErrors(error);
|
|
44
43
|
if (errs.birth_date) {
|
|
@@ -47,11 +46,12 @@ export const useProfileForm = (profile, loading, error, update, callback, option
|
|
|
47
46
|
}
|
|
48
47
|
setErrors(errs);
|
|
49
48
|
}
|
|
50
|
-
else if (callback
|
|
49
|
+
else if (callback) {
|
|
51
50
|
const payload = makePayload(fields, data);
|
|
52
51
|
if (payload)
|
|
53
52
|
callback(payload);
|
|
54
53
|
}
|
|
54
|
+
isSubmitting.current = false;
|
|
55
55
|
}
|
|
56
56
|
}, [loading, error, callback, fields, data]);
|
|
57
57
|
useEffect(() => {
|
package/package.json
CHANGED