@open-tender/utils 0.5.19 → 0.5.21
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/useLoginForm.d.ts +2 -2
- package/dist/cjs/hooks/useLoginForm.js +7 -11
- package/dist/cjs/hooks/useMenuItem.d.ts +1 -0
- package/dist/cjs/hooks/useModifier.d.ts +1 -0
- package/dist/cjs/hooks/useOrderItem.d.ts +1 -0
- package/dist/cjs/utils/cart.d.ts +2 -0
- package/dist/cjs/utils/cart.js +2 -0
- package/dist/esm/hooks/useLoginForm.d.ts +2 -2
- package/dist/esm/hooks/useLoginForm.js +7 -11
- package/dist/esm/hooks/useMenuItem.d.ts +1 -0
- package/dist/esm/hooks/useModifier.d.ts +1 -0
- package/dist/esm/hooks/useOrderItem.d.ts +1 -0
- package/dist/esm/utils/cart.d.ts +2 -0
- package/dist/esm/utils/cart.js +2 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LoginData, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useLoginForm: (loading: RequestStatus, error: RequestError, login: (email: string, password?: string, recaptcha_token?: string) => void,
|
|
3
|
+
export declare const useLoginForm: (loading: RequestStatus, error: RequestError, login: (email: string, password?: string, recaptcha_token?: string) => void, recaptchaKey: string | null, callback?: () => void, showPassword?: boolean) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
6
6
|
recaptchaRef: import("react").MutableRefObject<any>;
|
|
@@ -9,5 +9,5 @@ export declare const useLoginForm: (loading: RequestStatus, error: RequestError,
|
|
|
9
9
|
errors: Record<string, string>;
|
|
10
10
|
submitting: boolean;
|
|
11
11
|
handleChange: (name: string, value: string | number | boolean) => void;
|
|
12
|
-
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) =>
|
|
12
|
+
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
13
13
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useLoginForm = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const react_1 = require("react");
|
|
6
5
|
const utils_1 = require("../utils");
|
|
7
|
-
const useLoginForm = (loading, error, login,
|
|
6
|
+
const useLoginForm = (loading, error, login, recaptchaKey, callback, showPassword = true) => {
|
|
8
7
|
const submitRef = (0, react_1.useRef)(null);
|
|
9
8
|
const inputRef = (0, react_1.useRef)(null);
|
|
10
9
|
const recaptchaRef = (0, react_1.useRef)(null);
|
|
@@ -48,16 +47,13 @@ const useLoginForm = (loading, error, login, includeRecaptcha, callback, showPas
|
|
|
48
47
|
const handleChange = (name, value) => {
|
|
49
48
|
setData(Object.assign(Object.assign({}, data), { [name]: value }));
|
|
50
49
|
};
|
|
51
|
-
const handleSubmit = (evt) =>
|
|
52
|
-
var _a, _b, _c
|
|
50
|
+
const handleSubmit = (evt) => {
|
|
51
|
+
var _a, _b, _c;
|
|
53
52
|
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
54
53
|
const { email, password } = data;
|
|
55
|
-
if (
|
|
54
|
+
if (recaptchaKey) {
|
|
56
55
|
try {
|
|
57
|
-
const
|
|
58
|
-
const token = isEnterpriseRecaptcha
|
|
59
|
-
? yield ((_b = recaptchaRef.current) === null || _b === void 0 ? void 0 : _b.executeAsync())
|
|
60
|
-
: (_c = recaptchaRef.current) === null || _c === void 0 ? void 0 : _c.getValue();
|
|
56
|
+
const token = (_a = recaptchaRef.current) === null || _a === void 0 ? void 0 : _a.getValue();
|
|
61
57
|
if (!token) {
|
|
62
58
|
setSubmitting(false);
|
|
63
59
|
setErrors({
|
|
@@ -82,8 +78,8 @@ const useLoginForm = (loading, error, login, includeRecaptcha, callback, showPas
|
|
|
82
78
|
login(email, password);
|
|
83
79
|
setSubmitting(true);
|
|
84
80
|
}
|
|
85
|
-
((
|
|
86
|
-
}
|
|
81
|
+
((_b = submitRef.current) === null || _b === void 0 ? void 0 : _b.blur) && ((_c = submitRef.current) === null || _c === void 0 ? void 0 : _c.blur());
|
|
82
|
+
};
|
|
87
83
|
return {
|
|
88
84
|
submitRef,
|
|
89
85
|
inputRef,
|
|
@@ -56,6 +56,7 @@ export declare const useMenuItem: (builtItem: CartItem, auth: Auth | null, looku
|
|
|
56
56
|
shortDescription: string | null;
|
|
57
57
|
shortName: string;
|
|
58
58
|
slug: string;
|
|
59
|
+
suspend_until: number | null;
|
|
59
60
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
60
61
|
totalCals: number | null;
|
|
61
62
|
totalPrice: number | null;
|
|
@@ -47,6 +47,7 @@ export declare const useModifier: (group: CartItemGroup, option: CartItemOption,
|
|
|
47
47
|
shortDescription: string | null;
|
|
48
48
|
shortName: string;
|
|
49
49
|
slug: string;
|
|
50
|
+
suspend_until: number | null;
|
|
50
51
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
51
52
|
totalAllergens: string[];
|
|
52
53
|
totalCals: number | null;
|
|
@@ -45,6 +45,7 @@ export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavo
|
|
|
45
45
|
shortDescription: string | null;
|
|
46
46
|
shortName: string;
|
|
47
47
|
slug: string;
|
|
48
|
+
suspend_until: number | null;
|
|
48
49
|
tags: string[];
|
|
49
50
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
50
51
|
totalAllergens: string[];
|
package/dist/cjs/utils/cart.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Simp
|
|
|
50
50
|
shortDescription: string | null;
|
|
51
51
|
shortName: string;
|
|
52
52
|
slug: string;
|
|
53
|
+
suspend_until: number | null;
|
|
53
54
|
tags: string[];
|
|
54
55
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
55
56
|
totalAllergens: string[];
|
|
@@ -147,6 +148,7 @@ export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: Cart
|
|
|
147
148
|
shortDescription: string | null;
|
|
148
149
|
shortName: string;
|
|
149
150
|
slug: string;
|
|
151
|
+
suspend_until: number | null;
|
|
150
152
|
tags: string[];
|
|
151
153
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
152
154
|
totalAllergens: string[];
|
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -237,6 +237,7 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = [], requestedAt = n
|
|
|
237
237
|
ingredients: o.ingredients,
|
|
238
238
|
isDefault: o.opt_is_default,
|
|
239
239
|
isSoldOut: isSoldOut,
|
|
240
|
+
suspend_until: o.suspend_until,
|
|
240
241
|
max: isSoldOut ? 0 : o.max_quantity,
|
|
241
242
|
min: o.min_quantity,
|
|
242
243
|
name: o.name,
|
|
@@ -301,6 +302,7 @@ const makeOrderItem = (item, isEdit, soldOut = [], simpleItem, hasPoints = false
|
|
|
301
302
|
//index: null,
|
|
302
303
|
ingredients: item.ingredients,
|
|
303
304
|
isSoldOut: isSoldOut,
|
|
305
|
+
suspend_until: item.suspend_until,
|
|
304
306
|
madeFor: simpleItem ? simpleItem.made_for || null : null,
|
|
305
307
|
max: item.max_quantity,
|
|
306
308
|
min: item.min_quantity,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LoginData, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useLoginForm: (loading: RequestStatus, error: RequestError, login: (email: string, password?: string, recaptcha_token?: string) => void,
|
|
3
|
+
export declare const useLoginForm: (loading: RequestStatus, error: RequestError, login: (email: string, password?: string, recaptcha_token?: string) => void, recaptchaKey: string | null, callback?: () => void, showPassword?: boolean) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
6
6
|
recaptchaRef: import("react").MutableRefObject<any>;
|
|
@@ -9,5 +9,5 @@ export declare const useLoginForm: (loading: RequestStatus, error: RequestError,
|
|
|
9
9
|
errors: Record<string, string>;
|
|
10
10
|
submitting: boolean;
|
|
11
11
|
handleChange: (name: string, value: string | number | boolean) => void;
|
|
12
|
-
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) =>
|
|
12
|
+
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
13
13
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
1
|
import { useState, useEffect, useRef } from 'react';
|
|
3
2
|
import { makeFormErrors } from '../utils';
|
|
4
|
-
export const useLoginForm = (loading, error, login,
|
|
3
|
+
export const useLoginForm = (loading, error, login, recaptchaKey, callback, showPassword = true) => {
|
|
5
4
|
const submitRef = useRef(null);
|
|
6
5
|
const inputRef = useRef(null);
|
|
7
6
|
const recaptchaRef = useRef(null);
|
|
@@ -45,16 +44,13 @@ export const useLoginForm = (loading, error, login, includeRecaptcha, callback,
|
|
|
45
44
|
const handleChange = (name, value) => {
|
|
46
45
|
setData(Object.assign(Object.assign({}, data), { [name]: value }));
|
|
47
46
|
};
|
|
48
|
-
const handleSubmit = (evt) =>
|
|
49
|
-
var _a, _b, _c
|
|
47
|
+
const handleSubmit = (evt) => {
|
|
48
|
+
var _a, _b, _c;
|
|
50
49
|
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
51
50
|
const { email, password } = data;
|
|
52
|
-
if (
|
|
51
|
+
if (recaptchaKey) {
|
|
53
52
|
try {
|
|
54
|
-
const
|
|
55
|
-
const token = isEnterpriseRecaptcha
|
|
56
|
-
? yield ((_b = recaptchaRef.current) === null || _b === void 0 ? void 0 : _b.executeAsync())
|
|
57
|
-
: (_c = recaptchaRef.current) === null || _c === void 0 ? void 0 : _c.getValue();
|
|
53
|
+
const token = (_a = recaptchaRef.current) === null || _a === void 0 ? void 0 : _a.getValue();
|
|
58
54
|
if (!token) {
|
|
59
55
|
setSubmitting(false);
|
|
60
56
|
setErrors({
|
|
@@ -79,8 +75,8 @@ export const useLoginForm = (loading, error, login, includeRecaptcha, callback,
|
|
|
79
75
|
login(email, password);
|
|
80
76
|
setSubmitting(true);
|
|
81
77
|
}
|
|
82
|
-
((
|
|
83
|
-
}
|
|
78
|
+
((_b = submitRef.current) === null || _b === void 0 ? void 0 : _b.blur) && ((_c = submitRef.current) === null || _c === void 0 ? void 0 : _c.blur());
|
|
79
|
+
};
|
|
84
80
|
return {
|
|
85
81
|
submitRef,
|
|
86
82
|
inputRef,
|
|
@@ -56,6 +56,7 @@ export declare const useMenuItem: (builtItem: CartItem, auth: Auth | null, looku
|
|
|
56
56
|
shortDescription: string | null;
|
|
57
57
|
shortName: string;
|
|
58
58
|
slug: string;
|
|
59
|
+
suspend_until: number | null;
|
|
59
60
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
60
61
|
totalCals: number | null;
|
|
61
62
|
totalPrice: number | null;
|
|
@@ -47,6 +47,7 @@ export declare const useModifier: (group: CartItemGroup, option: CartItemOption,
|
|
|
47
47
|
shortDescription: string | null;
|
|
48
48
|
shortName: string;
|
|
49
49
|
slug: string;
|
|
50
|
+
suspend_until: number | null;
|
|
50
51
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
51
52
|
totalAllergens: string[];
|
|
52
53
|
totalCals: number | null;
|
|
@@ -45,6 +45,7 @@ export declare const useOrderItem: (orderItem: CartItem, favorite?: MenuItemFavo
|
|
|
45
45
|
shortDescription: string | null;
|
|
46
46
|
shortName: string;
|
|
47
47
|
slug: string;
|
|
48
|
+
suspend_until: number | null;
|
|
48
49
|
tags: string[];
|
|
49
50
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
50
51
|
totalAllergens: string[];
|
package/dist/esm/utils/cart.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export declare const rehydrateCart: (menuItems: MenuItems, simpleCartItems: Simp
|
|
|
50
50
|
shortDescription: string | null;
|
|
51
51
|
shortName: string;
|
|
52
52
|
slug: string;
|
|
53
|
+
suspend_until: number | null;
|
|
53
54
|
tags: string[];
|
|
54
55
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
55
56
|
totalAllergens: string[];
|
|
@@ -147,6 +148,7 @@ export declare const combineCarts: (cart: Cart, guestCart: Cart, cartOwner: Cart
|
|
|
147
148
|
shortDescription: string | null;
|
|
148
149
|
shortName: string;
|
|
149
150
|
slug: string;
|
|
151
|
+
suspend_until: number | null;
|
|
150
152
|
tags: string[];
|
|
151
153
|
tags_list?: import("@open-tender/types").MenuItemTags | undefined;
|
|
152
154
|
totalAllergens: string[];
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -222,6 +222,7 @@ const makeOrderItemGroups = (optionGroups, isEdit, soldOut = [], requestedAt = n
|
|
|
222
222
|
ingredients: o.ingredients,
|
|
223
223
|
isDefault: o.opt_is_default,
|
|
224
224
|
isSoldOut: isSoldOut,
|
|
225
|
+
suspend_until: o.suspend_until,
|
|
225
226
|
max: isSoldOut ? 0 : o.max_quantity,
|
|
226
227
|
min: o.min_quantity,
|
|
227
228
|
name: o.name,
|
|
@@ -286,6 +287,7 @@ export const makeOrderItem = (item, isEdit, soldOut = [], simpleItem, hasPoints
|
|
|
286
287
|
//index: null,
|
|
287
288
|
ingredients: item.ingredients,
|
|
288
289
|
isSoldOut: isSoldOut,
|
|
290
|
+
suspend_until: item.suspend_until,
|
|
289
291
|
madeFor: simpleItem ? simpleItem.made_for || null : null,
|
|
290
292
|
max: item.max_quantity,
|
|
291
293
|
min: item.min_quantity,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.21",
|
|
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",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"typescript": "^4.8.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@open-tender/types": "^0.4.
|
|
60
|
+
"@open-tender/types": "^0.4.140",
|
|
61
61
|
"@reduxjs/toolkit": "^1.8.5",
|
|
62
62
|
"react": "^18.2.0"
|
|
63
63
|
},
|