@open-tender/utils 0.4.46 → 0.4.48

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.
@@ -6,6 +6,7 @@ export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCust
6
6
  fields: import("@open-tender/types").FormFieldType[];
7
7
  notificationFields: import("./useSignUpForm").NotificationCheckbox[];
8
8
  data: CustomerCreate;
9
+ comms: NotificationChannel[];
9
10
  errors: Record<string, string>;
10
11
  disabled: boolean;
11
12
  guestDisabled: boolean;
@@ -13,4 +14,5 @@ export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCust
13
14
  handleChange: (name: string, value: string | number | boolean) => void;
14
15
  handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
15
16
  handleGuest: () => void;
17
+ handleComms: (name: NotificationChannel, value: boolean) => void;
16
18
  };
@@ -16,6 +16,7 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
16
16
  const inputRef = (0, react_1.useRef)(null);
17
17
  const initData = Object.assign(Object.assign(Object.assign({}, initialData), guest), { email });
18
18
  const [data, setData] = (0, react_1.useState)(initData);
19
+ const [comms, setComms] = (0, react_1.useState)([]);
19
20
  const [errors, setErrors] = (0, react_1.useState)({});
20
21
  const [submitting, setSubmitting] = (0, react_1.useState)(false);
21
22
  const { guestData, guestIncomplete } = (0, utils_1.checkGuestData)(data, email);
@@ -97,6 +98,11 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
97
98
  submitGuest(Object.assign(Object.assign({}, guestData), { email }));
98
99
  }
99
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
+ };
100
106
  (0, react_1.useEffect)(() => {
101
107
  var _a, _b;
102
108
  if (loading === 'idle') {
@@ -126,13 +132,15 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
126
132
  fields,
127
133
  notificationFields,
128
134
  data,
135
+ comms,
129
136
  errors,
130
137
  disabled,
131
138
  guestDisabled,
132
139
  submitting,
133
140
  handleChange,
134
141
  handleSubmit,
135
- handleGuest
142
+ handleGuest,
143
+ handleComms
136
144
  };
137
145
  };
138
146
  exports.useSignUpGuestForm = useSignUpGuestForm;
@@ -6,6 +6,7 @@ export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCust
6
6
  fields: import("@open-tender/types").FormFieldType[];
7
7
  notificationFields: import("./useSignUpForm").NotificationCheckbox[];
8
8
  data: CustomerCreate;
9
+ comms: NotificationChannel[];
9
10
  errors: Record<string, string>;
10
11
  disabled: boolean;
11
12
  guestDisabled: boolean;
@@ -13,4 +14,5 @@ export declare const useSignUpGuestForm: (email: string, guest: CheckoutFormCust
13
14
  handleChange: (name: string, value: string | number | boolean) => void;
14
15
  handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
15
16
  handleGuest: () => void;
17
+ handleComms: (name: NotificationChannel, value: boolean) => void;
16
18
  };
@@ -13,6 +13,7 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
13
13
  const inputRef = useRef(null);
14
14
  const initData = Object.assign(Object.assign(Object.assign({}, initialData), guest), { email });
15
15
  const [data, setData] = useState(initData);
16
+ const [comms, setComms] = useState([]);
16
17
  const [errors, setErrors] = useState({});
17
18
  const [submitting, setSubmitting] = useState(false);
18
19
  const { guestData, guestIncomplete } = checkGuestData(data, email);
@@ -94,6 +95,11 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
94
95
  submitGuest(Object.assign(Object.assign({}, guestData), { email }));
95
96
  }
96
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
+ };
97
103
  useEffect(() => {
98
104
  var _a, _b;
99
105
  if (loading === 'idle') {
@@ -123,12 +129,14 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
123
129
  fields,
124
130
  notificationFields,
125
131
  data,
132
+ comms,
126
133
  errors,
127
134
  disabled,
128
135
  guestDisabled,
129
136
  submitting,
130
137
  handleChange,
131
138
  handleSubmit,
132
- handleGuest
139
+ handleGuest,
140
+ handleComms
133
141
  };
134
142
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.4.46",
3
+ "version": "0.4.48",
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",