@open-tender/utils 0.1.11 → 0.1.13

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
- import { Address, RequestStatus } from '@open-tender/types';
2
+ import { Address, FieldType, RequestStatus } from '@open-tender/types';
3
3
  interface AddressFormField {
4
4
  label: string;
5
5
  name: string;
6
6
  type: string;
7
7
  required?: boolean;
8
+ fieldType: FieldType;
8
9
  }
9
10
  export declare const useAddressForm: (address: Address, loading: RequestStatus, error: any, update: (addressId: number, updatedData: Address, callback: () => void) => void, callback: () => void) => {
10
11
  fields: AddressFormField[];
@@ -10,12 +10,27 @@ const useAddressForm = (address, loading, error, update, callback) => {
10
10
  const [errors, setErrors] = (0, react_1.useState)({});
11
11
  const [submitting, setSubmitting] = (0, react_1.useState)(false);
12
12
  const fields = [
13
- { label: 'Company', name: 'company', type: 'default' },
14
- { label: 'Contact Person', name: 'contact', type: 'default' },
15
- { label: 'Contact Phone', name: 'phone', type: 'phone-pad' },
16
- { label: 'Description', name: 'description', type: 'default' },
17
- { label: 'Notes', name: 'notes', type: 'default' },
18
- { label: 'Is Default', name: 'is_default', type: 'checkbox' }
13
+ { label: 'Company', name: 'company', type: 'text', fieldType: 'Input' },
14
+ {
15
+ label: 'Contact Person',
16
+ name: 'contact',
17
+ type: 'text',
18
+ fieldType: 'Input'
19
+ },
20
+ { label: 'Contact Phone', name: 'phone', type: 'tel', fieldType: 'Input' },
21
+ {
22
+ label: 'Description',
23
+ name: 'description',
24
+ type: 'text',
25
+ fieldType: 'Input'
26
+ },
27
+ { label: 'Notes', name: 'notes', type: 'text', fieldType: 'Input' },
28
+ {
29
+ label: 'Is Default',
30
+ name: 'is_default',
31
+ type: 'checkbox',
32
+ fieldType: 'Checkbox'
33
+ }
19
34
  ];
20
35
  (0, react_1.useEffect)(() => {
21
36
  var _a, _b;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { CreditCardData } from '@open-tender/types';
3
- export declare const useCreditCard: (initState: CreditCardData, cardErrors?: {}, disabled?: boolean) => {
3
+ export declare const useCreditCard: (initState: CreditCardData | null, cardErrors?: {}, disabled?: boolean) => {
4
4
  submitRef: import("react").MutableRefObject<null>;
5
5
  data: CreditCardData;
6
6
  cardType: "VISA" | "MC" | "DISC" | "AMEX" | "OTHER";
@@ -9,8 +9,8 @@ export interface ProfileFormField {
9
9
  }
10
10
  export declare const useProfileForm: (profile: Partial<Profile>, loading: RequestStatus, error: any, update: (data: Partial<Profile>) => void, optIns?: Partial<ConfigBrand>) => {
11
11
  submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
12
- accepts_marketing: import("@open-tender/types").ConfigAcceptMarketing | undefined;
13
- order_notifications: import("@open-tender/types").ConfigOrderNotifications | undefined;
12
+ accepts_marketing: import("@open-tender/types").ConfigAcceptMarketing | null | undefined;
13
+ order_notifications: import("@open-tender/types").ConfigOrderNotifications | null | undefined;
14
14
  data: Partial<Profile>;
15
15
  errors: any;
16
16
  submitting: boolean;
@@ -16,5 +16,5 @@ export declare const getCardType: (cardNumber: string) => CardType;
16
16
  export declare const makeNumeric: (str: string) => string;
17
17
  export declare const makeAcctNumber: (str: string, cardType: CardType) => string;
18
18
  export declare const formatCardField: (field: keyof CreditCardData, value: string) => string;
19
- export declare const formatCard: (card: CreditCardData) => [CreditCardData | null, CardType | null];
19
+ export declare const formatCard: (card: CreditCardData | null) => [CreditCardData | null, CardType | null];
20
20
  export declare const validateCreditCard: (card: CreditCardData, cardType: CardType) => CreditCardValidate;
@@ -1,10 +1,11 @@
1
1
  /// <reference types="react" />
2
- import { Address, RequestStatus } from '@open-tender/types';
2
+ import { Address, FieldType, RequestStatus } from '@open-tender/types';
3
3
  interface AddressFormField {
4
4
  label: string;
5
5
  name: string;
6
6
  type: string;
7
7
  required?: boolean;
8
+ fieldType: FieldType;
8
9
  }
9
10
  export declare const useAddressForm: (address: Address, loading: RequestStatus, error: any, update: (addressId: number, updatedData: Address, callback: () => void) => void, callback: () => void) => {
10
11
  fields: AddressFormField[];
@@ -7,12 +7,27 @@ export const useAddressForm = (address, loading, error, update, callback) => {
7
7
  const [errors, setErrors] = useState({});
8
8
  const [submitting, setSubmitting] = useState(false);
9
9
  const fields = [
10
- { label: 'Company', name: 'company', type: 'default' },
11
- { label: 'Contact Person', name: 'contact', type: 'default' },
12
- { label: 'Contact Phone', name: 'phone', type: 'phone-pad' },
13
- { label: 'Description', name: 'description', type: 'default' },
14
- { label: 'Notes', name: 'notes', type: 'default' },
15
- { label: 'Is Default', name: 'is_default', type: 'checkbox' }
10
+ { label: 'Company', name: 'company', type: 'text', fieldType: 'Input' },
11
+ {
12
+ label: 'Contact Person',
13
+ name: 'contact',
14
+ type: 'text',
15
+ fieldType: 'Input'
16
+ },
17
+ { label: 'Contact Phone', name: 'phone', type: 'tel', fieldType: 'Input' },
18
+ {
19
+ label: 'Description',
20
+ name: 'description',
21
+ type: 'text',
22
+ fieldType: 'Input'
23
+ },
24
+ { label: 'Notes', name: 'notes', type: 'text', fieldType: 'Input' },
25
+ {
26
+ label: 'Is Default',
27
+ name: 'is_default',
28
+ type: 'checkbox',
29
+ fieldType: 'Checkbox'
30
+ }
16
31
  ];
17
32
  useEffect(() => {
18
33
  var _a, _b;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { CreditCardData } from '@open-tender/types';
3
- export declare const useCreditCard: (initState: CreditCardData, cardErrors?: {}, disabled?: boolean) => {
3
+ export declare const useCreditCard: (initState: CreditCardData | null, cardErrors?: {}, disabled?: boolean) => {
4
4
  submitRef: import("react").MutableRefObject<null>;
5
5
  data: CreditCardData;
6
6
  cardType: "VISA" | "MC" | "DISC" | "AMEX" | "OTHER";
@@ -9,8 +9,8 @@ export interface ProfileFormField {
9
9
  }
10
10
  export declare const useProfileForm: (profile: Partial<Profile>, loading: RequestStatus, error: any, update: (data: Partial<Profile>) => void, optIns?: Partial<ConfigBrand>) => {
11
11
  submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
12
- accepts_marketing: import("@open-tender/types").ConfigAcceptMarketing | undefined;
13
- order_notifications: import("@open-tender/types").ConfigOrderNotifications | undefined;
12
+ accepts_marketing: import("@open-tender/types").ConfigAcceptMarketing | null | undefined;
13
+ order_notifications: import("@open-tender/types").ConfigOrderNotifications | null | undefined;
14
14
  data: Partial<Profile>;
15
15
  errors: any;
16
16
  submitting: boolean;
@@ -16,5 +16,5 @@ export declare const getCardType: (cardNumber: string) => CardType;
16
16
  export declare const makeNumeric: (str: string) => string;
17
17
  export declare const makeAcctNumber: (str: string, cardType: CardType) => string;
18
18
  export declare const formatCardField: (field: keyof CreditCardData, value: string) => string;
19
- export declare const formatCard: (card: CreditCardData) => [CreditCardData | null, CardType | null];
19
+ export declare const formatCard: (card: CreditCardData | null) => [CreditCardData | null, CardType | null];
20
20
  export declare const validateCreditCard: (card: CreditCardData, cardType: CardType) => CreditCardValidate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
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",