@open-tender/utils 0.5.28 → 0.5.30

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.
@@ -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 && isSubmitting.current) {
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)(() => {
@@ -105,9 +105,8 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
105
105
  };
106
106
  const resetState = (0, react_1.useCallback)(() => {
107
107
  var _a, _b;
108
- if (loading !== 'idle')
108
+ if (loading !== 'idle' || !submitting)
109
109
  return;
110
- setSubmitting(false);
111
110
  if (error) {
112
111
  const errs = (0, utils_1.makeFormErrors)(error);
113
112
  if (errs.form.includes('parameters')) {
@@ -119,6 +118,8 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
119
118
  else if (guestErrors) {
120
119
  setErrors(guestErrors);
121
120
  }
121
+ setSubmitting(false);
122
+ // eslint-disable-next-line react-hooks/exhaustive-deps
122
123
  }, [loading, error, guestErrors]);
123
124
  (0, react_1.useEffect)(() => {
124
125
  resetState();
@@ -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 && isSubmitting.current) {
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(() => {
@@ -102,9 +102,8 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
102
102
  };
103
103
  const resetState = useCallback(() => {
104
104
  var _a, _b;
105
- if (loading !== 'idle')
105
+ if (loading !== 'idle' || !submitting)
106
106
  return;
107
- setSubmitting(false);
108
107
  if (error) {
109
108
  const errs = makeFormErrors(error);
110
109
  if (errs.form.includes('parameters')) {
@@ -116,6 +115,8 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
116
115
  else if (guestErrors) {
117
116
  setErrors(guestErrors);
118
117
  }
118
+ setSubmitting(false);
119
+ // eslint-disable-next-line react-hooks/exhaustive-deps
119
120
  }, [loading, error, guestErrors]);
120
121
  useEffect(() => {
121
122
  resetState();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.5.28",
3
+ "version": "0.5.30",
4
4
  "description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",