@open-tender/utils 0.4.53 → 0.4.55
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 +1 -5
- package/dist/cjs/hooks/useProfileForm.js +2 -17
- package/dist/cjs/hooks/useSignUpForm.d.ts +2 -2
- package/dist/cjs/hooks/useSignUpForm.js +3 -13
- package/dist/cjs/hooks/useSignUpGuestForm.d.ts +5 -2
- package/dist/cjs/hooks/useSignUpGuestForm.js +14 -3
- package/dist/cjs/utils/checkout.d.ts +2 -1
- package/dist/cjs/utils/checkout.js +25 -1
- package/dist/cjs/utils/customer.js +0 -1
- package/dist/cjs/utils/revenueCenters.d.ts +3 -3
- package/dist/cjs/utils/revenueCenters.js +20 -25
- package/dist/esm/hooks/useProfileForm.d.ts +1 -5
- package/dist/esm/hooks/useProfileForm.js +1 -16
- package/dist/esm/hooks/useSignUpForm.d.ts +2 -2
- package/dist/esm/hooks/useSignUpForm.js +1 -11
- package/dist/esm/hooks/useSignUpGuestForm.d.ts +5 -2
- package/dist/esm/hooks/useSignUpGuestForm.js +14 -3
- package/dist/esm/utils/checkout.d.ts +2 -1
- package/dist/esm/utils/checkout.js +23 -0
- package/dist/esm/utils/customer.js +0 -1
- package/dist/esm/utils/revenueCenters.d.ts +3 -3
- package/dist/esm/utils/revenueCenters.js +21 -26
- package/package.json +1 -1
- package/dist/cjs/__tests__/utils/revenueCenters.test.d.ts +0 -1
- package/dist/cjs/__tests__/utils/revenueCenters.test.js +0 -75
- package/dist/esm/__tests__/utils/revenueCenters.test.d.ts +0 -1
- package/dist/esm/__tests__/utils/revenueCenters.test.js +0 -73
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Customer, CustomerCreate, FormFieldType,
|
|
3
|
-
export declare const genderOptions: {
|
|
4
|
-
name: string;
|
|
5
|
-
value: Gender;
|
|
6
|
-
}[];
|
|
2
|
+
import { Customer, CustomerCreate, FormFieldType, RequestError, RequestStatus } from '@open-tender/types';
|
|
7
3
|
export declare const useProfileForm: (profile: Customer | null, loading: RequestStatus, error: RequestError, update: (data: CustomerCreate) => void, callback?: ((data: CustomerCreate) => void) | undefined, optionalFields?: string[]) => {
|
|
8
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
9
5
|
data: Customer | null;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useProfileForm =
|
|
3
|
+
exports.useProfileForm = 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
|
-
];
|
|
11
6
|
const allFields = [
|
|
12
7
|
{ label: 'First Name', name: 'first_name', type: 'text', required: true },
|
|
13
8
|
{ label: 'Last Name', name: 'last_name', type: 'text', required: true },
|
|
@@ -20,21 +15,13 @@ const allFields = [
|
|
|
20
15
|
},
|
|
21
16
|
{ label: 'Phone', name: 'phone', type: 'tel', required: true },
|
|
22
17
|
{ label: 'Company', name: 'company', type: 'text' },
|
|
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
|
-
}
|
|
18
|
+
{ label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' }
|
|
31
19
|
];
|
|
32
20
|
const makePayload = (fields, data) => {
|
|
33
21
|
if (!data)
|
|
34
22
|
return null;
|
|
35
23
|
const rest = fields.reduce((obj, i) => (Object.assign(Object.assign({}, obj), { [i.name]: data[i.name] })), {});
|
|
36
24
|
rest.birth_date = data.birth_date ? (0, utils_1.slashesToDashes)(data.birth_date) : null;
|
|
37
|
-
rest.gender = data.gender || null;
|
|
38
25
|
return rest;
|
|
39
26
|
};
|
|
40
27
|
const useProfileForm = (profile, loading, error, update, callback, optionalFields) => {
|
|
@@ -46,8 +33,6 @@ const useProfileForm = (profile, loading, error, update, callback, optionalField
|
|
|
46
33
|
const removed = [];
|
|
47
34
|
if (optionalFields && !optionalFields.includes('birth_date'))
|
|
48
35
|
removed.push('birth_date');
|
|
49
|
-
if (optionalFields && !optionalFields.includes('gender'))
|
|
50
|
-
removed.push('gender');
|
|
51
36
|
return removed;
|
|
52
37
|
}, [optionalFields]);
|
|
53
38
|
// const fields = allFields.filter((i) => !toRemove.includes(i.name))
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutConfig, ConfigBrand, Customer, CustomerCreate, NotificationChannel, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
interface NotificationCheckbox {
|
|
3
|
+
export interface NotificationCheckbox {
|
|
4
4
|
label: string;
|
|
5
5
|
name: NotificationChannel;
|
|
6
6
|
type: string;
|
|
7
7
|
}
|
|
8
|
+
export declare const notificationChannelFields: NotificationCheckbox[];
|
|
8
9
|
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']) => {
|
|
9
10
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
10
11
|
data: CustomerCreate;
|
|
@@ -17,4 +18,3 @@ export declare const useSignUpForm: (loading: RequestStatus, error: RequestError
|
|
|
17
18
|
handleComms: (name: NotificationChannel, value: boolean) => void;
|
|
18
19
|
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
19
20
|
};
|
|
20
|
-
export {};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSignUpForm = void 0;
|
|
3
|
+
exports.useSignUpForm = exports.notificationChannelFields = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
-
const useProfileForm_1 = require("./useProfileForm");
|
|
7
6
|
const initState = {
|
|
8
7
|
first_name: '',
|
|
9
8
|
last_name: '',
|
|
10
9
|
email: '',
|
|
11
10
|
phone: ''
|
|
12
11
|
};
|
|
13
|
-
|
|
12
|
+
exports.notificationChannelFields = [
|
|
14
13
|
{
|
|
15
14
|
label: 'Email',
|
|
16
15
|
name: 'EMAIL',
|
|
@@ -45,8 +44,6 @@ const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePasswo
|
|
|
45
44
|
toRemove.push('password');
|
|
46
45
|
if (optionalFields && !optionalFields.includes('birth_date'))
|
|
47
46
|
toRemove.push('birth_date');
|
|
48
|
-
if (optionalFields && !optionalFields.includes('gender'))
|
|
49
|
-
toRemove.push('gender');
|
|
50
47
|
const allFields = [
|
|
51
48
|
{
|
|
52
49
|
label: 'First Name',
|
|
@@ -86,17 +83,10 @@ const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePasswo
|
|
|
86
83
|
name: 'birth_date',
|
|
87
84
|
type: 'tel',
|
|
88
85
|
required: hasPunchh
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
label: 'Gender',
|
|
92
|
-
name: 'gender',
|
|
93
|
-
type: 'select',
|
|
94
|
-
showLabel: true,
|
|
95
|
-
options: useProfileForm_1.genderOptions
|
|
96
86
|
}
|
|
97
87
|
];
|
|
98
88
|
const fields = allFields.filter(i => !toRemove.includes(i.name));
|
|
99
|
-
const notificationFields = notificationChannelFields.filter(i => notificationChannels === null || notificationChannels === void 0 ? void 0 : notificationChannels.includes(i.name));
|
|
89
|
+
const notificationFields = exports.notificationChannelFields.filter(i => notificationChannels === null || notificationChannels === void 0 ? void 0 : notificationChannels.includes(i.name));
|
|
100
90
|
(0, react_1.useEffect)(() => {
|
|
101
91
|
return () => {
|
|
102
92
|
setData(initState);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
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']) => {
|
|
2
|
+
import { CheckoutFormCustomer, ConfigBrand, CustomerCreate, NotificationChannel, 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'], notificationChannels?: NotificationChannel[]) => {
|
|
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[];
|
|
7
8
|
data: CustomerCreate;
|
|
9
|
+
comms: NotificationChannel[];
|
|
8
10
|
errors: Record<string, string>;
|
|
9
11
|
disabled: boolean;
|
|
10
12
|
guestDisabled: boolean;
|
|
@@ -12,4 +14,5 @@ export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCust
|
|
|
12
14
|
handleChange: (name: string, value: string | number | boolean) => void;
|
|
13
15
|
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
14
16
|
handleGuest: () => void;
|
|
17
|
+
handleComms: (name: NotificationChannel, value: boolean) => void;
|
|
15
18
|
};
|
|
@@ -3,6 +3,7 @@ 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");
|
|
6
7
|
const initialData = {
|
|
7
8
|
first_name: '',
|
|
8
9
|
last_name: '',
|
|
@@ -10,11 +11,12 @@ const initialData = {
|
|
|
10
11
|
email: '',
|
|
11
12
|
password: ''
|
|
12
13
|
};
|
|
13
|
-
const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, submitGuest, tpls) => {
|
|
14
|
+
const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, submitGuest, tpls, notificationChannels = []) => {
|
|
14
15
|
const submitRef = (0, react_1.useRef)(null);
|
|
15
16
|
const inputRef = (0, react_1.useRef)(null);
|
|
16
17
|
const initData = Object.assign(Object.assign(Object.assign({}, initialData), guest), { email });
|
|
17
18
|
const [data, setData] = (0, react_1.useState)(initData);
|
|
19
|
+
const [comms, setComms] = (0, react_1.useState)([]);
|
|
18
20
|
const [errors, setErrors] = (0, react_1.useState)({});
|
|
19
21
|
const [submitting, setSubmitting] = (0, react_1.useState)(false);
|
|
20
22
|
const { guestData, guestIncomplete } = (0, utils_1.checkGuestData)(data, email);
|
|
@@ -66,6 +68,7 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
|
|
|
66
68
|
}
|
|
67
69
|
];
|
|
68
70
|
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));
|
|
69
72
|
const handleChange = (name, value) => {
|
|
70
73
|
const val = name === 'phone'
|
|
71
74
|
? (0, utils_1.makePhone)(value)
|
|
@@ -80,7 +83,7 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
|
|
|
80
83
|
if (!disabled) {
|
|
81
84
|
setErrors({});
|
|
82
85
|
setSubmitting(true);
|
|
83
|
-
const values = Object.assign(Object.assign({}, data), { email });
|
|
86
|
+
const values = Object.assign(Object.assign({}, data), { email, communications: comms });
|
|
84
87
|
if (values.birth_date) {
|
|
85
88
|
values.birth_date = (0, utils_1.slashesToDashes)(values.birth_date);
|
|
86
89
|
}
|
|
@@ -95,6 +98,11 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
|
|
|
95
98
|
submitGuest(Object.assign(Object.assign({}, guestData), { email }));
|
|
96
99
|
}
|
|
97
100
|
};
|
|
101
|
+
const handleComms = (name, value) => {
|
|
102
|
+
const other = comms.filter(i => i !== name);
|
|
103
|
+
const updated = value ? [...other, name] : other;
|
|
104
|
+
setComms(updated);
|
|
105
|
+
};
|
|
98
106
|
(0, react_1.useEffect)(() => {
|
|
99
107
|
var _a, _b;
|
|
100
108
|
if (loading === 'idle') {
|
|
@@ -122,14 +130,17 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
|
|
|
122
130
|
submitRef,
|
|
123
131
|
inputRef,
|
|
124
132
|
fields,
|
|
133
|
+
notificationFields,
|
|
125
134
|
data,
|
|
135
|
+
comms,
|
|
126
136
|
errors,
|
|
127
137
|
disabled,
|
|
128
138
|
guestDisabled,
|
|
129
139
|
submitting,
|
|
130
140
|
handleChange,
|
|
131
141
|
handleSubmit,
|
|
132
|
-
handleGuest
|
|
142
|
+
handleGuest,
|
|
143
|
+
handleComms
|
|
133
144
|
};
|
|
134
145
|
};
|
|
135
146
|
exports.useSignUpGuestForm = useSignUpGuestForm;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckoutTender, CheckoutTenders, CreditCard, Money, OrderTender } from '@open-tender/types';
|
|
1
|
+
import { CheckoutTender, CheckoutTenders, ConfirmationSections, CreditCard, Money, Order, 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,3 +53,4 @@ 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.makeCheckoutTenderName = exports.makeTenderName = exports.makeCreditCardName = exports.updateTenders = exports.adjustTenders = void 0;
|
|
3
|
+
exports.makeConfirmationOrderType = 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,3 +123,27 @@ 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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address,
|
|
1
|
+
import { Address, OrderType, RevenueCenter, ServiceType } from '@open-tender/types';
|
|
2
2
|
export declare const makeOrderAddress: (address: Address | null) => string;
|
|
3
3
|
export declare const makeFullAddress: (address: Address) => string;
|
|
4
4
|
export declare const makeOrderTypeFromParam: (param: string) => (string | boolean)[] | null;
|
|
@@ -9,5 +9,5 @@ export declare const makeRevenueCenterMsg: (revenueCenter: RevenueCenter, servic
|
|
|
9
9
|
message: any;
|
|
10
10
|
color: string;
|
|
11
11
|
};
|
|
12
|
-
export declare const isRevenueCenterOpen: (
|
|
13
|
-
export declare const getRevenueCenterStatus: (
|
|
12
|
+
export declare const isRevenueCenterOpen: (revenueCenter: RevenueCenter, serviceType: ServiceType, statusMessages: Record<string, string>) => boolean;
|
|
13
|
+
export declare const getRevenueCenterStatus: (revenueCenter: RevenueCenter, serviceType: ServiceType, statusMessages: Record<string, string>) => string;
|
|
@@ -5,7 +5,6 @@ const constants_1 = require("./constants");
|
|
|
5
5
|
const datetimes_1 = require("./datetimes");
|
|
6
6
|
const helpers_1 = require("./helpers");
|
|
7
7
|
const date_fns_1 = require("date-fns");
|
|
8
|
-
const date_fns_tz_1 = require("date-fns-tz");
|
|
9
8
|
const makeOrderAddress = (address) => {
|
|
10
9
|
const { street, unit, city, state, postal_code } = address || {};
|
|
11
10
|
return street
|
|
@@ -125,43 +124,39 @@ const makeRevenueCenterMsg = (revenueCenter, serviceType, requestedAt, statusMes
|
|
|
125
124
|
return { message, color };
|
|
126
125
|
};
|
|
127
126
|
exports.makeRevenueCenterMsg = makeRevenueCenterMsg;
|
|
128
|
-
const isRevenueCenterOpen = (
|
|
129
|
-
const
|
|
130
|
-
|
|
127
|
+
const isRevenueCenterOpen = (revenueCenter, serviceType, statusMessages) => {
|
|
128
|
+
const { status, first_times, order_times } = revenueCenter;
|
|
129
|
+
const tempClosed = status === 'CLOSED_TEMPORARILY';
|
|
130
|
+
if (tempClosed)
|
|
131
131
|
return false;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
const currentWeekday = (0, date_fns_1.format)(zonedDate, 'EEEE').toUpperCase();
|
|
135
|
-
const todayHours = serviceHours.find(hour => hour.weekday === currentWeekday);
|
|
136
|
-
if (!todayHours || !todayHours.open || !todayHours.close)
|
|
132
|
+
const statusMsg = statusMessages[revenueCenter.status];
|
|
133
|
+
if (!statusMsg)
|
|
137
134
|
return false;
|
|
138
|
-
const [
|
|
139
|
-
const [
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
minutes: closeMinutes
|
|
144
|
-
});
|
|
145
|
-
return (0, date_fns_1.isBefore)(openingTime, zonedDate) && (0, date_fns_1.isAfter)(closingTime, zonedDate);
|
|
135
|
+
const serviceOrderTimes = order_times ? order_times[serviceType] : null;
|
|
136
|
+
const serviceFirstTimes = first_times ? first_times[serviceType] : null;
|
|
137
|
+
const isHasFirstTimes = !!serviceFirstTimes;
|
|
138
|
+
const isHasOrderTime = !!serviceOrderTimes && serviceOrderTimes.length > 0;
|
|
139
|
+
return !isHasFirstTimes && !isHasOrderTime;
|
|
146
140
|
};
|
|
147
141
|
exports.isRevenueCenterOpen = isRevenueCenterOpen;
|
|
148
|
-
const getRevenueCenterStatus = (
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const tz = datetimes_1.timezoneMap[timezone !== null && timezone !== void 0 ? timezone : 'US/Central'];
|
|
152
|
-
const isOpen = (0, exports.isRevenueCenterOpen)(hours, tz, serviceType);
|
|
142
|
+
const getRevenueCenterStatus = (revenueCenter, serviceType, statusMessages) => {
|
|
143
|
+
const { first_times } = revenueCenter;
|
|
144
|
+
const isOpen = (0, exports.isRevenueCenterOpen)(revenueCenter, serviceType, statusMessages);
|
|
153
145
|
if (isOpen)
|
|
154
146
|
return 'Open Now';
|
|
155
|
-
const
|
|
147
|
+
const statusMsg = statusMessages[revenueCenter.status];
|
|
148
|
+
if (!statusMsg)
|
|
149
|
+
return 'Closed';
|
|
150
|
+
const serviceFirstTimes = first_times ? first_times[serviceType] : null;
|
|
156
151
|
if (!serviceFirstTimes)
|
|
157
152
|
return 'Closed';
|
|
158
153
|
const firstTimeDate = (0, date_fns_1.parseISO)(serviceFirstTimes.date);
|
|
159
154
|
const canOrderToday = (0, date_fns_1.isToday)(firstTimeDate);
|
|
160
155
|
if (canOrderToday)
|
|
161
|
-
return 'Currently
|
|
156
|
+
return 'Currently closed, order for later today';
|
|
162
157
|
const nextAvailableDate = (0, date_fns_1.isTomorrow)(firstTimeDate)
|
|
163
158
|
? 'tomorrow'
|
|
164
159
|
: (0, date_fns_1.format)(firstTimeDate, 'EEEE');
|
|
165
|
-
return `Closed for
|
|
160
|
+
return `Closed for today, order for ${nextAvailableDate}`;
|
|
166
161
|
};
|
|
167
162
|
exports.getRevenueCenterStatus = getRevenueCenterStatus;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Customer, CustomerCreate, FormFieldType,
|
|
3
|
-
export declare const genderOptions: {
|
|
4
|
-
name: string;
|
|
5
|
-
value: Gender;
|
|
6
|
-
}[];
|
|
2
|
+
import { Customer, CustomerCreate, FormFieldType, RequestError, RequestStatus } from '@open-tender/types';
|
|
7
3
|
export declare const useProfileForm: (profile: Customer | null, loading: RequestStatus, error: RequestError, update: (data: CustomerCreate) => void, callback?: ((data: CustomerCreate) => void) | undefined, optionalFields?: string[]) => {
|
|
8
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
9
5
|
data: Customer | null;
|
|
@@ -1,10 +1,5 @@
|
|
|
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
|
-
];
|
|
8
3
|
const allFields = [
|
|
9
4
|
{ label: 'First Name', name: 'first_name', type: 'text', required: true },
|
|
10
5
|
{ label: 'Last Name', name: 'last_name', type: 'text', required: true },
|
|
@@ -17,21 +12,13 @@ const allFields = [
|
|
|
17
12
|
},
|
|
18
13
|
{ label: 'Phone', name: 'phone', type: 'tel', required: true },
|
|
19
14
|
{ label: 'Company', name: 'company', type: 'text' },
|
|
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
|
-
}
|
|
15
|
+
{ label: 'Birth Date (mm/dd/yyyy)', name: 'birth_date', type: 'tel' }
|
|
28
16
|
];
|
|
29
17
|
const makePayload = (fields, data) => {
|
|
30
18
|
if (!data)
|
|
31
19
|
return null;
|
|
32
20
|
const rest = fields.reduce((obj, i) => (Object.assign(Object.assign({}, obj), { [i.name]: data[i.name] })), {});
|
|
33
21
|
rest.birth_date = data.birth_date ? slashesToDashes(data.birth_date) : null;
|
|
34
|
-
rest.gender = data.gender || null;
|
|
35
22
|
return rest;
|
|
36
23
|
};
|
|
37
24
|
export const useProfileForm = (profile, loading, error, update, callback, optionalFields) => {
|
|
@@ -43,8 +30,6 @@ export const useProfileForm = (profile, loading, error, update, callback, option
|
|
|
43
30
|
const removed = [];
|
|
44
31
|
if (optionalFields && !optionalFields.includes('birth_date'))
|
|
45
32
|
removed.push('birth_date');
|
|
46
|
-
if (optionalFields && !optionalFields.includes('gender'))
|
|
47
|
-
removed.push('gender');
|
|
48
33
|
return removed;
|
|
49
34
|
}, [optionalFields]);
|
|
50
35
|
// const fields = allFields.filter((i) => !toRemove.includes(i.name))
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckoutConfig, ConfigBrand, Customer, CustomerCreate, NotificationChannel, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
interface NotificationCheckbox {
|
|
3
|
+
export interface NotificationCheckbox {
|
|
4
4
|
label: string;
|
|
5
5
|
name: NotificationChannel;
|
|
6
6
|
type: string;
|
|
7
7
|
}
|
|
8
|
+
export declare const notificationChannelFields: NotificationCheckbox[];
|
|
8
9
|
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']) => {
|
|
9
10
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
10
11
|
data: CustomerCreate;
|
|
@@ -17,4 +18,3 @@ export declare const useSignUpForm: (loading: RequestStatus, error: RequestError
|
|
|
17
18
|
handleComms: (name: NotificationChannel, value: boolean) => void;
|
|
18
19
|
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
19
20
|
};
|
|
20
|
-
export {};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { useRef, useState, useEffect } from 'react';
|
|
2
2
|
import { makeBirthDate, makeFormErrors, makePhone, slashesToDashes } from '../utils';
|
|
3
|
-
import { genderOptions } from './useProfileForm';
|
|
4
3
|
const initState = {
|
|
5
4
|
first_name: '',
|
|
6
5
|
last_name: '',
|
|
7
6
|
email: '',
|
|
8
7
|
phone: ''
|
|
9
8
|
};
|
|
10
|
-
const notificationChannelFields = [
|
|
9
|
+
export const notificationChannelFields = [
|
|
11
10
|
{
|
|
12
11
|
label: 'Email',
|
|
13
12
|
name: 'EMAIL',
|
|
@@ -42,8 +41,6 @@ export const useSignUpForm = (loading, error, signUp, callback, checkConfig, hid
|
|
|
42
41
|
toRemove.push('password');
|
|
43
42
|
if (optionalFields && !optionalFields.includes('birth_date'))
|
|
44
43
|
toRemove.push('birth_date');
|
|
45
|
-
if (optionalFields && !optionalFields.includes('gender'))
|
|
46
|
-
toRemove.push('gender');
|
|
47
44
|
const allFields = [
|
|
48
45
|
{
|
|
49
46
|
label: 'First Name',
|
|
@@ -83,13 +80,6 @@ export const useSignUpForm = (loading, error, signUp, callback, checkConfig, hid
|
|
|
83
80
|
name: 'birth_date',
|
|
84
81
|
type: 'tel',
|
|
85
82
|
required: hasPunchh
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
label: 'Gender',
|
|
89
|
-
name: 'gender',
|
|
90
|
-
type: 'select',
|
|
91
|
-
showLabel: true,
|
|
92
|
-
options: genderOptions
|
|
93
83
|
}
|
|
94
84
|
];
|
|
95
85
|
const fields = allFields.filter(i => !toRemove.includes(i.name));
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
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']) => {
|
|
2
|
+
import { CheckoutFormCustomer, ConfigBrand, CustomerCreate, NotificationChannel, 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'], notificationChannels?: NotificationChannel[]) => {
|
|
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[];
|
|
7
8
|
data: CustomerCreate;
|
|
9
|
+
comms: NotificationChannel[];
|
|
8
10
|
errors: Record<string, string>;
|
|
9
11
|
disabled: boolean;
|
|
10
12
|
guestDisabled: boolean;
|
|
@@ -12,4 +14,5 @@ export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCust
|
|
|
12
14
|
handleChange: (name: string, value: string | number | boolean) => void;
|
|
13
15
|
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
14
16
|
handleGuest: () => void;
|
|
17
|
+
handleComms: (name: NotificationChannel, value: boolean) => void;
|
|
15
18
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useRef, useState, useEffect } from 'react';
|
|
2
2
|
import { checkGuestData, makeBirthDate, makeFormErrors, makePhone, slashesToDashes } from '../utils';
|
|
3
|
+
import { notificationChannelFields } from './useSignUpForm';
|
|
3
4
|
const initialData = {
|
|
4
5
|
first_name: '',
|
|
5
6
|
last_name: '',
|
|
@@ -7,11 +8,12 @@ const initialData = {
|
|
|
7
8
|
email: '',
|
|
8
9
|
password: ''
|
|
9
10
|
};
|
|
10
|
-
export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, submitGuest, tpls) => {
|
|
11
|
+
export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, submitGuest, tpls, notificationChannels = []) => {
|
|
11
12
|
const submitRef = useRef(null);
|
|
12
13
|
const inputRef = useRef(null);
|
|
13
14
|
const initData = Object.assign(Object.assign(Object.assign({}, initialData), guest), { email });
|
|
14
15
|
const [data, setData] = useState(initData);
|
|
16
|
+
const [comms, setComms] = useState([]);
|
|
15
17
|
const [errors, setErrors] = useState({});
|
|
16
18
|
const [submitting, setSubmitting] = useState(false);
|
|
17
19
|
const { guestData, guestIncomplete } = checkGuestData(data, email);
|
|
@@ -63,6 +65,7 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
|
|
|
63
65
|
}
|
|
64
66
|
];
|
|
65
67
|
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));
|
|
66
69
|
const handleChange = (name, value) => {
|
|
67
70
|
const val = name === 'phone'
|
|
68
71
|
? makePhone(value)
|
|
@@ -77,7 +80,7 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
|
|
|
77
80
|
if (!disabled) {
|
|
78
81
|
setErrors({});
|
|
79
82
|
setSubmitting(true);
|
|
80
|
-
const values = Object.assign(Object.assign({}, data), { email });
|
|
83
|
+
const values = Object.assign(Object.assign({}, data), { email, communications: comms });
|
|
81
84
|
if (values.birth_date) {
|
|
82
85
|
values.birth_date = slashesToDashes(values.birth_date);
|
|
83
86
|
}
|
|
@@ -92,6 +95,11 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
|
|
|
92
95
|
submitGuest(Object.assign(Object.assign({}, guestData), { email }));
|
|
93
96
|
}
|
|
94
97
|
};
|
|
98
|
+
const handleComms = (name, value) => {
|
|
99
|
+
const other = comms.filter(i => i !== name);
|
|
100
|
+
const updated = value ? [...other, name] : other;
|
|
101
|
+
setComms(updated);
|
|
102
|
+
};
|
|
95
103
|
useEffect(() => {
|
|
96
104
|
var _a, _b;
|
|
97
105
|
if (loading === 'idle') {
|
|
@@ -119,13 +127,16 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
|
|
|
119
127
|
submitRef,
|
|
120
128
|
inputRef,
|
|
121
129
|
fields,
|
|
130
|
+
notificationFields,
|
|
122
131
|
data,
|
|
132
|
+
comms,
|
|
123
133
|
errors,
|
|
124
134
|
disabled,
|
|
125
135
|
guestDisabled,
|
|
126
136
|
submitting,
|
|
127
137
|
handleChange,
|
|
128
138
|
handleSubmit,
|
|
129
|
-
handleGuest
|
|
139
|
+
handleGuest,
|
|
140
|
+
handleComms
|
|
130
141
|
};
|
|
131
142
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckoutTender, CheckoutTenders, CreditCard, Money, OrderTender } from '@open-tender/types';
|
|
1
|
+
import { CheckoutTender, CheckoutTenders, ConfirmationSections, CreditCard, Money, Order, 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,3 +53,4 @@ 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,3 +115,26 @@ 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
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address,
|
|
1
|
+
import { Address, OrderType, RevenueCenter, ServiceType } from '@open-tender/types';
|
|
2
2
|
export declare const makeOrderAddress: (address: Address | null) => string;
|
|
3
3
|
export declare const makeFullAddress: (address: Address) => string;
|
|
4
4
|
export declare const makeOrderTypeFromParam: (param: string) => (string | boolean)[] | null;
|
|
@@ -9,5 +9,5 @@ export declare const makeRevenueCenterMsg: (revenueCenter: RevenueCenter, servic
|
|
|
9
9
|
message: any;
|
|
10
10
|
color: string;
|
|
11
11
|
};
|
|
12
|
-
export declare const isRevenueCenterOpen: (
|
|
13
|
-
export declare const getRevenueCenterStatus: (
|
|
12
|
+
export declare const isRevenueCenterOpen: (revenueCenter: RevenueCenter, serviceType: ServiceType, statusMessages: Record<string, string>) => boolean;
|
|
13
|
+
export declare const getRevenueCenterStatus: (revenueCenter: RevenueCenter, serviceType: ServiceType, statusMessages: Record<string, string>) => string;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { serviceTypeNamesMap } from './constants';
|
|
2
2
|
import { fmtDate, formatDateStr, isoToDate, makeOrderTimes, makeReadableDateStrFromIso, makeWeekday, time24ToDate, timezoneMap } from './datetimes';
|
|
3
3
|
import { capitalize } from './helpers';
|
|
4
|
-
import {
|
|
5
|
-
import { utcToZonedTime } from 'date-fns-tz';
|
|
4
|
+
import { format, parseISO, isToday, isTomorrow } from 'date-fns';
|
|
6
5
|
export const makeOrderAddress = (address) => {
|
|
7
6
|
const { street, unit, city, state, postal_code } = address || {};
|
|
8
7
|
return street
|
|
@@ -115,41 +114,37 @@ export const makeRevenueCenterMsg = (revenueCenter, serviceType, requestedAt, st
|
|
|
115
114
|
}
|
|
116
115
|
return { message, color };
|
|
117
116
|
};
|
|
118
|
-
export const isRevenueCenterOpen = (
|
|
119
|
-
const
|
|
120
|
-
|
|
117
|
+
export const isRevenueCenterOpen = (revenueCenter, serviceType, statusMessages) => {
|
|
118
|
+
const { status, first_times, order_times } = revenueCenter;
|
|
119
|
+
const tempClosed = status === 'CLOSED_TEMPORARILY';
|
|
120
|
+
if (tempClosed)
|
|
121
121
|
return false;
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const currentWeekday = format(zonedDate, 'EEEE').toUpperCase();
|
|
125
|
-
const todayHours = serviceHours.find(hour => hour.weekday === currentWeekday);
|
|
126
|
-
if (!todayHours || !todayHours.open || !todayHours.close)
|
|
122
|
+
const statusMsg = statusMessages[revenueCenter.status];
|
|
123
|
+
if (!statusMsg)
|
|
127
124
|
return false;
|
|
128
|
-
const [
|
|
129
|
-
const [
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
minutes: closeMinutes
|
|
134
|
-
});
|
|
135
|
-
return isBefore(openingTime, zonedDate) && isAfter(closingTime, zonedDate);
|
|
125
|
+
const serviceOrderTimes = order_times ? order_times[serviceType] : null;
|
|
126
|
+
const serviceFirstTimes = first_times ? first_times[serviceType] : null;
|
|
127
|
+
const isHasFirstTimes = !!serviceFirstTimes;
|
|
128
|
+
const isHasOrderTime = !!serviceOrderTimes && serviceOrderTimes.length > 0;
|
|
129
|
+
return !isHasFirstTimes && !isHasOrderTime;
|
|
136
130
|
};
|
|
137
|
-
export const getRevenueCenterStatus = (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const tz = timezoneMap[timezone !== null && timezone !== void 0 ? timezone : 'US/Central'];
|
|
141
|
-
const isOpen = isRevenueCenterOpen(hours, tz, serviceType);
|
|
131
|
+
export const getRevenueCenterStatus = (revenueCenter, serviceType, statusMessages) => {
|
|
132
|
+
const { first_times } = revenueCenter;
|
|
133
|
+
const isOpen = isRevenueCenterOpen(revenueCenter, serviceType, statusMessages);
|
|
142
134
|
if (isOpen)
|
|
143
135
|
return 'Open Now';
|
|
144
|
-
const
|
|
136
|
+
const statusMsg = statusMessages[revenueCenter.status];
|
|
137
|
+
if (!statusMsg)
|
|
138
|
+
return 'Closed';
|
|
139
|
+
const serviceFirstTimes = first_times ? first_times[serviceType] : null;
|
|
145
140
|
if (!serviceFirstTimes)
|
|
146
141
|
return 'Closed';
|
|
147
142
|
const firstTimeDate = parseISO(serviceFirstTimes.date);
|
|
148
143
|
const canOrderToday = isToday(firstTimeDate);
|
|
149
144
|
if (canOrderToday)
|
|
150
|
-
return 'Currently
|
|
145
|
+
return 'Currently closed, order for later today';
|
|
151
146
|
const nextAvailableDate = isTomorrow(firstTimeDate)
|
|
152
147
|
? 'tomorrow'
|
|
153
148
|
: format(firstTimeDate, 'EEEE');
|
|
154
|
-
return `Closed for
|
|
149
|
+
return `Closed for today, order for ${nextAvailableDate}`;
|
|
155
150
|
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("../../utils");
|
|
4
|
-
describe('Revenue Center Status', () => {
|
|
5
|
-
const hours = {
|
|
6
|
-
WALKIN: [
|
|
7
|
-
{ weekday: 'MONDAY', open: '08:00', close: '17:00', holiday: null },
|
|
8
|
-
{ weekday: 'TUESDAY', open: '08:00', close: '17:00', holiday: null },
|
|
9
|
-
{ weekday: 'WEDNESDAY', open: '08:00', close: '17:00', holiday: null },
|
|
10
|
-
{ weekday: 'THURSDAY', open: '08:00', close: '17:00', holiday: null },
|
|
11
|
-
{ weekday: 'FRIDAY', open: '08:00', close: '17:00', holiday: null }
|
|
12
|
-
],
|
|
13
|
-
DELIVERY: null,
|
|
14
|
-
PICKUP: null,
|
|
15
|
-
description: 'Example Revenue Center'
|
|
16
|
-
};
|
|
17
|
-
const firstTimes = {
|
|
18
|
-
WALKIN: {
|
|
19
|
-
date: '2024-06-13',
|
|
20
|
-
utc: '2024-06-13T18:30:00Z',
|
|
21
|
-
has_asap: false,
|
|
22
|
-
weekday: 'THURSDAY',
|
|
23
|
-
time: '18:30 PM',
|
|
24
|
-
minutes: 30,
|
|
25
|
-
wait_minutes: null
|
|
26
|
-
},
|
|
27
|
-
DELIVERY: {
|
|
28
|
-
date: '2024-06-13',
|
|
29
|
-
utc: '2024-06-13T18:30:00Z',
|
|
30
|
-
has_asap: false,
|
|
31
|
-
weekday: 'THURSDAY',
|
|
32
|
-
time: '18:30 PM',
|
|
33
|
-
minutes: 30,
|
|
34
|
-
wait_minutes: null
|
|
35
|
-
},
|
|
36
|
-
PICKUP: {
|
|
37
|
-
date: '2024-06-13',
|
|
38
|
-
utc: '2024-06-13T18:30:00Z',
|
|
39
|
-
has_asap: false,
|
|
40
|
-
weekday: 'THURSDAY',
|
|
41
|
-
time: '18:30 PM',
|
|
42
|
-
minutes: 30,
|
|
43
|
-
wait_minutes: null
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const timezone = 'America/New_York';
|
|
47
|
-
const pythonTimezone = 'US/Central';
|
|
48
|
-
const serviceType = 'WALKIN';
|
|
49
|
-
beforeEach(() => {
|
|
50
|
-
jest
|
|
51
|
-
.spyOn(global.Date, 'now')
|
|
52
|
-
.mockImplementation(() => new Date('2024-06-13T12:00:00Z').valueOf());
|
|
53
|
-
});
|
|
54
|
-
afterEach(() => {
|
|
55
|
-
jest.restoreAllMocks();
|
|
56
|
-
});
|
|
57
|
-
test('isRevenueCenterOpen - should return true if center is open now', () => {
|
|
58
|
-
expect((0, utils_1.isRevenueCenterOpen)(hours, timezone, serviceType)).toBe(true);
|
|
59
|
-
});
|
|
60
|
-
test('isRevenueCenterOpen - should return false if center is closed now', () => {
|
|
61
|
-
jest
|
|
62
|
-
.spyOn(global.Date, 'now')
|
|
63
|
-
.mockImplementation(() => new Date('2024-06-13T18:00:00Z').valueOf());
|
|
64
|
-
expect((0, utils_1.isRevenueCenterOpen)(hours, timezone, serviceType)).toBe(false);
|
|
65
|
-
});
|
|
66
|
-
test('getRevenueCenterStatus - should return "Currently Closed, Order for later today"', () => {
|
|
67
|
-
expect((0, utils_1.getRevenueCenterStatus)(hours, firstTimes, serviceType, pythonTimezone)).toBe('Currently Closed, Order for later today');
|
|
68
|
-
});
|
|
69
|
-
test('getRevenueCenterStatus - should return "Closed for the Day, Order for tomorrow at 5:00 PM"', () => {
|
|
70
|
-
jest
|
|
71
|
-
.spyOn(global.Date, 'now')
|
|
72
|
-
.mockImplementation(() => new Date('2024-06-13T22:00:00Z').valueOf());
|
|
73
|
-
expect((0, utils_1.getRevenueCenterStatus)(hours, firstTimes, serviceType, pythonTimezone)).toBe('Closed for the Day, Order for June 14th at 5:00 PM');
|
|
74
|
-
});
|
|
75
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { getRevenueCenterStatus, isRevenueCenterOpen } from '../../utils';
|
|
2
|
-
describe('Revenue Center Status', () => {
|
|
3
|
-
const hours = {
|
|
4
|
-
WALKIN: [
|
|
5
|
-
{ weekday: 'MONDAY', open: '08:00', close: '17:00', holiday: null },
|
|
6
|
-
{ weekday: 'TUESDAY', open: '08:00', close: '17:00', holiday: null },
|
|
7
|
-
{ weekday: 'WEDNESDAY', open: '08:00', close: '17:00', holiday: null },
|
|
8
|
-
{ weekday: 'THURSDAY', open: '08:00', close: '17:00', holiday: null },
|
|
9
|
-
{ weekday: 'FRIDAY', open: '08:00', close: '17:00', holiday: null }
|
|
10
|
-
],
|
|
11
|
-
DELIVERY: null,
|
|
12
|
-
PICKUP: null,
|
|
13
|
-
description: 'Example Revenue Center'
|
|
14
|
-
};
|
|
15
|
-
const firstTimes = {
|
|
16
|
-
WALKIN: {
|
|
17
|
-
date: '2024-06-13',
|
|
18
|
-
utc: '2024-06-13T18:30:00Z',
|
|
19
|
-
has_asap: false,
|
|
20
|
-
weekday: 'THURSDAY',
|
|
21
|
-
time: '18:30 PM',
|
|
22
|
-
minutes: 30,
|
|
23
|
-
wait_minutes: null
|
|
24
|
-
},
|
|
25
|
-
DELIVERY: {
|
|
26
|
-
date: '2024-06-13',
|
|
27
|
-
utc: '2024-06-13T18:30:00Z',
|
|
28
|
-
has_asap: false,
|
|
29
|
-
weekday: 'THURSDAY',
|
|
30
|
-
time: '18:30 PM',
|
|
31
|
-
minutes: 30,
|
|
32
|
-
wait_minutes: null
|
|
33
|
-
},
|
|
34
|
-
PICKUP: {
|
|
35
|
-
date: '2024-06-13',
|
|
36
|
-
utc: '2024-06-13T18:30:00Z',
|
|
37
|
-
has_asap: false,
|
|
38
|
-
weekday: 'THURSDAY',
|
|
39
|
-
time: '18:30 PM',
|
|
40
|
-
minutes: 30,
|
|
41
|
-
wait_minutes: null
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const timezone = 'America/New_York';
|
|
45
|
-
const pythonTimezone = 'US/Central';
|
|
46
|
-
const serviceType = 'WALKIN';
|
|
47
|
-
beforeEach(() => {
|
|
48
|
-
jest
|
|
49
|
-
.spyOn(global.Date, 'now')
|
|
50
|
-
.mockImplementation(() => new Date('2024-06-13T12:00:00Z').valueOf());
|
|
51
|
-
});
|
|
52
|
-
afterEach(() => {
|
|
53
|
-
jest.restoreAllMocks();
|
|
54
|
-
});
|
|
55
|
-
test('isRevenueCenterOpen - should return true if center is open now', () => {
|
|
56
|
-
expect(isRevenueCenterOpen(hours, timezone, serviceType)).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
test('isRevenueCenterOpen - should return false if center is closed now', () => {
|
|
59
|
-
jest
|
|
60
|
-
.spyOn(global.Date, 'now')
|
|
61
|
-
.mockImplementation(() => new Date('2024-06-13T18:00:00Z').valueOf());
|
|
62
|
-
expect(isRevenueCenterOpen(hours, timezone, serviceType)).toBe(false);
|
|
63
|
-
});
|
|
64
|
-
test('getRevenueCenterStatus - should return "Currently Closed, Order for later today"', () => {
|
|
65
|
-
expect(getRevenueCenterStatus(hours, firstTimes, serviceType, pythonTimezone)).toBe('Currently Closed, Order for later today');
|
|
66
|
-
});
|
|
67
|
-
test('getRevenueCenterStatus - should return "Closed for the Day, Order for tomorrow at 5:00 PM"', () => {
|
|
68
|
-
jest
|
|
69
|
-
.spyOn(global.Date, 'now')
|
|
70
|
-
.mockImplementation(() => new Date('2024-06-13T22:00:00Z').valueOf());
|
|
71
|
-
expect(getRevenueCenterStatus(hours, firstTimes, serviceType, pythonTimezone)).toBe('Closed for the Day, Order for June 14th at 5:00 PM');
|
|
72
|
-
});
|
|
73
|
-
});
|