@open-tender/utils 0.5.69 → 0.5.71
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/useAccordion.d.ts +1 -1
- package/dist/cjs/hooks/useAccordion.js +1 -7
- package/dist/cjs/hooks/useBuilder.d.ts +1 -3
- package/dist/cjs/hooks/useBuilder.js +1 -10
- package/dist/cjs/hooks/useCreditCardForm.d.ts +1 -1
- package/dist/cjs/hooks/useCreditCardForm.js +3 -1
- package/dist/cjs/hooks/useDonationForm.d.ts +1 -1
- package/dist/cjs/hooks/useDonationForm.js +3 -1
- package/dist/cjs/hooks/useGiftCardsForm.d.ts +1 -1
- package/dist/cjs/hooks/useGiftCardsForm.js +3 -1
- package/dist/cjs/utils/cart.js +4 -4
- package/dist/esm/hooks/useAccordion.d.ts +1 -1
- package/dist/esm/hooks/useAccordion.js +1 -7
- package/dist/esm/hooks/useBuilder.d.ts +1 -3
- package/dist/esm/hooks/useBuilder.js +1 -10
- package/dist/esm/hooks/useCreditCardForm.d.ts +1 -1
- package/dist/esm/hooks/useCreditCardForm.js +3 -1
- package/dist/esm/hooks/useDonationForm.d.ts +1 -1
- package/dist/esm/hooks/useDonationForm.js +3 -1
- package/dist/esm/hooks/useGiftCardsForm.d.ts +1 -1
- package/dist/esm/hooks/useGiftCardsForm.js +3 -1
- package/dist/esm/utils/cart.js +4 -4
- package/package.json +3 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CartItem, CartLevels, ConfigAccordion } from '@open-tender/types';
|
|
3
|
-
export declare const useAccordion: (builtItem: CartItem, toggleOption: (levels: CartLevels) => void, cartId?: number | null, config?: ConfigAccordion
|
|
3
|
+
export declare const useAccordion: (builtItem: CartItem, toggleOption: (levels: CartLevels) => void, cartId?: number | null, config?: ConfigAccordion) => {
|
|
4
4
|
open: string | null;
|
|
5
5
|
setOpen: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
6
6
|
groups: import("@open-tender/types").CartItemGroups;
|
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useAccordion = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
-
const useAccordion = (builtItem, toggleOption, cartId, config
|
|
7
|
-
) => {
|
|
6
|
+
const useAccordion = (builtItem, toggleOption, cartId, config) => {
|
|
8
7
|
var _a;
|
|
9
8
|
const { hasCals: showCals = false, hasCustomize = false, hasMadeFor: showMadeFor = true, hasNotes: showNotes = true } = config || {};
|
|
10
9
|
const [open, setOpen] = (0, react_1.useState)(null);
|
|
@@ -30,11 +29,6 @@ const useAccordion = (builtItem, toggleOption, cartId, config, setImageUrl //
|
|
|
30
29
|
const toggleSize = (optionId) => {
|
|
31
30
|
if (sizeGroup) {
|
|
32
31
|
toggleOption([[sizeGroup.id, optionId]]);
|
|
33
|
-
if (setImageUrl) {
|
|
34
|
-
const selectedOption = sizeGroup.options.find(o => o.id === optionId);
|
|
35
|
-
if (selectedOption && (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.imageUrl))
|
|
36
|
-
setImageUrl(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.imageUrl);
|
|
37
|
-
}
|
|
38
32
|
setOpen(null);
|
|
39
33
|
}
|
|
40
34
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CartItem,
|
|
1
|
+
import { CartItem, CartLevels } from '@open-tender/types';
|
|
2
2
|
export declare const useBuilder: (orderItem: CartItem, orderTimeoutCallback?: () => void) => {
|
|
3
3
|
item: CartItem;
|
|
4
4
|
increment: () => void;
|
|
@@ -11,6 +11,4 @@ export declare const useBuilder: (orderItem: CartItem, orderTimeoutCallback?: ()
|
|
|
11
11
|
incrementOption: (levels: CartLevels) => CartItem;
|
|
12
12
|
decrementOption: (levels: CartLevels) => CartItem;
|
|
13
13
|
setOptionQuantity: (levels: CartLevels, quantity: number) => CartItem;
|
|
14
|
-
setGroups: (groups: CartItemGroups) => void;
|
|
15
|
-
setImageUrl: (imageUrl: string | null) => void;
|
|
16
14
|
};
|
|
@@ -134,13 +134,6 @@ const useBuilder = (orderItem, orderTimeoutCallback) => {
|
|
|
134
134
|
setItem(pricedItem);
|
|
135
135
|
return pricedItem;
|
|
136
136
|
};
|
|
137
|
-
const setGroups = (groups) => {
|
|
138
|
-
const pricedItem = (0, utils_1.calcPrices)(Object.assign(Object.assign({}, item), { groups }));
|
|
139
|
-
setItem(pricedItem);
|
|
140
|
-
};
|
|
141
|
-
const setImageUrl = (imageUrl) => {
|
|
142
|
-
setItem(prev => (Object.assign(Object.assign({}, prev), { imageUrl })));
|
|
143
|
-
};
|
|
144
137
|
return {
|
|
145
138
|
item,
|
|
146
139
|
increment,
|
|
@@ -152,9 +145,7 @@ const useBuilder = (orderItem, orderTimeoutCallback) => {
|
|
|
152
145
|
toggleOption,
|
|
153
146
|
incrementOption,
|
|
154
147
|
decrementOption,
|
|
155
|
-
setOptionQuantity
|
|
156
|
-
setGroups,
|
|
157
|
-
setImageUrl
|
|
148
|
+
setOptionQuantity
|
|
158
149
|
};
|
|
159
150
|
};
|
|
160
151
|
exports.useBuilder = useBuilder;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CardType, CreditCardData, CreditCardErrors, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useCreditCardForm: (loading: RequestStatus, error: RequestError, data: CreditCardData | null, cardType: CardType | null, addCard: (data: CreditCardData, callback: () => void) => void, callback: () => void, includeRecaptcha: boolean | undefined, revenue_center_id: number | null, kountSessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
3
|
+
export declare const useCreditCardForm: (loading: RequestStatus, error: RequestError, data: CreditCardData | null, cardType: CardType | null, addCard: (data: CreditCardData, callback: () => void) => void, callback: () => void, includeRecaptcha: boolean | undefined, revenue_center_id: number | null, kountSessionId?: string | null, sessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
data: CreditCardData | null;
|
|
6
6
|
errors: Record<string, string> | CreditCardErrors;
|
|
@@ -4,7 +4,7 @@ exports.useCreditCardForm = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const __1 = require("../");
|
|
7
|
-
const useCreditCardForm = (loading, error, data, cardType, addCard, callback, includeRecaptcha, revenue_center_id, kountSessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
7
|
+
const useCreditCardForm = (loading, error, data, cardType, addCard, callback, includeRecaptcha, revenue_center_id, kountSessionId, sessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
8
8
|
const submitRef = (0, react_1.useRef)(null);
|
|
9
9
|
const [submitting, setSubmitting] = (0, react_1.useState)(false);
|
|
10
10
|
const [errors, setErrors] = (0, react_1.useState)({});
|
|
@@ -31,6 +31,8 @@ const useCreditCardForm = (loading, error, data, cardType, addCard, callback, in
|
|
|
31
31
|
const cardRc = revenue_center_id ? Object.assign(Object.assign({}, card), { revenue_center_id }) : card;
|
|
32
32
|
if (kountSessionId)
|
|
33
33
|
cardRc.kount_device_session_id = kountSessionId;
|
|
34
|
+
if (sessionId)
|
|
35
|
+
cardRc.session_id = sessionId;
|
|
34
36
|
if (includeRecaptcha) {
|
|
35
37
|
try {
|
|
36
38
|
const token = yield (getRecaptchaToken === null || getRecaptchaToken === void 0 ? void 0 : getRecaptchaToken());
|
|
@@ -3,7 +3,7 @@ import { CardType, CreditCardData, CreditCardSaved, CreditCards, Customer, Donat
|
|
|
3
3
|
export declare const useDonationsForm: (purchase: (data: DonationPurchase, callback?: () => void) => void, reset: () => void, setAlert: (data: {
|
|
4
4
|
type: string;
|
|
5
5
|
args?: unknown;
|
|
6
|
-
}) => void, loading: RequestStatus, error: RequestError, success: boolean, customer?: Customer, creditCards?: CreditCards, includeRecaptcha?: boolean, cardData?: CreditCardData, cardType?: CardType, windowRef?: Window, kountSessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
6
|
+
}) => void, loading: RequestStatus, error: RequestError, success: boolean, customer?: Customer, creditCards?: CreditCards, includeRecaptcha?: boolean, cardData?: CreditCardData, cardType?: CardType, windowRef?: Window, kountSessionId?: string | null, sessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
7
7
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
8
8
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
9
9
|
amount: string | null;
|
|
@@ -4,7 +4,7 @@ exports.useDonationsForm = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
|
-
const useDonationsForm = (purchase, reset, setAlert, loading, error, success, customer, creditCards, includeRecaptcha, cardData, cardType, windowRef, kountSessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
7
|
+
const useDonationsForm = (purchase, reset, setAlert, loading, error, success, customer, creditCards, includeRecaptcha, cardData, cardType, windowRef, kountSessionId, sessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
8
8
|
const submitRef = (0, react_1.useRef)(null);
|
|
9
9
|
const inputRef = (0, react_1.useRef)(null);
|
|
10
10
|
const [amount, setAmount] = (0, react_1.useState)('');
|
|
@@ -78,6 +78,8 @@ const useDonationsForm = (purchase, reset, setAlert, loading, error, success, cu
|
|
|
78
78
|
};
|
|
79
79
|
if (kountSessionId)
|
|
80
80
|
formData.kount_device_session_id = kountSessionId;
|
|
81
|
+
if (sessionId)
|
|
82
|
+
formData.session_id = sessionId;
|
|
81
83
|
if (includeRecaptcha) {
|
|
82
84
|
try {
|
|
83
85
|
const token = yield (getRecaptchaToken === null || getRecaptchaToken === void 0 ? void 0 : getRecaptchaToken());
|
|
@@ -3,7 +3,7 @@ import { CardType, CreditCardData, CreditCardSaved, CreditCards, Customer, GiftC
|
|
|
3
3
|
export declare const useGiftCardsForm: (purchase: (data: GiftCardsPurchase, callback?: () => void) => void, reset: () => void, setAlert: (data: {
|
|
4
4
|
type: string;
|
|
5
5
|
args?: unknown;
|
|
6
|
-
}) => void, loading: RequestStatus, error: RequestError, success: boolean, initState: GiftCardPurchaseData, customer?: Customer | null, creditCards?: CreditCards, includeRecaptcha?: boolean, cardData?: CreditCardData, cardType?: CardType, url?: string, kountSessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
6
|
+
}) => void, loading: RequestStatus, error: RequestError, success: boolean, initState: GiftCardPurchaseData, customer?: Customer | null, creditCards?: CreditCards, includeRecaptcha?: boolean, cardData?: CreditCardData, cardType?: CardType, url?: string, kountSessionId?: string | null, sessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
7
7
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
8
8
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
9
9
|
creditCardOptions: {
|
|
@@ -4,7 +4,7 @@ exports.useGiftCardsForm = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
|
-
const useGiftCardsForm = (purchase, reset, setAlert, loading, error, success, initState, customer, creditCards, includeRecaptcha, cardData, cardType, url, kountSessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
7
|
+
const useGiftCardsForm = (purchase, reset, setAlert, loading, error, success, initState, customer, creditCards, includeRecaptcha, cardData, cardType, url, kountSessionId, sessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
8
8
|
const submitRef = (0, react_1.useRef)(null);
|
|
9
9
|
const inputRef = (0, react_1.useRef)(null);
|
|
10
10
|
const [name, setName] = (0, react_1.useState)(null);
|
|
@@ -99,6 +99,8 @@ const useGiftCardsForm = (purchase, reset, setAlert, loading, error, success, in
|
|
|
99
99
|
};
|
|
100
100
|
if (kountSessionId)
|
|
101
101
|
formData.kount_device_session_id = kountSessionId;
|
|
102
|
+
if (sessionId)
|
|
103
|
+
formData.session_id = sessionId;
|
|
102
104
|
if (includeRecaptcha) {
|
|
103
105
|
try {
|
|
104
106
|
const token = yield (getRecaptchaToken === null || getRecaptchaToken === void 0 ? void 0 : getRecaptchaToken());
|
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -114,9 +114,7 @@ const nutritionKeys = [
|
|
|
114
114
|
'sugars',
|
|
115
115
|
'total_carbs',
|
|
116
116
|
'total_fat',
|
|
117
|
-
'trans_fat'
|
|
118
|
-
'calories_from_fat',
|
|
119
|
-
'serving_weight'
|
|
117
|
+
'trans_fat'
|
|
120
118
|
];
|
|
121
119
|
const calcNutrition = (item) => {
|
|
122
120
|
const { nutritionalInfo, groups } = item;
|
|
@@ -329,7 +327,7 @@ const makeOrderItem = (item, isEdit, soldOut = [], simpleItem, hasPoints = false
|
|
|
329
327
|
list_id: item.list_id,
|
|
330
328
|
list_name: item.list_name,
|
|
331
329
|
menu_position: item.menu_position,
|
|
332
|
-
related_meal_item: item.related_meal_item
|
|
330
|
+
related_meal_item: item.related_meal_item || null
|
|
333
331
|
};
|
|
334
332
|
const pricedItem = (0, exports.calcPrices)(orderItem);
|
|
335
333
|
return pricedItem;
|
|
@@ -923,6 +921,8 @@ const prepareOrder = (data) => {
|
|
|
923
921
|
order.token = data.token;
|
|
924
922
|
if (data.kount_device_session_id)
|
|
925
923
|
order.kount_device_session_id = data.kount_device_session_id;
|
|
924
|
+
if (data.session_id)
|
|
925
|
+
order.session_id = data.session_id;
|
|
926
926
|
return order;
|
|
927
927
|
};
|
|
928
928
|
exports.prepareOrder = prepareOrder;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CartItem, CartLevels, ConfigAccordion } from '@open-tender/types';
|
|
3
|
-
export declare const useAccordion: (builtItem: CartItem, toggleOption: (levels: CartLevels) => void, cartId?: number | null, config?: ConfigAccordion
|
|
3
|
+
export declare const useAccordion: (builtItem: CartItem, toggleOption: (levels: CartLevels) => void, cartId?: number | null, config?: ConfigAccordion) => {
|
|
4
4
|
open: string | null;
|
|
5
5
|
setOpen: import("react").Dispatch<import("react").SetStateAction<string | null>>;
|
|
6
6
|
groups: import("@open-tender/types").CartItemGroups;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { calcNutritionalInfo } from '../utils';
|
|
3
|
-
export const useAccordion = (builtItem, toggleOption, cartId, config
|
|
4
|
-
) => {
|
|
3
|
+
export const useAccordion = (builtItem, toggleOption, cartId, config) => {
|
|
5
4
|
var _a;
|
|
6
5
|
const { hasCals: showCals = false, hasCustomize = false, hasMadeFor: showMadeFor = true, hasNotes: showNotes = true } = config || {};
|
|
7
6
|
const [open, setOpen] = useState(null);
|
|
@@ -27,11 +26,6 @@ export const useAccordion = (builtItem, toggleOption, cartId, config, setImageUr
|
|
|
27
26
|
const toggleSize = (optionId) => {
|
|
28
27
|
if (sizeGroup) {
|
|
29
28
|
toggleOption([[sizeGroup.id, optionId]]);
|
|
30
|
-
if (setImageUrl) {
|
|
31
|
-
const selectedOption = sizeGroup.options.find(o => o.id === optionId);
|
|
32
|
-
if (selectedOption && (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.imageUrl))
|
|
33
|
-
setImageUrl(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.imageUrl);
|
|
34
|
-
}
|
|
35
29
|
setOpen(null);
|
|
36
30
|
}
|
|
37
31
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CartItem,
|
|
1
|
+
import { CartItem, CartLevels } from '@open-tender/types';
|
|
2
2
|
export declare const useBuilder: (orderItem: CartItem, orderTimeoutCallback?: () => void) => {
|
|
3
3
|
item: CartItem;
|
|
4
4
|
increment: () => void;
|
|
@@ -11,6 +11,4 @@ export declare const useBuilder: (orderItem: CartItem, orderTimeoutCallback?: ()
|
|
|
11
11
|
incrementOption: (levels: CartLevels) => CartItem;
|
|
12
12
|
decrementOption: (levels: CartLevels) => CartItem;
|
|
13
13
|
setOptionQuantity: (levels: CartLevels, quantity: number) => CartItem;
|
|
14
|
-
setGroups: (groups: CartItemGroups) => void;
|
|
15
|
-
setImageUrl: (imageUrl: string | null) => void;
|
|
16
14
|
};
|
|
@@ -131,13 +131,6 @@ export const useBuilder = (orderItem, orderTimeoutCallback) => {
|
|
|
131
131
|
setItem(pricedItem);
|
|
132
132
|
return pricedItem;
|
|
133
133
|
};
|
|
134
|
-
const setGroups = (groups) => {
|
|
135
|
-
const pricedItem = calcPrices(Object.assign(Object.assign({}, item), { groups }));
|
|
136
|
-
setItem(pricedItem);
|
|
137
|
-
};
|
|
138
|
-
const setImageUrl = (imageUrl) => {
|
|
139
|
-
setItem(prev => (Object.assign(Object.assign({}, prev), { imageUrl })));
|
|
140
|
-
};
|
|
141
134
|
return {
|
|
142
135
|
item,
|
|
143
136
|
increment,
|
|
@@ -149,8 +142,6 @@ export const useBuilder = (orderItem, orderTimeoutCallback) => {
|
|
|
149
142
|
toggleOption,
|
|
150
143
|
incrementOption,
|
|
151
144
|
decrementOption,
|
|
152
|
-
setOptionQuantity
|
|
153
|
-
setGroups,
|
|
154
|
-
setImageUrl
|
|
145
|
+
setOptionQuantity
|
|
155
146
|
};
|
|
156
147
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CardType, CreditCardData, CreditCardErrors, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useCreditCardForm: (loading: RequestStatus, error: RequestError, data: CreditCardData | null, cardType: CardType | null, addCard: (data: CreditCardData, callback: () => void) => void, callback: () => void, includeRecaptcha: boolean | undefined, revenue_center_id: number | null, kountSessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
3
|
+
export declare const useCreditCardForm: (loading: RequestStatus, error: RequestError, data: CreditCardData | null, cardType: CardType | null, addCard: (data: CreditCardData, callback: () => void) => void, callback: () => void, includeRecaptcha: boolean | undefined, revenue_center_id: number | null, kountSessionId?: string | null, sessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
data: CreditCardData | null;
|
|
6
6
|
errors: Record<string, string> | CreditCardErrors;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { useState, useEffect, useRef } from 'react';
|
|
3
3
|
import { makeFormErrors, validateCreditCard } from '../';
|
|
4
|
-
export const useCreditCardForm = (loading, error, data, cardType, addCard, callback, includeRecaptcha, revenue_center_id, kountSessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
4
|
+
export const useCreditCardForm = (loading, error, data, cardType, addCard, callback, includeRecaptcha, revenue_center_id, kountSessionId, sessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
5
5
|
const submitRef = useRef(null);
|
|
6
6
|
const [submitting, setSubmitting] = useState(false);
|
|
7
7
|
const [errors, setErrors] = useState({});
|
|
@@ -28,6 +28,8 @@ export const useCreditCardForm = (loading, error, data, cardType, addCard, callb
|
|
|
28
28
|
const cardRc = revenue_center_id ? Object.assign(Object.assign({}, card), { revenue_center_id }) : card;
|
|
29
29
|
if (kountSessionId)
|
|
30
30
|
cardRc.kount_device_session_id = kountSessionId;
|
|
31
|
+
if (sessionId)
|
|
32
|
+
cardRc.session_id = sessionId;
|
|
31
33
|
if (includeRecaptcha) {
|
|
32
34
|
try {
|
|
33
35
|
const token = yield (getRecaptchaToken === null || getRecaptchaToken === void 0 ? void 0 : getRecaptchaToken());
|
|
@@ -3,7 +3,7 @@ import { CardType, CreditCardData, CreditCardSaved, CreditCards, Customer, Donat
|
|
|
3
3
|
export declare const useDonationsForm: (purchase: (data: DonationPurchase, callback?: () => void) => void, reset: () => void, setAlert: (data: {
|
|
4
4
|
type: string;
|
|
5
5
|
args?: unknown;
|
|
6
|
-
}) => void, loading: RequestStatus, error: RequestError, success: boolean, customer?: Customer, creditCards?: CreditCards, includeRecaptcha?: boolean, cardData?: CreditCardData, cardType?: CardType, windowRef?: Window, kountSessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
6
|
+
}) => void, loading: RequestStatus, error: RequestError, success: boolean, customer?: Customer, creditCards?: CreditCards, includeRecaptcha?: boolean, cardData?: CreditCardData, cardType?: CardType, windowRef?: Window, kountSessionId?: string | null, sessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
7
7
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
8
8
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
9
9
|
amount: string | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { useMemo, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { makeFormErrors, makeNumeric, validateCreditCard } from '../utils';
|
|
4
|
-
export const useDonationsForm = (purchase, reset, setAlert, loading, error, success, customer, creditCards, includeRecaptcha, cardData, cardType, windowRef, kountSessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
4
|
+
export const useDonationsForm = (purchase, reset, setAlert, loading, error, success, customer, creditCards, includeRecaptcha, cardData, cardType, windowRef, kountSessionId, sessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
5
5
|
const submitRef = useRef(null);
|
|
6
6
|
const inputRef = useRef(null);
|
|
7
7
|
const [amount, setAmount] = useState('');
|
|
@@ -75,6 +75,8 @@ export const useDonationsForm = (purchase, reset, setAlert, loading, error, succ
|
|
|
75
75
|
};
|
|
76
76
|
if (kountSessionId)
|
|
77
77
|
formData.kount_device_session_id = kountSessionId;
|
|
78
|
+
if (sessionId)
|
|
79
|
+
formData.session_id = sessionId;
|
|
78
80
|
if (includeRecaptcha) {
|
|
79
81
|
try {
|
|
80
82
|
const token = yield (getRecaptchaToken === null || getRecaptchaToken === void 0 ? void 0 : getRecaptchaToken());
|
|
@@ -3,7 +3,7 @@ import { CardType, CreditCardData, CreditCardSaved, CreditCards, Customer, GiftC
|
|
|
3
3
|
export declare const useGiftCardsForm: (purchase: (data: GiftCardsPurchase, callback?: () => void) => void, reset: () => void, setAlert: (data: {
|
|
4
4
|
type: string;
|
|
5
5
|
args?: unknown;
|
|
6
|
-
}) => void, loading: RequestStatus, error: RequestError, success: boolean, initState: GiftCardPurchaseData, customer?: Customer | null, creditCards?: CreditCards, includeRecaptcha?: boolean, cardData?: CreditCardData, cardType?: CardType, url?: string, kountSessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
6
|
+
}) => void, loading: RequestStatus, error: RequestError, success: boolean, initState: GiftCardPurchaseData, customer?: Customer | null, creditCards?: CreditCards, includeRecaptcha?: boolean, cardData?: CreditCardData, cardType?: CardType, url?: string, kountSessionId?: string | null, sessionId?: string | null, requireCardholderName?: boolean, getRecaptchaToken?: () => Promise<string | null>) => {
|
|
7
7
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
8
8
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
9
9
|
creditCardOptions: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { useMemo, useRef, useState, useEffect } from 'react';
|
|
3
3
|
import { makeFormErrors, validateCreditCard } from '../utils';
|
|
4
|
-
export const useGiftCardsForm = (purchase, reset, setAlert, loading, error, success, initState, customer, creditCards, includeRecaptcha, cardData, cardType, url, kountSessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
4
|
+
export const useGiftCardsForm = (purchase, reset, setAlert, loading, error, success, initState, customer, creditCards, includeRecaptcha, cardData, cardType, url, kountSessionId, sessionId, requireCardholderName = false, getRecaptchaToken) => {
|
|
5
5
|
const submitRef = useRef(null);
|
|
6
6
|
const inputRef = useRef(null);
|
|
7
7
|
const [name, setName] = useState(null);
|
|
@@ -96,6 +96,8 @@ export const useGiftCardsForm = (purchase, reset, setAlert, loading, error, succ
|
|
|
96
96
|
};
|
|
97
97
|
if (kountSessionId)
|
|
98
98
|
formData.kount_device_session_id = kountSessionId;
|
|
99
|
+
if (sessionId)
|
|
100
|
+
formData.session_id = sessionId;
|
|
99
101
|
if (includeRecaptcha) {
|
|
100
102
|
try {
|
|
101
103
|
const token = yield (getRecaptchaToken === null || getRecaptchaToken === void 0 ? void 0 : getRecaptchaToken());
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -103,9 +103,7 @@ const nutritionKeys = [
|
|
|
103
103
|
'sugars',
|
|
104
104
|
'total_carbs',
|
|
105
105
|
'total_fat',
|
|
106
|
-
'trans_fat'
|
|
107
|
-
'calories_from_fat',
|
|
108
|
-
'serving_weight'
|
|
106
|
+
'trans_fat'
|
|
109
107
|
];
|
|
110
108
|
export const calcNutrition = (item) => {
|
|
111
109
|
const { nutritionalInfo, groups } = item;
|
|
@@ -314,7 +312,7 @@ export const makeOrderItem = (item, isEdit, soldOut = [], simpleItem, hasPoints
|
|
|
314
312
|
list_id: item.list_id,
|
|
315
313
|
list_name: item.list_name,
|
|
316
314
|
menu_position: item.menu_position,
|
|
317
|
-
related_meal_item: item.related_meal_item
|
|
315
|
+
related_meal_item: item.related_meal_item || null
|
|
318
316
|
};
|
|
319
317
|
const pricedItem = calcPrices(orderItem);
|
|
320
318
|
return pricedItem;
|
|
@@ -885,6 +883,8 @@ export const prepareOrder = (data) => {
|
|
|
885
883
|
order.token = data.token;
|
|
886
884
|
if (data.kount_device_session_id)
|
|
887
885
|
order.kount_device_session_id = data.kount_device_session_id;
|
|
886
|
+
if (data.session_id)
|
|
887
|
+
order.session_id = data.session_id;
|
|
888
888
|
return order;
|
|
889
889
|
};
|
|
890
890
|
export const checkAmountRemaining = (total, tenders) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.71",
|
|
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",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"private": false,
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@emotion/react": "^11.10.4",
|
|
39
|
+
"@open-tender/types": "^0.4.182",
|
|
39
40
|
"@reduxjs/toolkit": "^1.8.5",
|
|
40
41
|
"@types/google.maps": "^3.53.5",
|
|
41
42
|
"@types/jest": "^29.5.11",
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"typescript": "^4.8.2"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
60
|
-
"@open-tender/types": "^0.4.
|
|
61
|
+
"@open-tender/types": "^0.4.182",
|
|
61
62
|
"@reduxjs/toolkit": "^1.8.5",
|
|
62
63
|
"react": "^18.2.0"
|
|
63
64
|
},
|