@open-tender/utils 0.4.35 → 0.4.36
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/LICENSE.md +21 -21
- package/README.md +2 -2
- package/dist/.DS_Store +0 -0
- package/dist/cjs/__tests__/utils/helpers.test.d.ts +1 -1
- package/dist/cjs/__tests__/utils/helpers.test.js +96 -96
- package/dist/cjs/__tests__/utils/theme.test.d.ts +1 -1
- package/dist/cjs/__tests__/utils/theme.test.js +37 -37
- package/dist/cjs/hooks/index.d.ts +35 -35
- package/dist/cjs/hooks/index.js +38 -38
- package/dist/cjs/hooks/types.d.ts +4 -4
- package/dist/cjs/hooks/types.js +2 -2
- package/dist/cjs/hooks/useAccordion.d.ts +22 -22
- package/dist/cjs/hooks/useAccordion.js +56 -56
- package/dist/cjs/hooks/useAddressForm.d.ts +12 -12
- package/dist/cjs/hooks/useAddressForm.js +83 -83
- package/dist/cjs/hooks/useAllergenForm.d.ts +10 -10
- package/dist/cjs/hooks/useAllergenForm.js +58 -58
- package/dist/cjs/hooks/useBuilder.d.ts +14 -14
- package/dist/cjs/hooks/useBuilder.js +144 -144
- package/dist/cjs/hooks/useCartGuestForm.d.ts +12 -12
- package/dist/cjs/hooks/useCartGuestForm.js +58 -58
- package/dist/cjs/hooks/useCartPoints.d.ts +13 -13
- package/dist/cjs/hooks/useCartPoints.js +74 -74
- package/dist/cjs/hooks/useCommunicationPreferences.js +1 -1
- package/dist/cjs/hooks/useCreditCard.d.ts +13 -13
- package/dist/cjs/hooks/useCreditCard.js +63 -63
- package/dist/cjs/hooks/useCreditCardForm.d.ts +10 -10
- package/dist/cjs/hooks/useCreditCardForm.js +71 -71
- package/dist/cjs/hooks/useCurbside.d.ts +9 -9
- package/dist/cjs/hooks/useCurbside.js +39 -39
- package/dist/cjs/hooks/useDineInForm.d.ts +11 -11
- package/dist/cjs/hooks/useDineInForm.js +56 -56
- package/dist/cjs/hooks/useDonationForm.d.ts +28 -28
- package/dist/cjs/hooks/useDonationForm.js +172 -172
- package/dist/cjs/hooks/useFirstTimes.d.ts +18 -18
- package/dist/cjs/hooks/useFirstTimes.js +81 -81
- package/dist/cjs/hooks/useGiftCardAssignForm.d.ts +14 -14
- package/dist/cjs/hooks/useGiftCardAssignForm.js +57 -57
- package/dist/cjs/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
- package/dist/cjs/hooks/useGiftCardAssignOtherForm.js +50 -50
- package/dist/cjs/hooks/useGiftCardForm.d.ts +12 -12
- package/dist/cjs/hooks/useGiftCardForm.js +74 -74
- package/dist/cjs/hooks/useGiftCardsForm.d.ts +31 -31
- package/dist/cjs/hooks/useGiftCardsForm.js +195 -195
- package/dist/cjs/hooks/useGuestCheckoutForm.d.ts +21 -21
- package/dist/cjs/hooks/useGuestCheckoutForm.js +89 -89
- package/dist/cjs/hooks/useGuestForm.d.ts +12 -12
- package/dist/cjs/hooks/useGuestForm.js +60 -60
- package/dist/cjs/hooks/useImage.d.ts +5 -5
- package/dist/cjs/hooks/useImage.js +33 -33
- package/dist/cjs/hooks/useLoginForm.d.ts +12 -12
- package/dist/cjs/hooks/useLoginForm.js +67 -67
- package/dist/cjs/hooks/useMenuItem.d.ts +57 -57
- package/dist/cjs/hooks/useMenuItem.js +67 -67
- package/dist/cjs/hooks/useModifier.d.ts +53 -53
- package/dist/cjs/hooks/useModifier.js +72 -72
- package/dist/cjs/hooks/useModifierGroup.d.ts +15 -15
- package/dist/cjs/hooks/useModifierGroup.js +17 -17
- package/dist/cjs/hooks/useOneTimePasscodeForm.d.ts +16 -16
- package/dist/cjs/hooks/useOneTimePasscodeForm.js +87 -87
- package/dist/cjs/hooks/useOrderFulfillmentForm.d.ts +11 -11
- package/dist/cjs/hooks/useOrderFulfillmentForm.js +65 -65
- package/dist/cjs/hooks/useOrderItem.d.ts +48 -48
- package/dist/cjs/hooks/useOrderItem.js +54 -54
- package/dist/cjs/hooks/useOrderRating.d.ts +10 -10
- package/dist/cjs/hooks/useOrderRating.js +34 -34
- package/dist/cjs/hooks/useOrderRatingForm.d.ts +11 -11
- package/dist/cjs/hooks/useOrderRatingForm.js +35 -35
- package/dist/cjs/hooks/useProfileForm.d.ts +15 -15
- package/dist/cjs/hooks/useProfileForm.js +116 -116
- package/dist/cjs/hooks/useResetPasswordForm.d.ts +12 -12
- package/dist/cjs/hooks/useResetPasswordForm.js +77 -77
- package/dist/cjs/hooks/useSendResetForm.d.ts +14 -14
- package/dist/cjs/hooks/useSendResetForm.js +57 -57
- package/dist/cjs/hooks/useSignUpForm.d.ts +20 -20
- package/dist/cjs/hooks/useSignUpForm.js +151 -157
- package/dist/cjs/hooks/useSignUpGuestForm.d.ts +23 -23
- package/dist/cjs/hooks/useSignUpGuestForm.js +113 -124
- package/dist/cjs/hooks/useSigninForm.d.ts +12 -12
- package/dist/cjs/hooks/useSigninForm.js +66 -66
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/utils/cards.d.ts +20 -20
- package/dist/cjs/utils/cards.js +155 -155
- package/dist/cjs/utils/cart.d.ts +202 -202
- package/dist/cjs/utils/cart.js +909 -909
- package/dist/cjs/utils/checkout.d.ts +55 -55
- package/dist/cjs/utils/checkout.js +125 -125
- package/dist/cjs/utils/constants.d.ts +43 -43
- package/dist/cjs/utils/constants.js +58 -58
- package/dist/cjs/utils/customer.d.ts +4 -4
- package/dist/cjs/utils/customer.js +34 -34
- package/dist/cjs/utils/datetimes.d.ts +99 -99
- package/dist/cjs/utils/datetimes.js +601 -601
- package/dist/cjs/utils/errors.d.ts +51 -51
- package/dist/cjs/utils/errors.js +191 -191
- package/dist/cjs/utils/favorites.d.ts +10 -10
- package/dist/cjs/utils/favorites.js +119 -119
- package/dist/cjs/utils/googleMaps.d.ts +14 -14
- package/dist/cjs/utils/googleMaps.js +30 -30
- package/dist/cjs/utils/helpers.d.ts +63 -63
- package/dist/cjs/utils/helpers.js +244 -244
- package/dist/cjs/utils/index.d.ts +19 -19
- package/dist/cjs/utils/index.js +23 -23
- package/dist/cjs/utils/keypad.d.ts +9 -9
- package/dist/cjs/utils/keypad.js +105 -105
- package/dist/cjs/utils/maps.d.ts +226 -226
- package/dist/cjs/utils/maps.js +334 -334
- package/dist/cjs/utils/menu.d.ts +117 -117
- package/dist/cjs/utils/menu.js +82 -82
- package/dist/cjs/utils/orders.d.ts +21 -21
- package/dist/cjs/utils/orders.js +202 -202
- package/dist/cjs/utils/pizzaBuilder.d.ts +10 -10
- package/dist/cjs/utils/pizzaBuilder.js +43 -43
- package/dist/cjs/utils/refunds.d.ts +35 -35
- package/dist/cjs/utils/refunds.js +98 -98
- package/dist/cjs/utils/revenueCenters.d.ts +11 -11
- package/dist/cjs/utils/revenueCenters.js +125 -125
- package/dist/cjs/utils/rewards.d.ts +4 -4
- package/dist/cjs/utils/rewards.js +100 -100
- package/dist/cjs/utils/theme.d.ts +27 -27
- package/dist/cjs/utils/theme.js +266 -266
- package/dist/cjs/utils/version.d.ts +4 -4
- package/dist/cjs/utils/version.js +38 -38
- package/dist/esm/__tests__/utils/helpers.test.d.ts +1 -1
- package/dist/esm/__tests__/utils/helpers.test.js +94 -94
- package/dist/esm/__tests__/utils/theme.test.d.ts +1 -1
- package/dist/esm/__tests__/utils/theme.test.js +35 -35
- package/dist/esm/hooks/index.d.ts +35 -35
- package/dist/esm/hooks/index.js +35 -35
- package/dist/esm/hooks/types.d.ts +4 -4
- package/dist/esm/hooks/types.js +1 -1
- package/dist/esm/hooks/useAccordion.d.ts +22 -22
- package/dist/esm/hooks/useAccordion.js +52 -52
- package/dist/esm/hooks/useAddressForm.d.ts +12 -12
- package/dist/esm/hooks/useAddressForm.js +79 -79
- package/dist/esm/hooks/useAllergenForm.d.ts +10 -10
- package/dist/esm/hooks/useAllergenForm.js +54 -54
- package/dist/esm/hooks/useBuilder.d.ts +14 -14
- package/dist/esm/hooks/useBuilder.js +140 -140
- package/dist/esm/hooks/useCartGuestForm.d.ts +12 -12
- package/dist/esm/hooks/useCartGuestForm.js +54 -54
- package/dist/esm/hooks/useCartPoints.d.ts +13 -13
- package/dist/esm/hooks/useCartPoints.js +70 -70
- package/dist/esm/hooks/useCommunicationPreferences.js +1 -1
- package/dist/esm/hooks/useCreditCard.d.ts +13 -13
- package/dist/esm/hooks/useCreditCard.js +59 -59
- package/dist/esm/hooks/useCreditCardForm.d.ts +10 -10
- package/dist/esm/hooks/useCreditCardForm.js +67 -67
- package/dist/esm/hooks/useCurbside.d.ts +9 -9
- package/dist/esm/hooks/useCurbside.js +35 -35
- package/dist/esm/hooks/useDineInForm.d.ts +11 -11
- package/dist/esm/hooks/useDineInForm.js +52 -52
- package/dist/esm/hooks/useDonationForm.d.ts +28 -28
- package/dist/esm/hooks/useDonationForm.js +168 -168
- package/dist/esm/hooks/useFirstTimes.d.ts +18 -18
- package/dist/esm/hooks/useFirstTimes.js +77 -77
- package/dist/esm/hooks/useGiftCardAssignForm.d.ts +14 -14
- package/dist/esm/hooks/useGiftCardAssignForm.js +53 -53
- package/dist/esm/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
- package/dist/esm/hooks/useGiftCardAssignOtherForm.js +46 -46
- package/dist/esm/hooks/useGiftCardForm.d.ts +12 -12
- package/dist/esm/hooks/useGiftCardForm.js +70 -70
- package/dist/esm/hooks/useGiftCardsForm.d.ts +31 -31
- package/dist/esm/hooks/useGiftCardsForm.js +191 -191
- package/dist/esm/hooks/useGuestCheckoutForm.d.ts +21 -21
- package/dist/esm/hooks/useGuestCheckoutForm.js +85 -85
- package/dist/esm/hooks/useGuestForm.d.ts +12 -12
- package/dist/esm/hooks/useGuestForm.js +56 -56
- package/dist/esm/hooks/useImage.d.ts +5 -5
- package/dist/esm/hooks/useImage.js +29 -29
- package/dist/esm/hooks/useLoginForm.d.ts +12 -12
- package/dist/esm/hooks/useLoginForm.js +63 -63
- package/dist/esm/hooks/useMenuItem.d.ts +57 -57
- package/dist/esm/hooks/useMenuItem.js +63 -63
- package/dist/esm/hooks/useModifier.d.ts +53 -53
- package/dist/esm/hooks/useModifier.js +68 -68
- package/dist/esm/hooks/useModifierGroup.d.ts +15 -15
- package/dist/esm/hooks/useModifierGroup.js +13 -13
- package/dist/esm/hooks/useOneTimePasscodeForm.d.ts +16 -16
- package/dist/esm/hooks/useOneTimePasscodeForm.js +83 -83
- package/dist/esm/hooks/useOrderFulfillmentForm.d.ts +11 -11
- package/dist/esm/hooks/useOrderFulfillmentForm.js +61 -61
- package/dist/esm/hooks/useOrderItem.d.ts +48 -48
- package/dist/esm/hooks/useOrderItem.js +50 -50
- package/dist/esm/hooks/useOrderRating.d.ts +10 -10
- package/dist/esm/hooks/useOrderRating.js +30 -30
- package/dist/esm/hooks/useOrderRatingForm.d.ts +11 -11
- package/dist/esm/hooks/useOrderRatingForm.js +31 -31
- package/dist/esm/hooks/useProfileForm.d.ts +15 -15
- package/dist/esm/hooks/useProfileForm.js +112 -112
- package/dist/esm/hooks/useResetPasswordForm.d.ts +12 -12
- package/dist/esm/hooks/useResetPasswordForm.js +73 -73
- package/dist/esm/hooks/useSendResetForm.d.ts +14 -14
- package/dist/esm/hooks/useSendResetForm.js +53 -53
- package/dist/esm/hooks/useSignUpForm.d.ts +20 -20
- package/dist/esm/hooks/useSignUpForm.js +147 -153
- package/dist/esm/hooks/useSignUpGuestForm.d.ts +23 -23
- package/dist/esm/hooks/useSignUpGuestForm.js +109 -120
- package/dist/esm/hooks/useSigninForm.d.ts +12 -12
- package/dist/esm/hooks/useSigninForm.js +62 -62
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/utils/cards.d.ts +20 -20
- package/dist/esm/utils/cards.js +146 -146
- package/dist/esm/utils/cart.d.ts +202 -202
- package/dist/esm/utils/cart.js +868 -868
- package/dist/esm/utils/checkout.d.ts +55 -55
- package/dist/esm/utils/checkout.js +117 -117
- package/dist/esm/utils/constants.d.ts +43 -43
- package/dist/esm/utils/constants.js +55 -55
- package/dist/esm/utils/customer.d.ts +4 -4
- package/dist/esm/utils/customer.js +29 -29
- package/dist/esm/utils/datetimes.d.ts +99 -99
- package/dist/esm/utils/datetimes.js +531 -531
- package/dist/esm/utils/errors.d.ts +51 -51
- package/dist/esm/utils/errors.js +180 -180
- package/dist/esm/utils/favorites.d.ts +10 -10
- package/dist/esm/utils/favorites.js +109 -109
- package/dist/esm/utils/googleMaps.d.ts +14 -14
- package/dist/esm/utils/googleMaps.js +26 -26
- package/dist/esm/utils/helpers.d.ts +63 -63
- package/dist/esm/utils/helpers.js +205 -205
- package/dist/esm/utils/index.d.ts +19 -19
- package/dist/esm/utils/index.js +20 -20
- package/dist/esm/utils/keypad.d.ts +9 -9
- package/dist/esm/utils/keypad.js +97 -97
- package/dist/esm/utils/maps.d.ts +226 -226
- package/dist/esm/utils/maps.js +316 -316
- package/dist/esm/utils/menu.d.ts +117 -117
- package/dist/esm/utils/menu.js +74 -74
- package/dist/esm/utils/orders.d.ts +21 -21
- package/dist/esm/utils/orders.js +185 -185
- package/dist/esm/utils/pizzaBuilder.d.ts +10 -10
- package/dist/esm/utils/pizzaBuilder.js +38 -38
- package/dist/esm/utils/refunds.d.ts +35 -35
- package/dist/esm/utils/refunds.js +90 -90
- package/dist/esm/utils/revenueCenters.d.ts +11 -11
- package/dist/esm/utils/revenueCenters.js +115 -115
- package/dist/esm/utils/rewards.d.ts +4 -4
- package/dist/esm/utils/rewards.js +94 -94
- package/dist/esm/utils/theme.d.ts +27 -27
- package/dist/esm/utils/theme.js +254 -254
- package/dist/esm/utils/version.d.ts +4 -4
- package/dist/esm/utils/version.js +34 -34
- package/package.json +69 -69
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useDonationsForm = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const useDonationsForm = (purchase, reset, setAlert, loading, error, success, customer, creditCards, recaptchaKey, cardData, cardType, windowRef) => {
|
|
7
|
-
const submitRef = (0, react_1.useRef)(null);
|
|
8
|
-
const inputRef = (0, react_1.useRef)(null);
|
|
9
|
-
const recaptchaRef = (0, react_1.useRef)(null);
|
|
10
|
-
const [amount, setAmount] = (0, react_1.useState)('');
|
|
11
|
-
const [email, setEmail] = (0, react_1.useState)('');
|
|
12
|
-
const [isNewCard, setIsNewCard] = (0, react_1.useState)(true);
|
|
13
|
-
const [creditCard, setCreditCard] = (0, react_1.useState)(null);
|
|
14
|
-
const [creditCardOptions, setCreditCardOptions] = (0, react_1.useState)([]);
|
|
15
|
-
const [errors, setErrors] = (0, react_1.useState)({});
|
|
16
|
-
const [submitting, setSubmitting] = (0, react_1.useState)(false);
|
|
17
|
-
const errMsg = errors.form && errors.form.includes('parameters')
|
|
18
|
-
? 'There are one or more errors below'
|
|
19
|
-
: errors.form || null;
|
|
20
|
-
const newCardErrors = (0, react_1.useMemo)(() => errors
|
|
21
|
-
? Object.entries(errors)
|
|
22
|
-
.filter(([key]) => key !== 'form')
|
|
23
|
-
.reduce((obj, [key, value]) => (Object.assign(Object.assign({}, obj), { [key]: value })), {})
|
|
24
|
-
: {}, [errors]);
|
|
25
|
-
(0, react_1.useEffect)(() => {
|
|
26
|
-
var _a, _b;
|
|
27
|
-
if (loading === 'idle') {
|
|
28
|
-
setSubmitting(false);
|
|
29
|
-
setAlert({ type: 'close' });
|
|
30
|
-
if (error) {
|
|
31
|
-
if (recaptchaRef.current)
|
|
32
|
-
recaptchaRef.current.reset();
|
|
33
|
-
setErrors((0, utils_1.makeFormErrors)(error));
|
|
34
|
-
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus());
|
|
35
|
-
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
36
|
-
}
|
|
37
|
-
else if (success) {
|
|
38
|
-
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}, [windowRef, loading, error, setAlert, success]);
|
|
42
|
-
(0, react_1.useEffect)(() => {
|
|
43
|
-
if ((creditCards === null || creditCards === void 0 ? void 0 : creditCards.length) && loading !== 'pending') {
|
|
44
|
-
const options = creditCards.map(i => ({
|
|
45
|
-
name: `${i.card_type_name} ending in ${i.last4}`,
|
|
46
|
-
value: i.customer_card_id
|
|
47
|
-
}));
|
|
48
|
-
setCreditCardOptions(options);
|
|
49
|
-
const defaultCard = creditCards.length
|
|
50
|
-
? { customer_card_id: creditCards[0].customer_card_id }
|
|
51
|
-
: null;
|
|
52
|
-
setCreditCard(defaultCard);
|
|
53
|
-
setIsNewCard(false);
|
|
54
|
-
}
|
|
55
|
-
}, [creditCards, loading]);
|
|
56
|
-
(0, react_1.useEffect)(() => {
|
|
57
|
-
setEmail((customer === null || customer === void 0 ? void 0 : customer.email) || '');
|
|
58
|
-
}, [customer === null || customer === void 0 ? void 0 : customer.email]);
|
|
59
|
-
const handleAmount = (value) => {
|
|
60
|
-
const cleanValue = (0, utils_1.makeNumeric)(value);
|
|
61
|
-
setAmount(cleanValue);
|
|
62
|
-
};
|
|
63
|
-
const handleEmail = (value) => {
|
|
64
|
-
setEmail(value);
|
|
65
|
-
};
|
|
66
|
-
const handleCreditCard = (value) => {
|
|
67
|
-
const customerCardId = parseInt(value);
|
|
68
|
-
setCreditCard({ customer_card_id: customerCardId });
|
|
69
|
-
};
|
|
70
|
-
const purchaseWithCaptcha = (credit_card) => {
|
|
71
|
-
const alert = {
|
|
72
|
-
type: 'working',
|
|
73
|
-
args: { text: 'Submitting your contribution...' }
|
|
74
|
-
};
|
|
75
|
-
if (recaptchaKey) {
|
|
76
|
-
try {
|
|
77
|
-
const token = recaptchaRef.current.getValue();
|
|
78
|
-
if (!token) {
|
|
79
|
-
setSubmitting(false);
|
|
80
|
-
setErrors({ form: 'Please complete the recaptcha before submitting' });
|
|
81
|
-
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
setSubmitting(true);
|
|
85
|
-
setAlert(alert);
|
|
86
|
-
purchase({
|
|
87
|
-
amount: amount,
|
|
88
|
-
email: email,
|
|
89
|
-
credit_card,
|
|
90
|
-
token: token
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
catch (err) {
|
|
95
|
-
setSubmitting(false);
|
|
96
|
-
setErrors({ form: 'Please complete the recaptcha before submitting' });
|
|
97
|
-
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
setSubmitting(true);
|
|
102
|
-
setAlert(alert);
|
|
103
|
-
purchase({
|
|
104
|
-
amount: amount,
|
|
105
|
-
email: email,
|
|
106
|
-
credit_card,
|
|
107
|
-
token: ''
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const handleSubmit = (evt) => {
|
|
112
|
-
var _a, _b, _c;
|
|
113
|
-
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
114
|
-
if (!amount || !email) {
|
|
115
|
-
setErrors({ form: 'Both amount and email are required' });
|
|
116
|
-
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && inputRef.current.focus();
|
|
117
|
-
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
if (isNewCard) {
|
|
121
|
-
if (cardData && cardType) {
|
|
122
|
-
const { card, errors: errs } = (0, utils_1.validateCreditCard)(cardData, cardType);
|
|
123
|
-
if (errs) {
|
|
124
|
-
setErrors(Object.assign(Object.assign({}, errs), { form: 'There are one or more credit card errors below' }));
|
|
125
|
-
setSubmitting(false);
|
|
126
|
-
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
purchaseWithCaptcha(card);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
if (creditCard)
|
|
135
|
-
purchaseWithCaptcha(creditCard);
|
|
136
|
-
}
|
|
137
|
-
((_b = submitRef.current) === null || _b === void 0 ? void 0 : _b.blur) && ((_c = submitRef.current) === null || _c === void 0 ? void 0 : _c.blur());
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
const handleReset = () => {
|
|
141
|
-
setErrors({});
|
|
142
|
-
setAmount(null);
|
|
143
|
-
if (!customer)
|
|
144
|
-
setEmail(null);
|
|
145
|
-
if (!customer)
|
|
146
|
-
setIsNewCard(true);
|
|
147
|
-
setCreditCard(null);
|
|
148
|
-
setCreditCardOptions([]);
|
|
149
|
-
reset();
|
|
150
|
-
};
|
|
151
|
-
return {
|
|
152
|
-
inputRef,
|
|
153
|
-
submitRef,
|
|
154
|
-
recaptchaRef,
|
|
155
|
-
amount,
|
|
156
|
-
handleAmount,
|
|
157
|
-
email,
|
|
158
|
-
handleEmail,
|
|
159
|
-
errors,
|
|
160
|
-
errMsg,
|
|
161
|
-
newCardErrors,
|
|
162
|
-
submitting,
|
|
163
|
-
isNewCard,
|
|
164
|
-
creditCard,
|
|
165
|
-
creditCardOptions,
|
|
166
|
-
handleCreditCard,
|
|
167
|
-
handleSubmit,
|
|
168
|
-
handleReset,
|
|
169
|
-
setErrors
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
exports.useDonationsForm = useDonationsForm;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDonationsForm = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const useDonationsForm = (purchase, reset, setAlert, loading, error, success, customer, creditCards, recaptchaKey, cardData, cardType, windowRef) => {
|
|
7
|
+
const submitRef = (0, react_1.useRef)(null);
|
|
8
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
9
|
+
const recaptchaRef = (0, react_1.useRef)(null);
|
|
10
|
+
const [amount, setAmount] = (0, react_1.useState)('');
|
|
11
|
+
const [email, setEmail] = (0, react_1.useState)('');
|
|
12
|
+
const [isNewCard, setIsNewCard] = (0, react_1.useState)(true);
|
|
13
|
+
const [creditCard, setCreditCard] = (0, react_1.useState)(null);
|
|
14
|
+
const [creditCardOptions, setCreditCardOptions] = (0, react_1.useState)([]);
|
|
15
|
+
const [errors, setErrors] = (0, react_1.useState)({});
|
|
16
|
+
const [submitting, setSubmitting] = (0, react_1.useState)(false);
|
|
17
|
+
const errMsg = errors.form && errors.form.includes('parameters')
|
|
18
|
+
? 'There are one or more errors below'
|
|
19
|
+
: errors.form || null;
|
|
20
|
+
const newCardErrors = (0, react_1.useMemo)(() => errors
|
|
21
|
+
? Object.entries(errors)
|
|
22
|
+
.filter(([key]) => key !== 'form')
|
|
23
|
+
.reduce((obj, [key, value]) => (Object.assign(Object.assign({}, obj), { [key]: value })), {})
|
|
24
|
+
: {}, [errors]);
|
|
25
|
+
(0, react_1.useEffect)(() => {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
if (loading === 'idle') {
|
|
28
|
+
setSubmitting(false);
|
|
29
|
+
setAlert({ type: 'close' });
|
|
30
|
+
if (error) {
|
|
31
|
+
if (recaptchaRef.current)
|
|
32
|
+
recaptchaRef.current.reset();
|
|
33
|
+
setErrors((0, utils_1.makeFormErrors)(error));
|
|
34
|
+
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus());
|
|
35
|
+
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
36
|
+
}
|
|
37
|
+
else if (success) {
|
|
38
|
+
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}, [windowRef, loading, error, setAlert, success]);
|
|
42
|
+
(0, react_1.useEffect)(() => {
|
|
43
|
+
if ((creditCards === null || creditCards === void 0 ? void 0 : creditCards.length) && loading !== 'pending') {
|
|
44
|
+
const options = creditCards.map(i => ({
|
|
45
|
+
name: `${i.card_type_name} ending in ${i.last4}`,
|
|
46
|
+
value: i.customer_card_id
|
|
47
|
+
}));
|
|
48
|
+
setCreditCardOptions(options);
|
|
49
|
+
const defaultCard = creditCards.length
|
|
50
|
+
? { customer_card_id: creditCards[0].customer_card_id }
|
|
51
|
+
: null;
|
|
52
|
+
setCreditCard(defaultCard);
|
|
53
|
+
setIsNewCard(false);
|
|
54
|
+
}
|
|
55
|
+
}, [creditCards, loading]);
|
|
56
|
+
(0, react_1.useEffect)(() => {
|
|
57
|
+
setEmail((customer === null || customer === void 0 ? void 0 : customer.email) || '');
|
|
58
|
+
}, [customer === null || customer === void 0 ? void 0 : customer.email]);
|
|
59
|
+
const handleAmount = (value) => {
|
|
60
|
+
const cleanValue = (0, utils_1.makeNumeric)(value);
|
|
61
|
+
setAmount(cleanValue);
|
|
62
|
+
};
|
|
63
|
+
const handleEmail = (value) => {
|
|
64
|
+
setEmail(value);
|
|
65
|
+
};
|
|
66
|
+
const handleCreditCard = (value) => {
|
|
67
|
+
const customerCardId = parseInt(value);
|
|
68
|
+
setCreditCard({ customer_card_id: customerCardId });
|
|
69
|
+
};
|
|
70
|
+
const purchaseWithCaptcha = (credit_card) => {
|
|
71
|
+
const alert = {
|
|
72
|
+
type: 'working',
|
|
73
|
+
args: { text: 'Submitting your contribution...' }
|
|
74
|
+
};
|
|
75
|
+
if (recaptchaKey) {
|
|
76
|
+
try {
|
|
77
|
+
const token = recaptchaRef.current.getValue();
|
|
78
|
+
if (!token) {
|
|
79
|
+
setSubmitting(false);
|
|
80
|
+
setErrors({ form: 'Please complete the recaptcha before submitting' });
|
|
81
|
+
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
setSubmitting(true);
|
|
85
|
+
setAlert(alert);
|
|
86
|
+
purchase({
|
|
87
|
+
amount: amount,
|
|
88
|
+
email: email,
|
|
89
|
+
credit_card,
|
|
90
|
+
token: token
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
setSubmitting(false);
|
|
96
|
+
setErrors({ form: 'Please complete the recaptcha before submitting' });
|
|
97
|
+
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
setSubmitting(true);
|
|
102
|
+
setAlert(alert);
|
|
103
|
+
purchase({
|
|
104
|
+
amount: amount,
|
|
105
|
+
email: email,
|
|
106
|
+
credit_card,
|
|
107
|
+
token: ''
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const handleSubmit = (evt) => {
|
|
112
|
+
var _a, _b, _c;
|
|
113
|
+
evt === null || evt === void 0 ? void 0 : evt.preventDefault();
|
|
114
|
+
if (!amount || !email) {
|
|
115
|
+
setErrors({ form: 'Both amount and email are required' });
|
|
116
|
+
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && inputRef.current.focus();
|
|
117
|
+
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
if (isNewCard) {
|
|
121
|
+
if (cardData && cardType) {
|
|
122
|
+
const { card, errors: errs } = (0, utils_1.validateCreditCard)(cardData, cardType);
|
|
123
|
+
if (errs) {
|
|
124
|
+
setErrors(Object.assign(Object.assign({}, errs), { form: 'There are one or more credit card errors below' }));
|
|
125
|
+
setSubmitting(false);
|
|
126
|
+
windowRef === null || windowRef === void 0 ? void 0 : windowRef.scrollTo(0, 0);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
purchaseWithCaptcha(card);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
if (creditCard)
|
|
135
|
+
purchaseWithCaptcha(creditCard);
|
|
136
|
+
}
|
|
137
|
+
((_b = submitRef.current) === null || _b === void 0 ? void 0 : _b.blur) && ((_c = submitRef.current) === null || _c === void 0 ? void 0 : _c.blur());
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const handleReset = () => {
|
|
141
|
+
setErrors({});
|
|
142
|
+
setAmount(null);
|
|
143
|
+
if (!customer)
|
|
144
|
+
setEmail(null);
|
|
145
|
+
if (!customer)
|
|
146
|
+
setIsNewCard(true);
|
|
147
|
+
setCreditCard(null);
|
|
148
|
+
setCreditCardOptions([]);
|
|
149
|
+
reset();
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
inputRef,
|
|
153
|
+
submitRef,
|
|
154
|
+
recaptchaRef,
|
|
155
|
+
amount,
|
|
156
|
+
handleAmount,
|
|
157
|
+
email,
|
|
158
|
+
handleEmail,
|
|
159
|
+
errors,
|
|
160
|
+
errMsg,
|
|
161
|
+
newCardErrors,
|
|
162
|
+
submitting,
|
|
163
|
+
isNewCard,
|
|
164
|
+
creditCard,
|
|
165
|
+
creditCardOptions,
|
|
166
|
+
handleCreditCard,
|
|
167
|
+
handleSubmit,
|
|
168
|
+
handleReset,
|
|
169
|
+
setErrors
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
exports.useDonationsForm = useDonationsForm;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { FirstTime, OrderType, RequestedAt, RevenueCenter, ServiceType, TimeOption } from '@open-tender/types';
|
|
3
|
-
export declare const useFirstTimes: (firstTime: FirstTime, revenueCenter: RevenueCenter, serviceType: ServiceType, orderType: OrderType, requestedAt?: RequestedAt, isGroupOrder?: boolean, days?: number) => {
|
|
4
|
-
date: `${number}${number}${number}${number}-${number}${number}-${number}${number}`;
|
|
5
|
-
setDate: import("react").Dispatch<import("react").SetStateAction<`${number}${number}${number}${number}-${number}${number}-${number}${number}`>>;
|
|
6
|
-
time: string | number;
|
|
7
|
-
setTime: import("react").Dispatch<import("react").SetStateAction<string | number>>;
|
|
8
|
-
dateChange: boolean;
|
|
9
|
-
setDateChange: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
10
|
-
dateOptions: {
|
|
11
|
-
name: string;
|
|
12
|
-
value: string;
|
|
13
|
-
}[];
|
|
14
|
-
timeOptions: TimeOption[];
|
|
15
|
-
firstMinutes: string | number | null;
|
|
16
|
-
requestedTime: RequestedAt;
|
|
17
|
-
orderMsg: string;
|
|
18
|
-
};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FirstTime, OrderType, RequestedAt, RevenueCenter, ServiceType, TimeOption } from '@open-tender/types';
|
|
3
|
+
export declare const useFirstTimes: (firstTime: FirstTime, revenueCenter: RevenueCenter, serviceType: ServiceType, orderType: OrderType, requestedAt?: RequestedAt, isGroupOrder?: boolean, days?: number) => {
|
|
4
|
+
date: `${number}${number}${number}${number}-${number}${number}-${number}${number}`;
|
|
5
|
+
setDate: import("react").Dispatch<import("react").SetStateAction<`${number}${number}${number}${number}-${number}${number}-${number}${number}`>>;
|
|
6
|
+
time: string | number;
|
|
7
|
+
setTime: import("react").Dispatch<import("react").SetStateAction<string | number>>;
|
|
8
|
+
dateChange: boolean;
|
|
9
|
+
setDateChange: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
10
|
+
dateOptions: {
|
|
11
|
+
name: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[];
|
|
14
|
+
timeOptions: TimeOption[];
|
|
15
|
+
firstMinutes: string | number | null;
|
|
16
|
+
requestedTime: RequestedAt;
|
|
17
|
+
orderMsg: string;
|
|
18
|
+
};
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useFirstTimes = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const useFirstTimes = (firstTime, revenueCenter, serviceType, orderType, requestedAt, isGroupOrder = false, days = 100) => {
|
|
7
|
-
const { timezone, holidays, days_ahead, valid_times, group_ordering } = revenueCenter;
|
|
8
|
-
const { prep_time = 0, lead_time = 0 } = group_ordering || {};
|
|
9
|
-
const leadTime = isGroupOrder ? prep_time + lead_time : 0;
|
|
10
|
-
const tz = utils_1.timezoneMap[timezone];
|
|
11
|
-
const selected = requestedAt && requestedAt !== 'asap';
|
|
12
|
-
const requested = selected
|
|
13
|
-
? (0, utils_1.isoToDateStrMinutes)(requestedAt, tz)
|
|
14
|
-
: { date: null, minutes: null };
|
|
15
|
-
const [date, setDate] = (0, react_1.useState)(requested.date || firstTime.date);
|
|
16
|
-
const [time, setTime] = (0, react_1.useState)(requested.minutes || firstTime.minutes);
|
|
17
|
-
const [dateChange, setDateChange] = (0, react_1.useState)(false);
|
|
18
|
-
const daysAhead = orderType === 'CATERING' ? days : days_ahead;
|
|
19
|
-
const dates = (0, react_1.useMemo)(() => (0, utils_1.makeDates)(firstTime.date, daysAhead, 'E, MMM d'), [firstTime.date, daysAhead]);
|
|
20
|
-
const dateOptions = dates.map(({ label, value }) => ({ name: label, value }));
|
|
21
|
-
const timeOptions = (0, react_1.useMemo)(() => {
|
|
22
|
-
if (date && valid_times) {
|
|
23
|
-
const options = (0, utils_1.makeTimes)(date, firstTime, valid_times, holidays, serviceType, leadTime);
|
|
24
|
-
return options !== null && options !== void 0 ? options : [];
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
}, [date, firstTime, valid_times, holidays, serviceType, leadTime]);
|
|
30
|
-
const orderDate = dateOptions.find(i => i.value === date);
|
|
31
|
-
const showAsap = firstTime.has_asap && date === firstTime.date ? true : false;
|
|
32
|
-
const firstIso = (0, utils_1.dateStrMinutesToIso)(firstTime.date, firstTime.minutes + leadTime, tz);
|
|
33
|
-
const asapTime = showAsap ? (0, utils_1.makeReadableDateStrFromIso)(firstIso, tz) : null;
|
|
34
|
-
const asapTimeOption = {
|
|
35
|
-
name: `ASAP (about ${asapTime})`,
|
|
36
|
-
value: 'asap',
|
|
37
|
-
disabled: false
|
|
38
|
-
};
|
|
39
|
-
const timeOptionsAsap = showAsap
|
|
40
|
-
? [asapTimeOption, ...timeOptions]
|
|
41
|
-
: timeOptions;
|
|
42
|
-
const firstOrderableTime = timeOptionsAsap
|
|
43
|
-
? timeOptionsAsap.find(i => !i.disabled)
|
|
44
|
-
: null;
|
|
45
|
-
const firstMinutes = firstOrderableTime ? firstOrderableTime.value : null;
|
|
46
|
-
const defaultTime = timeOptionsAsap
|
|
47
|
-
? timeOptionsAsap.find(i => i.value === firstMinutes)
|
|
48
|
-
: null;
|
|
49
|
-
const orderTime = timeOptionsAsap
|
|
50
|
-
? timeOptionsAsap.find(i => i.value === time) || defaultTime
|
|
51
|
-
: null;
|
|
52
|
-
const isAsap = orderTime && orderTime.value === 'asap' ? true : false;
|
|
53
|
-
const orderMsg = orderDate && orderTime
|
|
54
|
-
? isAsap
|
|
55
|
-
? `Order ${orderTime.name}`
|
|
56
|
-
: `Order for ${orderDate.name} @ ${orderTime.name}`
|
|
57
|
-
: 'Choose Time';
|
|
58
|
-
const timeVal = orderTime ? orderTime.value : time;
|
|
59
|
-
const timeInt = timeVal === 'asap' ? 0 : Number(timeVal);
|
|
60
|
-
const requestedTime = isAsap
|
|
61
|
-
? 'asap'
|
|
62
|
-
: (0, utils_1.dateStrMinutesToIso)(date, timeInt, tz);
|
|
63
|
-
const closedTimeOptions = [{ name: 'Closed', value: null, disabled: false }];
|
|
64
|
-
const timeOptionsAdjusted = !timeOptionsAsap.length
|
|
65
|
-
? closedTimeOptions
|
|
66
|
-
: timeOptionsAsap;
|
|
67
|
-
return {
|
|
68
|
-
date,
|
|
69
|
-
setDate,
|
|
70
|
-
time,
|
|
71
|
-
setTime,
|
|
72
|
-
dateChange,
|
|
73
|
-
setDateChange,
|
|
74
|
-
dateOptions,
|
|
75
|
-
timeOptions: timeOptionsAdjusted,
|
|
76
|
-
firstMinutes,
|
|
77
|
-
requestedTime,
|
|
78
|
-
orderMsg
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
exports.useFirstTimes = useFirstTimes;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFirstTimes = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const useFirstTimes = (firstTime, revenueCenter, serviceType, orderType, requestedAt, isGroupOrder = false, days = 100) => {
|
|
7
|
+
const { timezone, holidays, days_ahead, valid_times, group_ordering } = revenueCenter;
|
|
8
|
+
const { prep_time = 0, lead_time = 0 } = group_ordering || {};
|
|
9
|
+
const leadTime = isGroupOrder ? prep_time + lead_time : 0;
|
|
10
|
+
const tz = utils_1.timezoneMap[timezone];
|
|
11
|
+
const selected = requestedAt && requestedAt !== 'asap';
|
|
12
|
+
const requested = selected
|
|
13
|
+
? (0, utils_1.isoToDateStrMinutes)(requestedAt, tz)
|
|
14
|
+
: { date: null, minutes: null };
|
|
15
|
+
const [date, setDate] = (0, react_1.useState)(requested.date || firstTime.date);
|
|
16
|
+
const [time, setTime] = (0, react_1.useState)(requested.minutes || firstTime.minutes);
|
|
17
|
+
const [dateChange, setDateChange] = (0, react_1.useState)(false);
|
|
18
|
+
const daysAhead = orderType === 'CATERING' ? days : days_ahead;
|
|
19
|
+
const dates = (0, react_1.useMemo)(() => (0, utils_1.makeDates)(firstTime.date, daysAhead, 'E, MMM d'), [firstTime.date, daysAhead]);
|
|
20
|
+
const dateOptions = dates.map(({ label, value }) => ({ name: label, value }));
|
|
21
|
+
const timeOptions = (0, react_1.useMemo)(() => {
|
|
22
|
+
if (date && valid_times) {
|
|
23
|
+
const options = (0, utils_1.makeTimes)(date, firstTime, valid_times, holidays, serviceType, leadTime);
|
|
24
|
+
return options !== null && options !== void 0 ? options : [];
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
}, [date, firstTime, valid_times, holidays, serviceType, leadTime]);
|
|
30
|
+
const orderDate = dateOptions.find(i => i.value === date);
|
|
31
|
+
const showAsap = firstTime.has_asap && date === firstTime.date ? true : false;
|
|
32
|
+
const firstIso = (0, utils_1.dateStrMinutesToIso)(firstTime.date, firstTime.minutes + leadTime, tz);
|
|
33
|
+
const asapTime = showAsap ? (0, utils_1.makeReadableDateStrFromIso)(firstIso, tz) : null;
|
|
34
|
+
const asapTimeOption = {
|
|
35
|
+
name: `ASAP (about ${asapTime})`,
|
|
36
|
+
value: 'asap',
|
|
37
|
+
disabled: false
|
|
38
|
+
};
|
|
39
|
+
const timeOptionsAsap = showAsap
|
|
40
|
+
? [asapTimeOption, ...timeOptions]
|
|
41
|
+
: timeOptions;
|
|
42
|
+
const firstOrderableTime = timeOptionsAsap
|
|
43
|
+
? timeOptionsAsap.find(i => !i.disabled)
|
|
44
|
+
: null;
|
|
45
|
+
const firstMinutes = firstOrderableTime ? firstOrderableTime.value : null;
|
|
46
|
+
const defaultTime = timeOptionsAsap
|
|
47
|
+
? timeOptionsAsap.find(i => i.value === firstMinutes)
|
|
48
|
+
: null;
|
|
49
|
+
const orderTime = timeOptionsAsap
|
|
50
|
+
? timeOptionsAsap.find(i => i.value === time) || defaultTime
|
|
51
|
+
: null;
|
|
52
|
+
const isAsap = orderTime && orderTime.value === 'asap' ? true : false;
|
|
53
|
+
const orderMsg = orderDate && orderTime
|
|
54
|
+
? isAsap
|
|
55
|
+
? `Order ${orderTime.name}`
|
|
56
|
+
: `Order for ${orderDate.name} @ ${orderTime.name}`
|
|
57
|
+
: 'Choose Time';
|
|
58
|
+
const timeVal = orderTime ? orderTime.value : time;
|
|
59
|
+
const timeInt = timeVal === 'asap' ? 0 : Number(timeVal);
|
|
60
|
+
const requestedTime = isAsap
|
|
61
|
+
? 'asap'
|
|
62
|
+
: (0, utils_1.dateStrMinutesToIso)(date, timeInt, tz);
|
|
63
|
+
const closedTimeOptions = [{ name: 'Closed', value: null, disabled: false }];
|
|
64
|
+
const timeOptionsAdjusted = !timeOptionsAsap.length
|
|
65
|
+
? closedTimeOptions
|
|
66
|
+
: timeOptionsAsap;
|
|
67
|
+
return {
|
|
68
|
+
date,
|
|
69
|
+
setDate,
|
|
70
|
+
time,
|
|
71
|
+
setTime,
|
|
72
|
+
dateChange,
|
|
73
|
+
setDateChange,
|
|
74
|
+
dateOptions,
|
|
75
|
+
timeOptions: timeOptionsAdjusted,
|
|
76
|
+
firstMinutes,
|
|
77
|
+
requestedTime,
|
|
78
|
+
orderMsg
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
exports.useFirstTimes = useFirstTimes;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { FormFields, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export declare const useGiftCardAssignForm: (loading: RequestStatus, error: RequestError, assign: (card_number: number, callback: () => void) => void, callback: () => void) => {
|
|
4
|
-
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
|
-
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
6
|
-
fields: FormFields;
|
|
7
|
-
data: {
|
|
8
|
-
card_number: string;
|
|
9
|
-
};
|
|
10
|
-
errors: Record<string, string>;
|
|
11
|
-
submitting: boolean;
|
|
12
|
-
handleChange: (name: string, value: string | number | boolean) => void;
|
|
13
|
-
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
14
|
-
};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormFields, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export declare const useGiftCardAssignForm: (loading: RequestStatus, error: RequestError, assign: (card_number: number, callback: () => void) => void, callback: () => void) => {
|
|
4
|
+
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
|
+
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
6
|
+
fields: FormFields;
|
|
7
|
+
data: {
|
|
8
|
+
card_number: string;
|
|
9
|
+
};
|
|
10
|
+
errors: Record<string, string>;
|
|
11
|
+
submitting: boolean;
|
|
12
|
+
handleChange: (name: string, value: string | number | boolean) => void;
|
|
13
|
+
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
14
|
+
};
|