@open-tender/utils 0.4.52 → 0.4.53
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/useProfileForm.d.ts +5 -1
- package/dist/cjs/hooks/useProfileForm.js +17 -2
- package/dist/cjs/hooks/useSignUpForm.d.ts +2 -2
- package/dist/cjs/hooks/useSignUpForm.js +13 -3
- package/dist/cjs/hooks/useSignUpGuestForm.d.ts +2 -5
- package/dist/cjs/hooks/useSignUpGuestForm.js +3 -14
- package/dist/cjs/utils/checkout.d.ts +1 -2
- package/dist/cjs/utils/checkout.js +1 -25
- package/dist/cjs/utils/customer.js +1 -0
- package/dist/cjs/utils/revenueCenters.js +2 -2
- package/dist/esm/hooks/useProfileForm.d.ts +5 -1
- package/dist/esm/hooks/useProfileForm.js +16 -1
- package/dist/esm/hooks/useSignUpForm.d.ts +2 -2
- package/dist/esm/hooks/useSignUpForm.js +11 -1
- package/dist/esm/hooks/useSignUpGuestForm.d.ts +2 -5
- package/dist/esm/hooks/useSignUpGuestForm.js +3 -14
- package/dist/esm/utils/checkout.d.ts +1 -2
- package/dist/esm/utils/checkout.js +0 -23
- package/dist/esm/utils/customer.js +1 -0
- package/dist/esm/utils/revenueCenters.js +2 -2
- package/package.json +2 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Customer, CustomerCreate, FormFieldType, RequestError, RequestStatus } from '@open-tender/types';
|
|
2
|
+
import { Customer, CustomerCreate, FormFieldType, Gender, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export declare const genderOptions: {
|
|
4
|
+
name: string;
|
|
5
|
+
value: Gender;
|
|
6
|
+
}[];
|
|
3
7
|
export declare const useProfileForm: (profile: Customer | null, loading: RequestStatus, error: RequestError, update: (data: CustomerCreate) => void, callback?: ((data: CustomerCreate) => void) | undefined, optionalFields?: string[]) => {
|
|
4
8
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
9
|
data: Customer | null;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useProfileForm = void 0;
|
|
3
|
+
exports.useProfileForm = exports.genderOptions = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
exports.genderOptions = [
|
|
7
|
+
{ name: 'not specified', value: 'DECLINED' },
|
|
8
|
+
{ name: 'Male', value: 'MALE' },
|
|
9
|
+
{ name: 'Female', value: 'FEMALE' }
|
|
10
|
+
];
|
|
6
11
|
const allFields = [
|
|
7
12
|
{ label: 'First Name', name: 'first_name', type: 'text', required: true },
|
|
8
13
|
{ label: 'Last Name', name: 'last_name', type: 'text', required: true },
|
|
@@ -15,13 +20,21 @@ const allFields = [
|
|
|
15
20
|
},
|
|
16
21
|
{ label: 'Phone', name: 'phone', type: 'tel', required: true },
|
|
17
22
|
{ label: 'Company', name: 'company', type: 'text' },
|
|
18
|
-
{ label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' }
|
|
23
|
+
{ label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' },
|
|
24
|
+
{
|
|
25
|
+
label: 'Gender',
|
|
26
|
+
name: 'gender',
|
|
27
|
+
type: 'select',
|
|
28
|
+
showLabel: true,
|
|
29
|
+
options: exports.genderOptions
|
|
30
|
+
}
|
|
19
31
|
];
|
|
20
32
|
const makePayload = (fields, data) => {
|
|
21
33
|
if (!data)
|
|
22
34
|
return null;
|
|
23
35
|
const rest = fields.reduce((obj, i) => (Object.assign(Object.assign({}, obj), { [i.name]: data[i.name] })), {});
|
|
24
36
|
rest.birth_date = data.birth_date ? (0, utils_1.slashesToDashes)(data.birth_date) : null;
|
|
37
|
+
rest.gender = data.gender || null;
|
|
25
38
|
return rest;
|
|
26
39
|
};
|
|
27
40
|
const useProfileForm = (profile, loading, error, update, callback, optionalFields) => {
|
|
@@ -33,6 +46,8 @@ const useProfileForm = (profile, loading, error, update, callback, optionalField
|
|
|
33
46
|
const removed = [];
|
|
34
47
|
if (optionalFields && !optionalFields.includes('birth_date'))
|
|
35
48
|
removed.push('birth_date');
|
|
49
|
+
if (optionalFields && !optionalFields.includes('gender'))
|
|
50
|
+
removed.push('gender');
|
|
36
51
|
return removed;
|
|
37
52
|
}, [optionalFields]);
|
|
38
53
|
// const fields = allFields.filter((i) => !toRemove.includes(i.name))
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutConfig, ConfigBrand, Customer, CustomerCreate, NotificationChannel, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
|
|
3
|
+
interface NotificationCheckbox {
|
|
4
4
|
label: string;
|
|
5
5
|
name: NotificationChannel;
|
|
6
6
|
type: string;
|
|
7
7
|
}
|
|
8
|
-
export declare const notificationChannelFields: NotificationCheckbox[];
|
|
9
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, tpls?: ConfigBrand['tpls']) => {
|
|
10
9
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
11
10
|
data: CustomerCreate;
|
|
@@ -18,3 +17,4 @@ export declare const useSignUpForm: (loading: RequestStatus, error: RequestError
|
|
|
18
17
|
handleComms: (name: NotificationChannel, value: boolean) => void;
|
|
19
18
|
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
20
19
|
};
|
|
20
|
+
export {};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSignUpForm =
|
|
3
|
+
exports.useSignUpForm = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const useProfileForm_1 = require("./useProfileForm");
|
|
6
7
|
const initState = {
|
|
7
8
|
first_name: '',
|
|
8
9
|
last_name: '',
|
|
9
10
|
email: '',
|
|
10
11
|
phone: ''
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
+
const notificationChannelFields = [
|
|
13
14
|
{
|
|
14
15
|
label: 'Email',
|
|
15
16
|
name: 'EMAIL',
|
|
@@ -44,6 +45,8 @@ const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePasswo
|
|
|
44
45
|
toRemove.push('password');
|
|
45
46
|
if (optionalFields && !optionalFields.includes('birth_date'))
|
|
46
47
|
toRemove.push('birth_date');
|
|
48
|
+
if (optionalFields && !optionalFields.includes('gender'))
|
|
49
|
+
toRemove.push('gender');
|
|
47
50
|
const allFields = [
|
|
48
51
|
{
|
|
49
52
|
label: 'First Name',
|
|
@@ -83,10 +86,17 @@ const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePasswo
|
|
|
83
86
|
name: 'birth_date',
|
|
84
87
|
type: 'tel',
|
|
85
88
|
required: hasPunchh
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
label: 'Gender',
|
|
92
|
+
name: 'gender',
|
|
93
|
+
type: 'select',
|
|
94
|
+
showLabel: true,
|
|
95
|
+
options: useProfileForm_1.genderOptions
|
|
86
96
|
}
|
|
87
97
|
];
|
|
88
98
|
const fields = allFields.filter(i => !toRemove.includes(i.name));
|
|
89
|
-
const notificationFields =
|
|
99
|
+
const notificationFields = notificationChannelFields.filter(i => notificationChannels === null || notificationChannels === void 0 ? void 0 : notificationChannels.includes(i.name));
|
|
90
100
|
(0, react_1.useEffect)(() => {
|
|
91
101
|
return () => {
|
|
92
102
|
setData(initState);
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { CheckoutFormCustomer, ConfigBrand, CustomerCreate,
|
|
3
|
-
export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, guestErrors: Record<string, string> | null, signUp: (data: CustomerCreate) => void, submitGuest: (data: CheckoutFormCustomer) => void, tpls?: ConfigBrand['tpls']
|
|
2
|
+
import { CheckoutFormCustomer, ConfigBrand, CustomerCreate, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, guestErrors: Record<string, string> | null, signUp: (data: CustomerCreate) => void, submitGuest: (data: CheckoutFormCustomer) => void, tpls?: ConfigBrand['tpls']) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
6
6
|
fields: import("@open-tender/types").FormFieldType[];
|
|
7
|
-
notificationFields: import("./useSignUpForm").NotificationCheckbox[];
|
|
8
7
|
data: CustomerCreate;
|
|
9
|
-
comms: NotificationChannel[];
|
|
10
8
|
errors: Record<string, string>;
|
|
11
9
|
disabled: boolean;
|
|
12
10
|
guestDisabled: boolean;
|
|
@@ -14,5 +12,4 @@ export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCust
|
|
|
14
12
|
handleChange: (name: string, value: string | number | boolean) => void;
|
|
15
13
|
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
16
14
|
handleGuest: () => void;
|
|
17
|
-
handleComms: (name: NotificationChannel, value: boolean) => void;
|
|
18
15
|
};
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useSignUpGuestForm = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
-
const useSignUpForm_1 = require("./useSignUpForm");
|
|
7
6
|
const initialData = {
|
|
8
7
|
first_name: '',
|
|
9
8
|
last_name: '',
|
|
@@ -11,12 +10,11 @@ const initialData = {
|
|
|
11
10
|
email: '',
|
|
12
11
|
password: ''
|
|
13
12
|
};
|
|
14
|
-
const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, submitGuest, tpls
|
|
13
|
+
const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, submitGuest, tpls) => {
|
|
15
14
|
const submitRef = (0, react_1.useRef)(null);
|
|
16
15
|
const inputRef = (0, react_1.useRef)(null);
|
|
17
16
|
const initData = Object.assign(Object.assign(Object.assign({}, initialData), guest), { email });
|
|
18
17
|
const [data, setData] = (0, react_1.useState)(initData);
|
|
19
|
-
const [comms, setComms] = (0, react_1.useState)([]);
|
|
20
18
|
const [errors, setErrors] = (0, react_1.useState)({});
|
|
21
19
|
const [submitting, setSubmitting] = (0, react_1.useState)(false);
|
|
22
20
|
const { guestData, guestIncomplete } = (0, utils_1.checkGuestData)(data, email);
|
|
@@ -68,7 +66,6 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
|
|
|
68
66
|
}
|
|
69
67
|
];
|
|
70
68
|
const fields = allFields.filter(i => !toRemove.includes(i.name));
|
|
71
|
-
const notificationFields = useSignUpForm_1.notificationChannelFields.filter(i => notificationChannels === null || notificationChannels === void 0 ? void 0 : notificationChannels.includes(i.name));
|
|
72
69
|
const handleChange = (name, value) => {
|
|
73
70
|
const val = name === 'phone'
|
|
74
71
|
? (0, utils_1.makePhone)(value)
|
|
@@ -83,7 +80,7 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
|
|
|
83
80
|
if (!disabled) {
|
|
84
81
|
setErrors({});
|
|
85
82
|
setSubmitting(true);
|
|
86
|
-
const values = Object.assign(Object.assign({}, data), { email
|
|
83
|
+
const values = Object.assign(Object.assign({}, data), { email });
|
|
87
84
|
if (values.birth_date) {
|
|
88
85
|
values.birth_date = (0, utils_1.slashesToDashes)(values.birth_date);
|
|
89
86
|
}
|
|
@@ -98,11 +95,6 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
|
|
|
98
95
|
submitGuest(Object.assign(Object.assign({}, guestData), { email }));
|
|
99
96
|
}
|
|
100
97
|
};
|
|
101
|
-
const handleComms = (name, value) => {
|
|
102
|
-
const other = comms.filter(i => i !== name);
|
|
103
|
-
const updated = value ? [...other, name] : other;
|
|
104
|
-
setComms(updated);
|
|
105
|
-
};
|
|
106
98
|
(0, react_1.useEffect)(() => {
|
|
107
99
|
var _a, _b;
|
|
108
100
|
if (loading === 'idle') {
|
|
@@ -130,17 +122,14 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
|
|
|
130
122
|
submitRef,
|
|
131
123
|
inputRef,
|
|
132
124
|
fields,
|
|
133
|
-
notificationFields,
|
|
134
125
|
data,
|
|
135
|
-
comms,
|
|
136
126
|
errors,
|
|
137
127
|
disabled,
|
|
138
128
|
guestDisabled,
|
|
139
129
|
submitting,
|
|
140
130
|
handleChange,
|
|
141
131
|
handleSubmit,
|
|
142
|
-
handleGuest
|
|
143
|
-
handleComms
|
|
132
|
+
handleGuest
|
|
144
133
|
};
|
|
145
134
|
};
|
|
146
135
|
exports.useSignUpGuestForm = useSignUpGuestForm;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckoutTender, CheckoutTenders,
|
|
1
|
+
import { CheckoutTender, CheckoutTenders, CreditCard, Money, OrderTender } from '@open-tender/types';
|
|
2
2
|
export declare const adjustTenders: (tenders: CheckoutTenders, isPaid: boolean, amountRemaining: number, updateForm: (form: {
|
|
3
3
|
tenders: any;
|
|
4
4
|
}) => void) => void;
|
|
@@ -53,4 +53,3 @@ export declare const updateTenders: (tenders: CheckoutTenders, total: Money) =>
|
|
|
53
53
|
export declare const makeCreditCardName: (creditCard: CreditCard) => string;
|
|
54
54
|
export declare const makeTenderName: (tender: OrderTender) => string;
|
|
55
55
|
export declare const makeCheckoutTenderName: (tender: CheckoutTender) => string | undefined;
|
|
56
|
-
export declare const makeConfirmationOrderType: (order: Order) => keyof ConfirmationSections | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.makeCheckoutTenderName = exports.makeTenderName = exports.makeCreditCardName = exports.updateTenders = exports.adjustTenders = void 0;
|
|
4
4
|
const types_1 = require("@open-tender/types");
|
|
5
5
|
const cart_1 = require("./cart");
|
|
6
6
|
const adjustTenders = (tenders, isPaid, amountRemaining, updateForm) => {
|
|
@@ -123,27 +123,3 @@ const makeCheckoutTenderName = (tender) => {
|
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
exports.makeCheckoutTenderName = makeCheckoutTenderName;
|
|
126
|
-
const makeConfirmationOrderType = (order) => {
|
|
127
|
-
if (!order)
|
|
128
|
-
return null;
|
|
129
|
-
const { order_type, service_type, order_fulfillment, revenue_center, details } = order;
|
|
130
|
-
const { notes_internal } = details || {};
|
|
131
|
-
const isWalkIn = service_type === 'WALKIN';
|
|
132
|
-
if (isWalkIn) {
|
|
133
|
-
if (notes_internal && notes_internal.includes('TAKE OUT')) {
|
|
134
|
-
return 'takeOut';
|
|
135
|
-
}
|
|
136
|
-
return 'dineIn';
|
|
137
|
-
}
|
|
138
|
-
if (order_type === 'CATERING')
|
|
139
|
-
return 'catering';
|
|
140
|
-
if (revenue_center.is_outpost)
|
|
141
|
-
return 'outpost';
|
|
142
|
-
if (service_type === 'DELIVERY')
|
|
143
|
-
return 'delivery';
|
|
144
|
-
if (service_type === 'PICKUP' && order_fulfillment) {
|
|
145
|
-
return 'curbside';
|
|
146
|
-
}
|
|
147
|
-
return 'pickup';
|
|
148
|
-
};
|
|
149
|
-
exports.makeConfirmationOrderType = makeConfirmationOrderType;
|
|
@@ -158,10 +158,10 @@ const getRevenueCenterStatus = (hours, firstTimes, serviceType, timezone) => {
|
|
|
158
158
|
const firstTimeDate = (0, date_fns_1.parseISO)(serviceFirstTimes.date);
|
|
159
159
|
const canOrderToday = (0, date_fns_1.isToday)(firstTimeDate);
|
|
160
160
|
if (canOrderToday)
|
|
161
|
-
return 'Currently
|
|
161
|
+
return 'Currently Closed, Order for later today';
|
|
162
162
|
const nextAvailableDate = (0, date_fns_1.isTomorrow)(firstTimeDate)
|
|
163
163
|
? 'tomorrow'
|
|
164
164
|
: (0, date_fns_1.format)(firstTimeDate, 'EEEE');
|
|
165
|
-
return `Closed for
|
|
165
|
+
return `Closed for the Day, Order for ${nextAvailableDate}`;
|
|
166
166
|
};
|
|
167
167
|
exports.getRevenueCenterStatus = getRevenueCenterStatus;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Customer, CustomerCreate, FormFieldType, RequestError, RequestStatus } from '@open-tender/types';
|
|
2
|
+
import { Customer, CustomerCreate, FormFieldType, Gender, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export declare const genderOptions: {
|
|
4
|
+
name: string;
|
|
5
|
+
value: Gender;
|
|
6
|
+
}[];
|
|
3
7
|
export declare const useProfileForm: (profile: Customer | null, loading: RequestStatus, error: RequestError, update: (data: CustomerCreate) => void, callback?: ((data: CustomerCreate) => void) | undefined, optionalFields?: string[]) => {
|
|
4
8
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
9
|
data: Customer | null;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { useRef, useState, useEffect, useMemo } from 'react';
|
|
2
2
|
import { makeBirthDate, makeFormErrors, makePhone, slashesToDashes } from '../utils';
|
|
3
|
+
export const genderOptions = [
|
|
4
|
+
{ name: 'not specified', value: 'DECLINED' },
|
|
5
|
+
{ name: 'Male', value: 'MALE' },
|
|
6
|
+
{ name: 'Female', value: 'FEMALE' }
|
|
7
|
+
];
|
|
3
8
|
const allFields = [
|
|
4
9
|
{ label: 'First Name', name: 'first_name', type: 'text', required: true },
|
|
5
10
|
{ label: 'Last Name', name: 'last_name', type: 'text', required: true },
|
|
@@ -12,13 +17,21 @@ const allFields = [
|
|
|
12
17
|
},
|
|
13
18
|
{ label: 'Phone', name: 'phone', type: 'tel', required: true },
|
|
14
19
|
{ label: 'Company', name: 'company', type: 'text' },
|
|
15
|
-
{ label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' }
|
|
20
|
+
{ label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' },
|
|
21
|
+
{
|
|
22
|
+
label: 'Gender',
|
|
23
|
+
name: 'gender',
|
|
24
|
+
type: 'select',
|
|
25
|
+
showLabel: true,
|
|
26
|
+
options: genderOptions
|
|
27
|
+
}
|
|
16
28
|
];
|
|
17
29
|
const makePayload = (fields, data) => {
|
|
18
30
|
if (!data)
|
|
19
31
|
return null;
|
|
20
32
|
const rest = fields.reduce((obj, i) => (Object.assign(Object.assign({}, obj), { [i.name]: data[i.name] })), {});
|
|
21
33
|
rest.birth_date = data.birth_date ? slashesToDashes(data.birth_date) : null;
|
|
34
|
+
rest.gender = data.gender || null;
|
|
22
35
|
return rest;
|
|
23
36
|
};
|
|
24
37
|
export const useProfileForm = (profile, loading, error, update, callback, optionalFields) => {
|
|
@@ -30,6 +43,8 @@ export const useProfileForm = (profile, loading, error, update, callback, option
|
|
|
30
43
|
const removed = [];
|
|
31
44
|
if (optionalFields && !optionalFields.includes('birth_date'))
|
|
32
45
|
removed.push('birth_date');
|
|
46
|
+
if (optionalFields && !optionalFields.includes('gender'))
|
|
47
|
+
removed.push('gender');
|
|
33
48
|
return removed;
|
|
34
49
|
}, [optionalFields]);
|
|
35
50
|
// const fields = allFields.filter((i) => !toRemove.includes(i.name))
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutConfig, ConfigBrand, Customer, CustomerCreate, NotificationChannel, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
|
|
3
|
+
interface NotificationCheckbox {
|
|
4
4
|
label: string;
|
|
5
5
|
name: NotificationChannel;
|
|
6
6
|
type: string;
|
|
7
7
|
}
|
|
8
|
-
export declare const notificationChannelFields: NotificationCheckbox[];
|
|
9
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, tpls?: ConfigBrand['tpls']) => {
|
|
10
9
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
11
10
|
data: CustomerCreate;
|
|
@@ -18,3 +17,4 @@ export declare const useSignUpForm: (loading: RequestStatus, error: RequestError
|
|
|
18
17
|
handleComms: (name: NotificationChannel, value: boolean) => void;
|
|
19
18
|
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
20
19
|
};
|
|
20
|
+
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { useRef, useState, useEffect } from 'react';
|
|
2
2
|
import { makeBirthDate, makeFormErrors, makePhone, slashesToDashes } from '../utils';
|
|
3
|
+
import { genderOptions } from './useProfileForm';
|
|
3
4
|
const initState = {
|
|
4
5
|
first_name: '',
|
|
5
6
|
last_name: '',
|
|
6
7
|
email: '',
|
|
7
8
|
phone: ''
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
const notificationChannelFields = [
|
|
10
11
|
{
|
|
11
12
|
label: 'Email',
|
|
12
13
|
name: 'EMAIL',
|
|
@@ -41,6 +42,8 @@ export const useSignUpForm = (loading, error, signUp, callback, checkConfig, hid
|
|
|
41
42
|
toRemove.push('password');
|
|
42
43
|
if (optionalFields && !optionalFields.includes('birth_date'))
|
|
43
44
|
toRemove.push('birth_date');
|
|
45
|
+
if (optionalFields && !optionalFields.includes('gender'))
|
|
46
|
+
toRemove.push('gender');
|
|
44
47
|
const allFields = [
|
|
45
48
|
{
|
|
46
49
|
label: 'First Name',
|
|
@@ -80,6 +83,13 @@ export const useSignUpForm = (loading, error, signUp, callback, checkConfig, hid
|
|
|
80
83
|
name: 'birth_date',
|
|
81
84
|
type: 'tel',
|
|
82
85
|
required: hasPunchh
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: 'Gender',
|
|
89
|
+
name: 'gender',
|
|
90
|
+
type: 'select',
|
|
91
|
+
showLabel: true,
|
|
92
|
+
options: genderOptions
|
|
83
93
|
}
|
|
84
94
|
];
|
|
85
95
|
const fields = allFields.filter(i => !toRemove.includes(i.name));
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { CheckoutFormCustomer, ConfigBrand, CustomerCreate,
|
|
3
|
-
export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, guestErrors: Record<string, string> | null, signUp: (data: CustomerCreate) => void, submitGuest: (data: CheckoutFormCustomer) => void, tpls?: ConfigBrand['tpls']
|
|
2
|
+
import { CheckoutFormCustomer, ConfigBrand, CustomerCreate, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCustomer, loading: RequestStatus, error: RequestError, guestErrors: Record<string, string> | null, signUp: (data: CustomerCreate) => void, submitGuest: (data: CheckoutFormCustomer) => void, tpls?: ConfigBrand['tpls']) => {
|
|
4
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
5
5
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
6
6
|
fields: import("@open-tender/types").FormFieldType[];
|
|
7
|
-
notificationFields: import("./useSignUpForm").NotificationCheckbox[];
|
|
8
7
|
data: CustomerCreate;
|
|
9
|
-
comms: NotificationChannel[];
|
|
10
8
|
errors: Record<string, string>;
|
|
11
9
|
disabled: boolean;
|
|
12
10
|
guestDisabled: boolean;
|
|
@@ -14,5 +12,4 @@ export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCust
|
|
|
14
12
|
handleChange: (name: string, value: string | number | boolean) => void;
|
|
15
13
|
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
16
14
|
handleGuest: () => void;
|
|
17
|
-
handleComms: (name: NotificationChannel, value: boolean) => void;
|
|
18
15
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useRef, useState, useEffect } from 'react';
|
|
2
2
|
import { checkGuestData, makeBirthDate, makeFormErrors, makePhone, slashesToDashes } from '../utils';
|
|
3
|
-
import { notificationChannelFields } from './useSignUpForm';
|
|
4
3
|
const initialData = {
|
|
5
4
|
first_name: '',
|
|
6
5
|
last_name: '',
|
|
@@ -8,12 +7,11 @@ const initialData = {
|
|
|
8
7
|
email: '',
|
|
9
8
|
password: ''
|
|
10
9
|
};
|
|
11
|
-
export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, submitGuest, tpls
|
|
10
|
+
export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, submitGuest, tpls) => {
|
|
12
11
|
const submitRef = useRef(null);
|
|
13
12
|
const inputRef = useRef(null);
|
|
14
13
|
const initData = Object.assign(Object.assign(Object.assign({}, initialData), guest), { email });
|
|
15
14
|
const [data, setData] = useState(initData);
|
|
16
|
-
const [comms, setComms] = useState([]);
|
|
17
15
|
const [errors, setErrors] = useState({});
|
|
18
16
|
const [submitting, setSubmitting] = useState(false);
|
|
19
17
|
const { guestData, guestIncomplete } = checkGuestData(data, email);
|
|
@@ -65,7 +63,6 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
|
|
|
65
63
|
}
|
|
66
64
|
];
|
|
67
65
|
const fields = allFields.filter(i => !toRemove.includes(i.name));
|
|
68
|
-
const notificationFields = notificationChannelFields.filter(i => notificationChannels === null || notificationChannels === void 0 ? void 0 : notificationChannels.includes(i.name));
|
|
69
66
|
const handleChange = (name, value) => {
|
|
70
67
|
const val = name === 'phone'
|
|
71
68
|
? makePhone(value)
|
|
@@ -80,7 +77,7 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
|
|
|
80
77
|
if (!disabled) {
|
|
81
78
|
setErrors({});
|
|
82
79
|
setSubmitting(true);
|
|
83
|
-
const values = Object.assign(Object.assign({}, data), { email
|
|
80
|
+
const values = Object.assign(Object.assign({}, data), { email });
|
|
84
81
|
if (values.birth_date) {
|
|
85
82
|
values.birth_date = slashesToDashes(values.birth_date);
|
|
86
83
|
}
|
|
@@ -95,11 +92,6 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
|
|
|
95
92
|
submitGuest(Object.assign(Object.assign({}, guestData), { email }));
|
|
96
93
|
}
|
|
97
94
|
};
|
|
98
|
-
const handleComms = (name, value) => {
|
|
99
|
-
const other = comms.filter(i => i !== name);
|
|
100
|
-
const updated = value ? [...other, name] : other;
|
|
101
|
-
setComms(updated);
|
|
102
|
-
};
|
|
103
95
|
useEffect(() => {
|
|
104
96
|
var _a, _b;
|
|
105
97
|
if (loading === 'idle') {
|
|
@@ -127,16 +119,13 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
|
|
|
127
119
|
submitRef,
|
|
128
120
|
inputRef,
|
|
129
121
|
fields,
|
|
130
|
-
notificationFields,
|
|
131
122
|
data,
|
|
132
|
-
comms,
|
|
133
123
|
errors,
|
|
134
124
|
disabled,
|
|
135
125
|
guestDisabled,
|
|
136
126
|
submitting,
|
|
137
127
|
handleChange,
|
|
138
128
|
handleSubmit,
|
|
139
|
-
handleGuest
|
|
140
|
-
handleComms
|
|
129
|
+
handleGuest
|
|
141
130
|
};
|
|
142
131
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckoutTender, CheckoutTenders,
|
|
1
|
+
import { CheckoutTender, CheckoutTenders, CreditCard, Money, OrderTender } from '@open-tender/types';
|
|
2
2
|
export declare const adjustTenders: (tenders: CheckoutTenders, isPaid: boolean, amountRemaining: number, updateForm: (form: {
|
|
3
3
|
tenders: any;
|
|
4
4
|
}) => void) => void;
|
|
@@ -53,4 +53,3 @@ export declare const updateTenders: (tenders: CheckoutTenders, total: Money) =>
|
|
|
53
53
|
export declare const makeCreditCardName: (creditCard: CreditCard) => string;
|
|
54
54
|
export declare const makeTenderName: (tender: OrderTender) => string;
|
|
55
55
|
export declare const makeCheckoutTenderName: (tender: CheckoutTender) => string | undefined;
|
|
56
|
-
export declare const makeConfirmationOrderType: (order: Order) => keyof ConfirmationSections | null;
|
|
@@ -115,26 +115,3 @@ export const makeCheckoutTenderName = (tender) => {
|
|
|
115
115
|
return '';
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
export const makeConfirmationOrderType = (order) => {
|
|
119
|
-
if (!order)
|
|
120
|
-
return null;
|
|
121
|
-
const { order_type, service_type, order_fulfillment, revenue_center, details } = order;
|
|
122
|
-
const { notes_internal } = details || {};
|
|
123
|
-
const isWalkIn = service_type === 'WALKIN';
|
|
124
|
-
if (isWalkIn) {
|
|
125
|
-
if (notes_internal && notes_internal.includes('TAKE OUT')) {
|
|
126
|
-
return 'takeOut';
|
|
127
|
-
}
|
|
128
|
-
return 'dineIn';
|
|
129
|
-
}
|
|
130
|
-
if (order_type === 'CATERING')
|
|
131
|
-
return 'catering';
|
|
132
|
-
if (revenue_center.is_outpost)
|
|
133
|
-
return 'outpost';
|
|
134
|
-
if (service_type === 'DELIVERY')
|
|
135
|
-
return 'delivery';
|
|
136
|
-
if (service_type === 'PICKUP' && order_fulfillment) {
|
|
137
|
-
return 'curbside';
|
|
138
|
-
}
|
|
139
|
-
return 'pickup';
|
|
140
|
-
};
|
|
@@ -147,9 +147,9 @@ export const getRevenueCenterStatus = (hours, firstTimes, serviceType, timezone)
|
|
|
147
147
|
const firstTimeDate = parseISO(serviceFirstTimes.date);
|
|
148
148
|
const canOrderToday = isToday(firstTimeDate);
|
|
149
149
|
if (canOrderToday)
|
|
150
|
-
return 'Currently
|
|
150
|
+
return 'Currently Closed, Order for later today';
|
|
151
151
|
const nextAvailableDate = isTomorrow(firstTimeDate)
|
|
152
152
|
? 'tomorrow'
|
|
153
153
|
: format(firstTimeDate, 'EEEE');
|
|
154
|
-
return `Closed for
|
|
154
|
+
return `Closed for the Day, Order for ${nextAvailableDate}`;
|
|
155
155
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/utils",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.53",
|
|
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.77",
|
|
39
40
|
"@reduxjs/toolkit": "^1.8.5",
|
|
40
41
|
"@types/google.maps": "^3.53.5",
|
|
41
42
|
"@types/jest": "^29.5.11",
|