@open-tender/utils 0.1.171 → 0.1.173

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.
@@ -30,7 +30,7 @@ const useLoginForm = (loading, error, login, callback, showPassword = true) => {
30
30
  const fields = allFields.filter(i => !toRemove.includes(i.name));
31
31
  (0, react_1.useEffect)(() => {
32
32
  var _a, _b;
33
- if (loading === 'idle') {
33
+ if (loading === 'idle' && submitting) {
34
34
  setSubmitting(false);
35
35
  if (error) {
36
36
  setErrors((0, utils_1.makeFormErrors)(error));
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { OneTimePasscode, RequestError, RequestStatus } from '@open-tender/types';
3
- export declare const useOneTimePasscodeForm: (otpSent: boolean, loading: RequestStatus, error: RequestError, submit: (data: OneTimePasscode) => void, callback?: () => void) => {
2
+ import { CustomerSignIn, RequestError, RequestStatus } from '@open-tender/types';
3
+ export declare const useOneTimePasscodeForm: (otpSent: boolean, loading: RequestStatus, error: RequestError, submit: (data: CustomerSignIn) => void, callback?: () => void) => {
4
4
  submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
5
5
  inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
6
6
  fields: import("@open-tender/types").FormFieldType[];
@@ -41,7 +41,7 @@ const useOneTimePasscodeForm = (otpSent, loading, error, submit, callback) => {
41
41
  setErrors(errs);
42
42
  ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus());
43
43
  }
44
- else if (callback && submitting && otpSent) {
44
+ else if (callback && otpSent) {
45
45
  setErrors({});
46
46
  callback();
47
47
  }
@@ -31,7 +31,7 @@ const useSignInForm = (email, loading, error, login, callback) => {
31
31
  }
32
32
  }, [email, data.email, data.password]);
33
33
  (0, react_1.useEffect)(() => {
34
- if (loading === 'idle') {
34
+ if (loading === 'idle' && submitting) {
35
35
  setSubmitting(false);
36
36
  if (error) {
37
37
  setErrors((0, utils_1.makeFormErrors)(error));
@@ -40,7 +40,7 @@ const useSignInForm = (email, loading, error, login, callback) => {
40
40
  callback();
41
41
  }
42
42
  }
43
- }, [loading, error, callback]);
43
+ }, [loading, error, callback, submitting]);
44
44
  const handleChange = (name, value) => {
45
45
  setData(Object.assign(Object.assign({}, data), { [name]: value }));
46
46
  };
@@ -27,7 +27,7 @@ export const useLoginForm = (loading, error, login, callback, showPassword = tru
27
27
  const fields = allFields.filter(i => !toRemove.includes(i.name));
28
28
  useEffect(() => {
29
29
  var _a, _b;
30
- if (loading === 'idle') {
30
+ if (loading === 'idle' && submitting) {
31
31
  setSubmitting(false);
32
32
  if (error) {
33
33
  setErrors(makeFormErrors(error));
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { OneTimePasscode, RequestError, RequestStatus } from '@open-tender/types';
3
- export declare const useOneTimePasscodeForm: (otpSent: boolean, loading: RequestStatus, error: RequestError, submit: (data: OneTimePasscode) => void, callback?: () => void) => {
2
+ import { CustomerSignIn, RequestError, RequestStatus } from '@open-tender/types';
3
+ export declare const useOneTimePasscodeForm: (otpSent: boolean, loading: RequestStatus, error: RequestError, submit: (data: CustomerSignIn) => void, callback?: () => void) => {
4
4
  submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
5
5
  inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
6
6
  fields: import("@open-tender/types").FormFieldType[];
@@ -38,7 +38,7 @@ export const useOneTimePasscodeForm = (otpSent, loading, error, submit, callback
38
38
  setErrors(errs);
39
39
  ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus());
40
40
  }
41
- else if (callback && submitting && otpSent) {
41
+ else if (callback && otpSent) {
42
42
  setErrors({});
43
43
  callback();
44
44
  }
@@ -28,7 +28,7 @@ export const useSignInForm = (email, loading, error, login, callback) => {
28
28
  }
29
29
  }, [email, data.email, data.password]);
30
30
  useEffect(() => {
31
- if (loading === 'idle') {
31
+ if (loading === 'idle' && submitting) {
32
32
  setSubmitting(false);
33
33
  if (error) {
34
34
  setErrors(makeFormErrors(error));
@@ -37,7 +37,7 @@ export const useSignInForm = (email, loading, error, login, callback) => {
37
37
  callback();
38
38
  }
39
39
  }
40
- }, [loading, error, callback]);
40
+ }, [loading, error, callback, submitting]);
41
41
  const handleChange = (name, value) => {
42
42
  setData(Object.assign(Object.assign({}, data), { [name]: value }));
43
43
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.1.171",
3
+ "version": "0.1.173",
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",
@@ -54,7 +54,7 @@
54
54
  "typescript": "^4.8.2"
55
55
  },
56
56
  "peerDependencies": {
57
- "@open-tender/types": "^0.2.98",
57
+ "@open-tender/types": "^0.2.102",
58
58
  "@reduxjs/toolkit": "^1.8.5",
59
59
  "react": "^18.2.0"
60
60
  },