@open-tender/utils 0.1.26 → 0.1.27
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.
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export declare const useProfileForm: (profile: Customer, loading: RequestStatus, error: RequestError, update: (data: CustomerCreate) => void
|
|
2
|
+
import { Customer, CustomerCreate, FormFields, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export declare const useProfileForm: (profile: Customer, loading: RequestStatus, error: RequestError, update: (data: CustomerCreate) => void) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
|
-
accepts_marketing: import("@open-tender/types").ConfigAcceptMarketing | null | undefined;
|
|
6
|
-
order_notifications: import("@open-tender/types").ConfigOrderNotifications | null | undefined;
|
|
7
5
|
data: CustomerCreate;
|
|
8
6
|
errors: Record<string, string>;
|
|
9
7
|
submitting: boolean;
|
|
@@ -3,9 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useProfileForm = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
-
const
|
|
6
|
+
const genderOptions = [
|
|
7
|
+
{ name: 'not specified', value: 'DECLINED' },
|
|
8
|
+
{ name: 'Male', value: 'MALE' },
|
|
9
|
+
{ name: 'Female', value: 'FEMALE' }
|
|
10
|
+
];
|
|
11
|
+
const useProfileForm = (profile, loading, error, update
|
|
12
|
+
// optIns: Partial<ConfigBrand> = {}
|
|
13
|
+
) => {
|
|
7
14
|
const submitRef = (0, react_1.useRef)(null);
|
|
8
|
-
const { accepts_marketing, order_notifications } = optIns
|
|
15
|
+
// const { accepts_marketing, order_notifications } = optIns
|
|
9
16
|
const [data, setData] = (0, react_1.useState)(profile);
|
|
10
17
|
const [submitting, setSubmitting] = (0, react_1.useState)(false);
|
|
11
18
|
const [errors, setErrors] = (0, react_1.useState)({});
|
|
@@ -20,7 +27,9 @@ const useProfileForm = (profile, loading, error, update, optIns = {}) => {
|
|
|
20
27
|
autoComplete: 'email'
|
|
21
28
|
},
|
|
22
29
|
{ label: 'Phone', name: 'phone', type: 'tel', required: true },
|
|
23
|
-
{ label: 'Company', name: 'company', type: 'text' }
|
|
30
|
+
{ label: 'Company', name: 'company', type: 'text' },
|
|
31
|
+
{ label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' },
|
|
32
|
+
{ label: 'Gender', name: 'gender', type: 'select', options: genderOptions }
|
|
24
33
|
];
|
|
25
34
|
(0, react_1.useEffect)(() => {
|
|
26
35
|
if (loading === 'idle') {
|
|
@@ -65,8 +74,8 @@ const useProfileForm = (profile, loading, error, update, optIns = {}) => {
|
|
|
65
74
|
};
|
|
66
75
|
return {
|
|
67
76
|
submitRef,
|
|
68
|
-
accepts_marketing,
|
|
69
|
-
order_notifications,
|
|
77
|
+
// accepts_marketing,
|
|
78
|
+
// order_notifications,
|
|
70
79
|
data,
|
|
71
80
|
errors,
|
|
72
81
|
submitting,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export declare const useProfileForm: (profile: Customer, loading: RequestStatus, error: RequestError, update: (data: CustomerCreate) => void
|
|
2
|
+
import { Customer, CustomerCreate, FormFields, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export declare const useProfileForm: (profile: Customer, loading: RequestStatus, error: RequestError, update: (data: CustomerCreate) => void) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
|
-
accepts_marketing: import("@open-tender/types").ConfigAcceptMarketing | null | undefined;
|
|
6
|
-
order_notifications: import("@open-tender/types").ConfigOrderNotifications | null | undefined;
|
|
7
5
|
data: CustomerCreate;
|
|
8
6
|
errors: Record<string, string>;
|
|
9
7
|
submitting: boolean;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { useRef, useState, useEffect } from 'react';
|
|
2
2
|
import { makeBirthDate, makeFormErrors, makePhone, slashesToDashes } from '../utils';
|
|
3
|
-
|
|
3
|
+
const genderOptions = [
|
|
4
|
+
{ name: 'not specified', value: 'DECLINED' },
|
|
5
|
+
{ name: 'Male', value: 'MALE' },
|
|
6
|
+
{ name: 'Female', value: 'FEMALE' }
|
|
7
|
+
];
|
|
8
|
+
export const useProfileForm = (profile, loading, error, update
|
|
9
|
+
// optIns: Partial<ConfigBrand> = {}
|
|
10
|
+
) => {
|
|
4
11
|
const submitRef = useRef(null);
|
|
5
|
-
const { accepts_marketing, order_notifications } = optIns
|
|
12
|
+
// const { accepts_marketing, order_notifications } = optIns
|
|
6
13
|
const [data, setData] = useState(profile);
|
|
7
14
|
const [submitting, setSubmitting] = useState(false);
|
|
8
15
|
const [errors, setErrors] = useState({});
|
|
@@ -17,7 +24,9 @@ export const useProfileForm = (profile, loading, error, update, optIns = {}) =>
|
|
|
17
24
|
autoComplete: 'email'
|
|
18
25
|
},
|
|
19
26
|
{ label: 'Phone', name: 'phone', type: 'tel', required: true },
|
|
20
|
-
{ label: 'Company', name: 'company', type: 'text' }
|
|
27
|
+
{ label: 'Company', name: 'company', type: 'text' },
|
|
28
|
+
{ label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' },
|
|
29
|
+
{ label: 'Gender', name: 'gender', type: 'select', options: genderOptions }
|
|
21
30
|
];
|
|
22
31
|
useEffect(() => {
|
|
23
32
|
if (loading === 'idle') {
|
|
@@ -62,8 +71,8 @@ export const useProfileForm = (profile, loading, error, update, optIns = {}) =>
|
|
|
62
71
|
};
|
|
63
72
|
return {
|
|
64
73
|
submitRef,
|
|
65
|
-
accepts_marketing,
|
|
66
|
-
order_notifications,
|
|
74
|
+
// accepts_marketing,
|
|
75
|
+
// order_notifications,
|
|
67
76
|
data,
|
|
68
77
|
errors,
|
|
69
78
|
submitting,
|
package/package.json
CHANGED