@open-tender/utils 0.4.51 → 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.
@@ -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
- export interface NotificationCheckbox {
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 = exports.notificationChannelFields = void 0;
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
- exports.notificationChannelFields = [
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 = exports.notificationChannelFields.filter(i => notificationChannels === null || notificationChannels === void 0 ? void 0 : notificationChannels.includes(i.name));
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, 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[]) => {
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, notificationChannels = []) => {
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, communications: comms });
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;
@@ -11,6 +11,7 @@ exports.profileFields = [
11
11
  'phone',
12
12
  'company',
13
13
  'birth_date',
14
+ 'gender',
14
15
  'is_verified',
15
16
  'is_notification_set'
16
17
  ];
@@ -1,4 +1,4 @@
1
- import { ConfirmationSections, Order, OrderChannel, OrderCounts, PosCart, PrepStatus, Store, TenderType, Ticket } from '@open-tender/types';
1
+ import { OrderChannel, OrderCounts, PosCart, PrepStatus, Store, TenderType, Ticket } from '@open-tender/types';
2
2
  export declare const makeChannelName: (channel: OrderChannel) => string | null | undefined;
3
3
  export declare const makeTenderTypeName: (tenderType: TenderType) => string;
4
4
  export declare const notDone: (prep_status: PrepStatus) => boolean;
@@ -19,4 +19,3 @@ export declare const makeTicketGroups: (tickets: Array<Ticket>, cart: PosCart, i
19
19
  export declare const makeDisplayCounts: (counts: OrderCounts) => any[] | "";
20
20
  export declare const displayCounts: (counts: OrderCounts) => string;
21
21
  export declare const makeColor: (settings: Store, minutes: number) => string;
22
- 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.makeConfirmationOrderType = exports.makeColor = exports.displayCounts = exports.makeDisplayCounts = exports.makeTicketGroups = exports.makeItemTypesMap = exports.makeItemTypeSettings = exports.makeCartLookup = exports.makeTicketCounts = exports.isCompleted = exports.notCompleted = exports.isDone = exports.notDone = exports.makeTenderTypeName = exports.makeChannelName = void 0;
3
+ exports.makeColor = exports.displayCounts = exports.makeDisplayCounts = exports.makeTicketGroups = exports.makeItemTypesMap = exports.makeItemTypeSettings = exports.makeCartLookup = exports.makeTicketCounts = exports.isCompleted = exports.notCompleted = exports.isDone = exports.notDone = exports.makeTenderTypeName = exports.makeChannelName = void 0;
4
4
  const constants_1 = require("./constants");
5
5
  const helpers_1 = require("./helpers");
6
6
  const makeChannelName = (channel) => {
@@ -200,27 +200,3 @@ const makeColor = (settings, minutes) => {
200
200
  : 'text';
201
201
  };
202
202
  exports.makeColor = makeColor;
203
- const makeConfirmationOrderType = (order) => {
204
- if (!order)
205
- return null;
206
- const { order_type, service_type, order_fulfillment, revenue_center, details } = order;
207
- const { notes_internal } = details || {};
208
- const isWalkIn = service_type === 'WALKIN';
209
- if (isWalkIn) {
210
- if (notes_internal && notes_internal.includes('TAKE OUT')) {
211
- return 'takeOut';
212
- }
213
- return 'dineIn';
214
- }
215
- if (order_type === 'CATERING')
216
- return 'catering';
217
- if (revenue_center.is_outpost)
218
- return 'outpost';
219
- if (service_type === 'DELIVERY')
220
- return 'delivery';
221
- if (service_type === 'PICKUP' && order_fulfillment) {
222
- return 'curbside';
223
- }
224
- return 'pickup';
225
- };
226
- 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 closed, order for later today';
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 today, order for ${nextAvailableDate}`;
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
- export interface NotificationCheckbox {
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
- export const notificationChannelFields = [
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, 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[]) => {
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, notificationChannels = []) => {
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, communications: comms });
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
  };
@@ -8,6 +8,7 @@ export const profileFields = [
8
8
  'phone',
9
9
  'company',
10
10
  'birth_date',
11
+ 'gender',
11
12
  'is_verified',
12
13
  'is_notification_set'
13
14
  ];
@@ -1,4 +1,4 @@
1
- import { ConfirmationSections, Order, OrderChannel, OrderCounts, PosCart, PrepStatus, Store, TenderType, Ticket } from '@open-tender/types';
1
+ import { OrderChannel, OrderCounts, PosCart, PrepStatus, Store, TenderType, Ticket } from '@open-tender/types';
2
2
  export declare const makeChannelName: (channel: OrderChannel) => string | null | undefined;
3
3
  export declare const makeTenderTypeName: (tenderType: TenderType) => string;
4
4
  export declare const notDone: (prep_status: PrepStatus) => boolean;
@@ -19,4 +19,3 @@ export declare const makeTicketGroups: (tickets: Array<Ticket>, cart: PosCart, i
19
19
  export declare const makeDisplayCounts: (counts: OrderCounts) => any[] | "";
20
20
  export declare const displayCounts: (counts: OrderCounts) => string;
21
21
  export declare const makeColor: (settings: Store, minutes: number) => string;
22
- export declare const makeConfirmationOrderType: (order: Order) => keyof ConfirmationSections | null;
@@ -183,26 +183,3 @@ export const makeColor = (settings, minutes) => {
183
183
  ? 'alert'
184
184
  : 'text';
185
185
  };
186
- export const makeConfirmationOrderType = (order) => {
187
- if (!order)
188
- return null;
189
- const { order_type, service_type, order_fulfillment, revenue_center, details } = order;
190
- const { notes_internal } = details || {};
191
- const isWalkIn = service_type === 'WALKIN';
192
- if (isWalkIn) {
193
- if (notes_internal && notes_internal.includes('TAKE OUT')) {
194
- return 'takeOut';
195
- }
196
- return 'dineIn';
197
- }
198
- if (order_type === 'CATERING')
199
- return 'catering';
200
- if (revenue_center.is_outpost)
201
- return 'outpost';
202
- if (service_type === 'DELIVERY')
203
- return 'delivery';
204
- if (service_type === 'PICKUP' && order_fulfillment) {
205
- return 'curbside';
206
- }
207
- return 'pickup';
208
- };
@@ -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 closed, order for later today';
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 today, order for ${nextAvailableDate}`;
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.51",
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",