@open-tender/utils 0.1.80 → 0.1.82
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.
- package/dist/cjs/hooks/useProfileForm.js +1 -5
- package/dist/cjs/hooks/useSignUpForm.d.ts +2 -2
- package/dist/cjs/hooks/useSignUpForm.js +1 -1
- package/dist/cjs/utils/errors.js +3 -0
- package/dist/esm/hooks/useProfileForm.js +1 -5
- package/dist/esm/hooks/useSignUpForm.d.ts +2 -2
- package/dist/esm/hooks/useSignUpForm.js +1 -1
- package/dist/esm/utils/errors.js +3 -0
- package/package.json +1 -1
|
@@ -52,11 +52,7 @@ const useProfileForm = (profile, loading, error, update, callback
|
|
|
52
52
|
if (loading === 'idle') {
|
|
53
53
|
setSubmitting(false);
|
|
54
54
|
if (error) {
|
|
55
|
-
|
|
56
|
-
if (errs.birth_date) {
|
|
57
|
-
errs.birth_date = 'Invalid date. Please enter in mm/dd/yyyy format.';
|
|
58
|
-
}
|
|
59
|
-
setErrors(errs);
|
|
55
|
+
setErrors((0, utils_1.makeFormErrors)(error));
|
|
60
56
|
}
|
|
61
57
|
else if (callback && submitting) {
|
|
62
58
|
const payload = makePayload(fields, data);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { CheckoutConfig, CustomerCreate, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: () => void) => void, callback?: () => void, checkConfig?:
|
|
2
|
+
import { CheckoutConfig, Customer, CustomerCreate, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: ((data: Customer) => void) | undefined) => void, callback?: ((data: Customer) => void) | undefined, checkConfig?: CheckoutConfig, hasThanx?: boolean) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
data: CustomerCreate;
|
|
6
6
|
errors: Record<string, string>;
|
|
@@ -10,7 +10,7 @@ const initState = {
|
|
|
10
10
|
email: '',
|
|
11
11
|
phone: ''
|
|
12
12
|
};
|
|
13
|
-
const useSignUpForm = (loading, error, signUp, callback, checkConfig
|
|
13
|
+
const useSignUpForm = (loading, error, signUp, callback, checkConfig, hasThanx = false) => {
|
|
14
14
|
const submitRef = (0, react_1.useRef)(null);
|
|
15
15
|
const [data, setData] = (0, react_1.useState)(initState);
|
|
16
16
|
const [errors, setErrors] = (0, react_1.useState)({});
|
package/dist/cjs/utils/errors.js
CHANGED
|
@@ -49,6 +49,9 @@ const processError = (msg) => {
|
|
|
49
49
|
else if (msg.includes("not a 'user-password'")) {
|
|
50
50
|
return exports.errMessages.invalidPassword;
|
|
51
51
|
}
|
|
52
|
+
else if (msg.includes("not a 'optional-date'")) {
|
|
53
|
+
return exports.errMessages.invalidDate;
|
|
54
|
+
}
|
|
52
55
|
return msg;
|
|
53
56
|
};
|
|
54
57
|
exports.processError = processError;
|
|
@@ -49,11 +49,7 @@ export const useProfileForm = (profile, loading, error, update, callback
|
|
|
49
49
|
if (loading === 'idle') {
|
|
50
50
|
setSubmitting(false);
|
|
51
51
|
if (error) {
|
|
52
|
-
|
|
53
|
-
if (errs.birth_date) {
|
|
54
|
-
errs.birth_date = 'Invalid date. Please enter in mm/dd/yyyy format.';
|
|
55
|
-
}
|
|
56
|
-
setErrors(errs);
|
|
52
|
+
setErrors(makeFormErrors(error));
|
|
57
53
|
}
|
|
58
54
|
else if (callback && submitting) {
|
|
59
55
|
const payload = makePayload(fields, data);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { CheckoutConfig, CustomerCreate, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: () => void) => void, callback?: () => void, checkConfig?:
|
|
2
|
+
import { CheckoutConfig, Customer, CustomerCreate, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: ((data: Customer) => void) | undefined) => void, callback?: ((data: Customer) => void) | undefined, checkConfig?: CheckoutConfig, hasThanx?: boolean) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
data: CustomerCreate;
|
|
6
6
|
errors: Record<string, string>;
|
|
@@ -7,7 +7,7 @@ const initState = {
|
|
|
7
7
|
email: '',
|
|
8
8
|
phone: ''
|
|
9
9
|
};
|
|
10
|
-
export const useSignUpForm = (loading, error, signUp, callback, checkConfig
|
|
10
|
+
export const useSignUpForm = (loading, error, signUp, callback, checkConfig, hasThanx = false) => {
|
|
11
11
|
const submitRef = useRef(null);
|
|
12
12
|
const [data, setData] = useState(initState);
|
|
13
13
|
const [errors, setErrors] = useState({});
|
package/dist/esm/utils/errors.js
CHANGED
|
@@ -45,6 +45,9 @@ export const processError = (msg) => {
|
|
|
45
45
|
else if (msg.includes("not a 'user-password'")) {
|
|
46
46
|
return errMessages.invalidPassword;
|
|
47
47
|
}
|
|
48
|
+
else if (msg.includes("not a 'optional-date'")) {
|
|
49
|
+
return errMessages.invalidDate;
|
|
50
|
+
}
|
|
48
51
|
return msg;
|
|
49
52
|
};
|
|
50
53
|
export const handleFormErrors = (params) => {
|
package/package.json
CHANGED