@infosoftas/s4-orders-js-sdk 0.1.4 → 0.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infosoftas/s4-orders-js-sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "scripts": {
5
5
  "build": "rimraf lib && webpack --mode production",
6
6
  "release": "release-it"
@@ -2,6 +2,7 @@ import { FC } from 'react';
2
2
  import { useFormContext } from 'react-hook-form';
3
3
 
4
4
  import { uuidv4 } from '../../utils/helper';
5
+ import { REQUIRED_VALIDATION_REGEXP } from '../../constants/index';
5
6
 
6
7
  type Props = {
7
8
  name: string;
@@ -37,6 +38,7 @@ const AddressField: FC<Props> = ({
37
38
  {...register(name, {
38
39
  required: required ? errorReqMsg : false,
39
40
  })}
41
+ {...(required ? { pattern: REQUIRED_VALIDATION_REGEXP } : '')}
40
42
  />
41
43
  <label className="label-control" htmlFor={id}>
42
44
  {label} {required && <span className="text-error">*</span>}
@@ -2,6 +2,7 @@ import { FC } from 'react';
2
2
  import { useFormContext } from 'react-hook-form';
3
3
 
4
4
  import { uuidv4 } from '../../utils/helper';
5
+ import { REQUIRED_VALIDATION_REGEXP } from '../../constants/index';
5
6
 
6
7
  type Props = {
7
8
  name: string;
@@ -37,6 +38,7 @@ const NameField: FC<Props> = ({
37
38
  {...register(name, {
38
39
  required: required ? errorReqMsg : false,
39
40
  })}
41
+ {...(required ? { pattern: REQUIRED_VALIDATION_REGEXP } : '')}
40
42
  />
41
43
  <label className="label-control" htmlFor={id}>
42
44
  {label} {required && <span className="text-error">*</span>}
@@ -2,6 +2,7 @@ import { FC } from 'react';
2
2
  import { useFormContext } from 'react-hook-form';
3
3
 
4
4
  import { uuidv4 } from '../../utils/helper';
5
+ import { REQUIRED_VALIDATION_REGEXP } from '../../constants/index';
5
6
 
6
7
  type Props = {
7
8
  name: string;
@@ -37,6 +38,7 @@ const NameField: FC<Props> = ({
37
38
  {...register(name, {
38
39
  required: required ? errorReqMsg : false,
39
40
  })}
41
+ {...(required ? { pattern: REQUIRED_VALIDATION_REGEXP } : '')}
40
42
  />
41
43
  <label className="label-control" htmlFor={id}>
42
44
  {label} {required && <span className="text-error">*</span>}
@@ -4,6 +4,8 @@ export const BASE_API = '/';
4
4
 
5
5
  export const WRONG_MSG = 'Something went wrong!';
6
6
 
7
+ export const REQUIRED_VALIDATION_REGEXP = '.*\\S.*';
8
+
7
9
  export const PAYMENT_METHOD_DEFAULT: PaymentMethodEnum =
8
10
  PaymentMethodEnum.Vipps;
9
11
 
@@ -99,12 +99,14 @@ const useOrderForm = ({
99
99
  // TODO: "recievesInvoice" should be deleted in the future
100
100
  const receivesInvoice = invoiceResponse?.receivesInvoice || invoiceResponse?.recievesInvoice;
101
101
 
102
- userActionCallback?.(UserActionEnum.SEARCH_ORGANIZATION_NUMBER, {
103
- organizationNumber: data.organizationNumber,
104
- cvr: data.cvr,
105
- gln: data.gln,
106
- found: !!receivesInvoice
107
- });
102
+ if (invoiceResponse) {
103
+ userActionCallback?.(UserActionEnum.SEARCH_ORGANIZATION_NUMBER, {
104
+ organizationNumber: data.organizationNumber,
105
+ cvr: data.cvr,
106
+ gln: data.gln,
107
+ found: !!receivesInvoice
108
+ });
109
+ }
108
110
 
109
111
  if (invoiceResponse && !receivesInvoice) {
110
112
  setLoading(false);