@open-tender/utils 0.1.140 → 0.1.141
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/useGuestCheckoutForm.d.ts +1 -1
- package/dist/cjs/hooks/useGuestCheckoutForm.js +5 -2
- package/dist/cjs/hooks/useSignUpGuestForm.d.ts +1 -1
- package/dist/cjs/hooks/useSignUpGuestForm.js +5 -2
- package/dist/esm/hooks/useGuestCheckoutForm.d.ts +1 -1
- package/dist/esm/hooks/useGuestCheckoutForm.js +5 -2
- package/dist/esm/hooks/useSignUpGuestForm.d.ts +1 -1
- package/dist/esm/hooks/useSignUpGuestForm.js +5 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutFormCustomer, FormFields, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useGuestCheckoutForm: (guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, submit: (data: CheckoutFormCustomer) => void) => {
|
|
3
|
+
export declare const useGuestCheckoutForm: (guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, guestErrors: Record<string, string> | null, submit: (data: CheckoutFormCustomer) => void) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
6
6
|
fields: FormFields;
|
|
@@ -9,7 +9,7 @@ const initialData = {
|
|
|
9
9
|
email: '',
|
|
10
10
|
phone: ''
|
|
11
11
|
};
|
|
12
|
-
const useGuestCheckoutForm = (guest, loading, error, submit) => {
|
|
12
|
+
const useGuestCheckoutForm = (guest, loading, error, guestErrors, submit) => {
|
|
13
13
|
const submitRef = (0, react_1.useRef)(null);
|
|
14
14
|
const inputRef = (0, react_1.useRef)(null);
|
|
15
15
|
const initData = Object.assign(Object.assign({}, initialData), guest);
|
|
@@ -62,8 +62,11 @@ const useGuestCheckoutForm = (guest, loading, error, submit) => {
|
|
|
62
62
|
setErrors(errs);
|
|
63
63
|
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus());
|
|
64
64
|
}
|
|
65
|
+
else if (guestErrors) {
|
|
66
|
+
setErrors(guestErrors);
|
|
67
|
+
}
|
|
65
68
|
}
|
|
66
|
-
}, [loading, error]);
|
|
69
|
+
}, [loading, error, guestErrors]);
|
|
67
70
|
(0, react_1.useEffect)(() => {
|
|
68
71
|
return () => {
|
|
69
72
|
setData(initialData);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutFormCustomer, CustomerCreate, FormFields, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate) => void, submitGuest: (data: CheckoutFormCustomer) => void, hasThanx?: boolean) => {
|
|
3
|
+
export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, guestErrors: Record<string, string> | null, signUp: (data: CustomerCreate) => void, submitGuest: (data: CheckoutFormCustomer) => void, hasThanx?: boolean) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
6
6
|
fields: FormFields;
|
|
@@ -9,7 +9,7 @@ const initialData = {
|
|
|
9
9
|
phone: '',
|
|
10
10
|
password: ''
|
|
11
11
|
};
|
|
12
|
-
const useSignUpGuestForm = (email, guest, loading, error, signUp, submitGuest, hasThanx) => {
|
|
12
|
+
const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, submitGuest, hasThanx) => {
|
|
13
13
|
const submitRef = (0, react_1.useRef)(null);
|
|
14
14
|
const inputRef = (0, react_1.useRef)(null);
|
|
15
15
|
const initData = Object.assign(Object.assign(Object.assign({}, initialData), guest), { email });
|
|
@@ -84,8 +84,11 @@ const useSignUpGuestForm = (email, guest, loading, error, signUp, submitGuest, h
|
|
|
84
84
|
setErrors(errs);
|
|
85
85
|
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus());
|
|
86
86
|
}
|
|
87
|
+
else if (guestErrors) {
|
|
88
|
+
setErrors(guestErrors);
|
|
89
|
+
}
|
|
87
90
|
}
|
|
88
|
-
}, [loading, error]);
|
|
91
|
+
}, [loading, error, guestErrors]);
|
|
89
92
|
(0, react_1.useEffect)(() => {
|
|
90
93
|
return () => {
|
|
91
94
|
setData(Object.assign(Object.assign({}, initialData), { email: '' }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutFormCustomer, FormFields, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useGuestCheckoutForm: (guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, submit: (data: CheckoutFormCustomer) => void) => {
|
|
3
|
+
export declare const useGuestCheckoutForm: (guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, guestErrors: Record<string, string> | null, submit: (data: CheckoutFormCustomer) => void) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
6
6
|
fields: FormFields;
|
|
@@ -6,7 +6,7 @@ const initialData = {
|
|
|
6
6
|
email: '',
|
|
7
7
|
phone: ''
|
|
8
8
|
};
|
|
9
|
-
export const useGuestCheckoutForm = (guest, loading, error, submit) => {
|
|
9
|
+
export const useGuestCheckoutForm = (guest, loading, error, guestErrors, submit) => {
|
|
10
10
|
const submitRef = useRef(null);
|
|
11
11
|
const inputRef = useRef(null);
|
|
12
12
|
const initData = Object.assign(Object.assign({}, initialData), guest);
|
|
@@ -59,8 +59,11 @@ export const useGuestCheckoutForm = (guest, loading, error, submit) => {
|
|
|
59
59
|
setErrors(errs);
|
|
60
60
|
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus());
|
|
61
61
|
}
|
|
62
|
+
else if (guestErrors) {
|
|
63
|
+
setErrors(guestErrors);
|
|
64
|
+
}
|
|
62
65
|
}
|
|
63
|
-
}, [loading, error]);
|
|
66
|
+
}, [loading, error, guestErrors]);
|
|
64
67
|
useEffect(() => {
|
|
65
68
|
return () => {
|
|
66
69
|
setData(initialData);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutFormCustomer, CustomerCreate, FormFields, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate) => void, submitGuest: (data: CheckoutFormCustomer) => void, hasThanx?: boolean) => {
|
|
3
|
+
export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, guestErrors: Record<string, string> | null, signUp: (data: CustomerCreate) => void, submitGuest: (data: CheckoutFormCustomer) => void, hasThanx?: boolean) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
6
6
|
fields: FormFields;
|
|
@@ -6,7 +6,7 @@ const initialData = {
|
|
|
6
6
|
phone: '',
|
|
7
7
|
password: ''
|
|
8
8
|
};
|
|
9
|
-
export const useSignUpGuestForm = (email, guest, loading, error, signUp, submitGuest, hasThanx) => {
|
|
9
|
+
export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, submitGuest, hasThanx) => {
|
|
10
10
|
const submitRef = useRef(null);
|
|
11
11
|
const inputRef = useRef(null);
|
|
12
12
|
const initData = Object.assign(Object.assign(Object.assign({}, initialData), guest), { email });
|
|
@@ -81,8 +81,11 @@ export const useSignUpGuestForm = (email, guest, loading, error, signUp, submitG
|
|
|
81
81
|
setErrors(errs);
|
|
82
82
|
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus());
|
|
83
83
|
}
|
|
84
|
+
else if (guestErrors) {
|
|
85
|
+
setErrors(guestErrors);
|
|
86
|
+
}
|
|
84
87
|
}
|
|
85
|
-
}, [loading, error]);
|
|
88
|
+
}, [loading, error, guestErrors]);
|
|
86
89
|
useEffect(() => {
|
|
87
90
|
return () => {
|
|
88
91
|
setData(Object.assign(Object.assign({}, initialData), { email: '' }));
|
package/package.json
CHANGED