@open-tender/utils 0.4.45 → 0.4.46

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,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,6 +1,6 @@
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
6
  const initState = {
@@ -9,7 +9,7 @@ const initState = {
9
9
  email: '',
10
10
  phone: ''
11
11
  };
12
- const notificationChannelFields = [
12
+ exports.notificationChannelFields = [
13
13
  {
14
14
  label: 'Email',
15
15
  name: 'EMAIL',
@@ -86,7 +86,7 @@ const useSignUpForm = (loading, error, signUp, callback, checkConfig, hidePasswo
86
86
  }
87
87
  ];
88
88
  const fields = allFields.filter(i => !toRemove.includes(i.name));
89
- 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));
90
90
  (0, react_1.useEffect)(() => {
91
91
  return () => {
92
92
  setData(initState);
@@ -1,9 +1,10 @@
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;
8
9
  errors: Record<string, string>;
9
10
  disabled: boolean;
@@ -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,7 +11,7 @@ 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 });
@@ -66,6 +67,7 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
66
67
  }
67
68
  ];
68
69
  const fields = allFields.filter(i => !toRemove.includes(i.name));
70
+ const notificationFields = useSignUpForm_1.notificationChannelFields.filter(i => notificationChannels === null || notificationChannels === void 0 ? void 0 : notificationChannels.includes(i.name));
69
71
  const handleChange = (name, value) => {
70
72
  const val = name === 'phone'
71
73
  ? (0, utils_1.makePhone)(value)
@@ -122,6 +124,7 @@ const useSignUpGuestForm = (email, guest, loading, error, guestErrors, signUp, s
122
124
  submitRef,
123
125
  inputRef,
124
126
  fields,
127
+ notificationFields,
125
128
  data,
126
129
  errors,
127
130
  disabled,
@@ -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 {};
@@ -6,7 +6,7 @@ const initState = {
6
6
  email: '',
7
7
  phone: ''
8
8
  };
9
- const notificationChannelFields = [
9
+ export const notificationChannelFields = [
10
10
  {
11
11
  label: 'Email',
12
12
  name: 'EMAIL',
@@ -1,9 +1,10 @@
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;
8
9
  errors: Record<string, string>;
9
10
  disabled: boolean;
@@ -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,7 +8,7 @@ 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 });
@@ -63,6 +64,7 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
63
64
  }
64
65
  ];
65
66
  const fields = allFields.filter(i => !toRemove.includes(i.name));
67
+ const notificationFields = notificationChannelFields.filter(i => notificationChannels === null || notificationChannels === void 0 ? void 0 : notificationChannels.includes(i.name));
66
68
  const handleChange = (name, value) => {
67
69
  const val = name === 'phone'
68
70
  ? makePhone(value)
@@ -119,6 +121,7 @@ export const useSignUpGuestForm = (email, guest, loading, error, guestErrors, si
119
121
  submitRef,
120
122
  inputRef,
121
123
  fields,
124
+ notificationFields,
122
125
  data,
123
126
  errors,
124
127
  disabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.4.45",
3
+ "version": "0.4.46",
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",