@open-tender/utils 0.3.1 → 0.3.3
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/useCartPoints.d.ts +2 -0
- package/dist/cjs/hooks/useCartPoints.js +4 -0
- package/dist/cjs/hooks/useSignUpForm.d.ts +1 -1
- package/dist/cjs/hooks/useSignUpForm.js +2 -2
- package/dist/cjs/utils/checkout.d.ts +7 -7
- package/dist/esm/hooks/useCartPoints.d.ts +2 -0
- package/dist/esm/hooks/useCartPoints.js +4 -0
- package/dist/esm/hooks/useSignUpForm.d.ts +1 -1
- package/dist/esm/hooks/useSignUpForm.js +2 -2
- package/dist/esm/utils/checkout.d.ts +7 -7
- package/package.json +2 -2
|
@@ -4,6 +4,8 @@ export declare const useCartPoints: (cart: Cart | null, check: CheckoutCheck | n
|
|
|
4
4
|
cartDiff: number;
|
|
5
5
|
cartWithPoints: CartItemWithPoints[];
|
|
6
6
|
points: import("@open-tender/types").CheckoutConfigLoyalty | null | undefined;
|
|
7
|
+
pointsBalance: number;
|
|
8
|
+
pointsRemaining: number;
|
|
7
9
|
pointsApplied: number;
|
|
8
10
|
pointsName: string | null;
|
|
9
11
|
pointsObj: CheckoutPoints | null;
|
|
@@ -6,6 +6,8 @@ const useCartPoints = (cart, check, form, updatePoints) => {
|
|
|
6
6
|
var _a;
|
|
7
7
|
const [cartLength, setCartLength] = (0, react_1.useState)((cart === null || cart === void 0 ? void 0 : cart.length) || 0);
|
|
8
8
|
const { points } = (check === null || check === void 0 ? void 0 : check.config) || {};
|
|
9
|
+
const pointsBalance = points ? parseInt(points.balance) : 0;
|
|
10
|
+
const pointsRemaining = points ? parseInt(points.remaining) : 0;
|
|
9
11
|
const { cart: items = [] } = check || {};
|
|
10
12
|
const itemsPoints = items.length
|
|
11
13
|
? items.reduce((obj, i, index) => {
|
|
@@ -61,6 +63,8 @@ const useCartPoints = (cart, check, form, updatePoints) => {
|
|
|
61
63
|
cartDiff,
|
|
62
64
|
cartWithPoints,
|
|
63
65
|
points,
|
|
66
|
+
pointsBalance,
|
|
67
|
+
pointsRemaining,
|
|
64
68
|
pointsApplied,
|
|
65
69
|
pointsName,
|
|
66
70
|
pointsObj,
|
|
@@ -5,7 +5,7 @@ interface NotificationCheckbox {
|
|
|
5
5
|
name: NotificationChannel;
|
|
6
6
|
type: string;
|
|
7
7
|
}
|
|
8
|
-
export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: ((data: Customer) => void) | undefined) => void, callback?: ((data: Customer) => void) | undefined, checkConfig?: CheckoutConfig, hidePassword?: boolean, optionalFields?: string[], notificationChannels?: NotificationChannel[]) => {
|
|
8
|
+
export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: ((data: Customer) => void) | undefined) => void, callback?: ((data: Customer) => void) | undefined, checkConfig?: CheckoutConfig, hidePassword?: boolean, optionalFields?: string[], notificationChannels?: NotificationChannel[], passwordRequirements?: string) => {
|
|
9
9
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
10
10
|
data: CustomerCreate;
|
|
11
11
|
comms: NotificationChannel[];
|
|
@@ -27,7 +27,7 @@ const notificationChannelFields = [
|
|
|
27
27
|
type: 'checkbox'
|
|
28
28
|
}
|
|
29
29
|
];
|
|
30
|
-
const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePassword = false, optionalFields, notificationChannels) => {
|
|
30
|
+
const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePassword = false, optionalFields, notificationChannels, passwordRequirements) => {
|
|
31
31
|
const submitRef = (0, react_1.useRef)(null);
|
|
32
32
|
const [data, setData] = (0, react_1.useState)(initState);
|
|
33
33
|
const [comms, setComms] = (0, react_1.useState)([]);
|
|
@@ -67,7 +67,7 @@ const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePasswo
|
|
|
67
67
|
autoComplete: 'email'
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
|
-
label:
|
|
70
|
+
label: `Password${passwordRequirements || ''}`,
|
|
71
71
|
name: 'password',
|
|
72
72
|
type: 'password',
|
|
73
73
|
required: true,
|
|
@@ -29,15 +29,15 @@ export declare const updateTenders: (tenders: CheckoutTenders, total: Money) =>
|
|
|
29
29
|
tender_type: import("@open-tender/types").TenderType;
|
|
30
30
|
} | {
|
|
31
31
|
amount: string;
|
|
32
|
-
approved_contact
|
|
33
|
-
domain
|
|
32
|
+
approved_contact?: boolean | undefined;
|
|
33
|
+
domain?: string | null | undefined;
|
|
34
34
|
house_account_id: number;
|
|
35
35
|
name: string;
|
|
36
|
-
order_type
|
|
37
|
-
pin
|
|
38
|
-
revenue_centers
|
|
39
|
-
service_type
|
|
40
|
-
tender_type
|
|
36
|
+
order_type?: import("@open-tender/types").OrderType | null | undefined;
|
|
37
|
+
pin?: string | undefined;
|
|
38
|
+
revenue_centers?: number[] | undefined;
|
|
39
|
+
service_type?: import("@open-tender/types").ServiceType | null | undefined;
|
|
40
|
+
tender_type?: import("@open-tender/types").TenderType | undefined;
|
|
41
41
|
} | {
|
|
42
42
|
amount: string;
|
|
43
43
|
tender_type: import("@open-tender/types").TenderType;
|
|
@@ -4,6 +4,8 @@ export declare const useCartPoints: (cart: Cart | null, check: CheckoutCheck | n
|
|
|
4
4
|
cartDiff: number;
|
|
5
5
|
cartWithPoints: CartItemWithPoints[];
|
|
6
6
|
points: import("@open-tender/types").CheckoutConfigLoyalty | null | undefined;
|
|
7
|
+
pointsBalance: number;
|
|
8
|
+
pointsRemaining: number;
|
|
7
9
|
pointsApplied: number;
|
|
8
10
|
pointsName: string | null;
|
|
9
11
|
pointsObj: CheckoutPoints | null;
|
|
@@ -3,6 +3,8 @@ export const useCartPoints = (cart, check, form, updatePoints) => {
|
|
|
3
3
|
var _a;
|
|
4
4
|
const [cartLength, setCartLength] = useState((cart === null || cart === void 0 ? void 0 : cart.length) || 0);
|
|
5
5
|
const { points } = (check === null || check === void 0 ? void 0 : check.config) || {};
|
|
6
|
+
const pointsBalance = points ? parseInt(points.balance) : 0;
|
|
7
|
+
const pointsRemaining = points ? parseInt(points.remaining) : 0;
|
|
6
8
|
const { cart: items = [] } = check || {};
|
|
7
9
|
const itemsPoints = items.length
|
|
8
10
|
? items.reduce((obj, i, index) => {
|
|
@@ -58,6 +60,8 @@ export const useCartPoints = (cart, check, form, updatePoints) => {
|
|
|
58
60
|
cartDiff,
|
|
59
61
|
cartWithPoints,
|
|
60
62
|
points,
|
|
63
|
+
pointsBalance,
|
|
64
|
+
pointsRemaining,
|
|
61
65
|
pointsApplied,
|
|
62
66
|
pointsName,
|
|
63
67
|
pointsObj,
|
|
@@ -5,7 +5,7 @@ interface NotificationCheckbox {
|
|
|
5
5
|
name: NotificationChannel;
|
|
6
6
|
type: string;
|
|
7
7
|
}
|
|
8
|
-
export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: ((data: Customer) => void) | undefined) => void, callback?: ((data: Customer) => void) | undefined, checkConfig?: CheckoutConfig, hidePassword?: boolean, optionalFields?: string[], notificationChannels?: NotificationChannel[]) => {
|
|
8
|
+
export declare const useSignUpForm: (loading: RequestStatus, error: RequestError, signUp: (data: CustomerCreate, callback?: ((data: Customer) => void) | undefined) => void, callback?: ((data: Customer) => void) | undefined, checkConfig?: CheckoutConfig, hidePassword?: boolean, optionalFields?: string[], notificationChannels?: NotificationChannel[], passwordRequirements?: string) => {
|
|
9
9
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
10
10
|
data: CustomerCreate;
|
|
11
11
|
comms: NotificationChannel[];
|
|
@@ -24,7 +24,7 @@ const notificationChannelFields = [
|
|
|
24
24
|
type: 'checkbox'
|
|
25
25
|
}
|
|
26
26
|
];
|
|
27
|
-
export const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePassword = false, optionalFields, notificationChannels) => {
|
|
27
|
+
export const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePassword = false, optionalFields, notificationChannels, passwordRequirements) => {
|
|
28
28
|
const submitRef = useRef(null);
|
|
29
29
|
const [data, setData] = useState(initState);
|
|
30
30
|
const [comms, setComms] = useState([]);
|
|
@@ -64,7 +64,7 @@ export const useSignUpForm = (loading, error, signUp, callback, checkConfig, hid
|
|
|
64
64
|
autoComplete: 'email'
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
|
-
label:
|
|
67
|
+
label: `Password${passwordRequirements || ''}`,
|
|
68
68
|
name: 'password',
|
|
69
69
|
type: 'password',
|
|
70
70
|
required: true,
|
|
@@ -29,15 +29,15 @@ export declare const updateTenders: (tenders: CheckoutTenders, total: Money) =>
|
|
|
29
29
|
tender_type: import("@open-tender/types").TenderType;
|
|
30
30
|
} | {
|
|
31
31
|
amount: string;
|
|
32
|
-
approved_contact
|
|
33
|
-
domain
|
|
32
|
+
approved_contact?: boolean | undefined;
|
|
33
|
+
domain?: string | null | undefined;
|
|
34
34
|
house_account_id: number;
|
|
35
35
|
name: string;
|
|
36
|
-
order_type
|
|
37
|
-
pin
|
|
38
|
-
revenue_centers
|
|
39
|
-
service_type
|
|
40
|
-
tender_type
|
|
36
|
+
order_type?: import("@open-tender/types").OrderType | null | undefined;
|
|
37
|
+
pin?: string | undefined;
|
|
38
|
+
revenue_centers?: number[] | undefined;
|
|
39
|
+
service_type?: import("@open-tender/types").ServiceType | null | undefined;
|
|
40
|
+
tender_type?: import("@open-tender/types").TenderType | undefined;
|
|
41
41
|
} | {
|
|
42
42
|
amount: string;
|
|
43
43
|
tender_type: import("@open-tender/types").TenderType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
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.
|
|
57
|
+
"@open-tender/types": "^0.3.5",
|
|
58
58
|
"@reduxjs/toolkit": "^1.8.5",
|
|
59
59
|
"react": "^18.2.0"
|
|
60
60
|
},
|