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

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.6",
3
+ "version": "0.1.8",
4
4
  "scripts": {
5
5
  "build": "rimraf lib && webpack --mode production",
6
6
  "release": "release-it"
@@ -14,28 +14,28 @@
14
14
  "prop-types": "^15.8.1",
15
15
  "react": "^18.3.1",
16
16
  "react-dom": "^18.3.1",
17
- "react-hook-form": "^7.53.0"
17
+ "react-hook-form": "^7.66.1"
18
18
  },
19
19
  "devDependencies": {
20
- "@babel/core": "^7.24.3",
21
- "@babel/preset-env": "^7.18.10",
22
- "@babel/preset-react": "^7.18.6",
23
- "@babel/preset-typescript": "^7.24.7",
24
- "@types/react": "^18.0.17",
25
- "@types/react-dom": "^18.0.6",
26
- "babel-loader": "^8.3.0",
27
- "copy-webpack-plugin": "^12.0.2",
20
+ "@babel/core": "^7.28.5",
21
+ "@babel/preset-env": "^7.28.5",
22
+ "@babel/preset-react": "^7.28.5",
23
+ "@babel/preset-typescript": "^7.28.5",
24
+ "@types/react": "^19.2.6",
25
+ "@types/react-dom": "^19.2.3",
26
+ "babel-loader": "^10.0.0",
27
+ "copy-webpack-plugin": "^13.0.1",
28
28
  "css-loader": "^7.1.2",
29
- "mini-css-extract-plugin": "^2.9.1",
30
- "release-it": "^19.0.4",
31
- "rimraf": "^6.0.1",
32
- "sass": "^1.79.2",
33
- "sass-loader": "^16.0.1",
29
+ "mini-css-extract-plugin": "^2.9.4",
30
+ "release-it": "^19.0.6",
31
+ "rimraf": "^6.1.2",
32
+ "sass": "^1.94.2",
33
+ "sass-loader": "^16.0.6",
34
34
  "style-loader": "^4.0.0",
35
- "ts-loader": "^9.5.1",
36
- "typescript": "^5.6.2",
37
- "webpack": "^5.95.0",
38
- "webpack-cli": "^5.1.4"
35
+ "ts-loader": "^9.5.4",
36
+ "typescript": "^5.9.3",
37
+ "webpack": "^5.103.0",
38
+ "webpack-cli": "^6.0.1"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
package/src/App.tsx CHANGED
@@ -29,6 +29,7 @@ import './App.scss';
29
29
  const App: FC<ConfigType> = ({
30
30
  submitStartCallback,
31
31
  userActionCallback,
32
+ setContactCallback,
32
33
  moduleTitle,
33
34
  apiKey,
34
35
  apiUrl,
@@ -343,6 +344,7 @@ const App: FC<ConfigType> = ({
343
344
  settings?.invoiceLookupNotFoundText
344
345
  }
345
346
  userActionCallback={userActionCallback}
347
+ setContactCallback={setContactCallback}
346
348
  errorValidationTitleMsg={settings?.errorValidationTitleMsg}
347
349
  errorValidationDenialOrderBlockingMsg={settings?.errorValidationDenialOrderBlockingMsg}
348
350
  errorValidationBlockingOffersMsg={settings?.errorValidationBlockingOffersMsg}
@@ -378,6 +380,7 @@ const App: FC<ConfigType> = ({
378
380
  settings?.invoiceLookupNotFoundText
379
381
  }
380
382
  userActionCallback={userActionCallback}
383
+ setContactCallback={setContactCallback}
381
384
  errorValidationTitleMsg={settings?.errorValidationTitleMsg}
382
385
  errorValidationDenialOrderBlockingMsg={settings?.errorValidationDenialOrderBlockingMsg}
383
386
  errorValidationBlockingOffersMsg={settings?.errorValidationBlockingOffersMsg}
@@ -426,6 +429,7 @@ const App: FC<ConfigType> = ({
426
429
  invoiceAddressSelection
427
430
  }
428
431
  userActionCallback={userActionCallback}
432
+ setContactCallback={setContactCallback}
429
433
  errorValidationTitleMsg={settings?.errorValidationTitleMsg}
430
434
  errorValidationDenialOrderBlockingMsg={settings?.errorValidationDenialOrderBlockingMsg}
431
435
  errorValidationBlockingOffersMsg={settings?.errorValidationBlockingOffersMsg}
@@ -8,6 +8,7 @@ import { PaymentMethodEnum, UserActionEnum } from '../../enums/general';
8
8
  import {
9
9
  OrderFormFiledType,
10
10
  PaymentMethodOptionsType,
11
+ ContactRequestType,
11
12
  } from '../../types/general';
12
13
  import { OrderFormInputsType, OrderInfoType } from '../../types/order';
13
14
  import { orderInvoiceContactFields } from '../../utils/order.helper';
@@ -19,6 +20,7 @@ type Props = {
19
20
  onBack: () => void;
20
21
  submitStartCallback?: (id: string) => void;
21
22
  userActionCallback?: (action: UserActionEnum, args: object | null | undefined) => void;
23
+ setContactCallback?: (contactInfo: ContactRequestType) => void;
22
24
  className?: string;
23
25
  backButtonText?: string;
24
26
  verifyButtonText?: string;
@@ -61,6 +63,7 @@ const EHFForm: FC<Props> = ({
61
63
  onBack,
62
64
  submitStartCallback,
63
65
  userActionCallback,
66
+ setContactCallback,
64
67
  className = '',
65
68
  backButtonText = '',
66
69
  verifyButtonText = '',
@@ -106,6 +109,7 @@ const EHFForm: FC<Props> = ({
106
109
  callback,
107
110
  submitStartCallback,
108
111
  userActionCallback,
112
+ setContactCallback,
109
113
  organizationId,
110
114
  subscriberId,
111
115
  userId,
@@ -2,7 +2,6 @@ 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';
6
5
 
7
6
  type Props = {
8
7
  name: string;
@@ -25,7 +24,10 @@ const AddressField: FC<Props> = ({
25
24
  errorReqMsg = 'This field is required!',
26
25
  errors,
27
26
  }) => {
28
- const { register } = useFormContext();
27
+ const { register, setValue, watch } = useFormContext();
28
+
29
+ const value = watch(name);
30
+
29
31
  const id = uuidv4();
30
32
  return (
31
33
  <div className="field-wrapper" data-testid={`sdk-${name}-field-id`}>
@@ -38,7 +40,12 @@ const AddressField: FC<Props> = ({
38
40
  {...register(name, {
39
41
  required: required ? errorReqMsg : false,
40
42
  })}
41
- {...(required ? { pattern: REQUIRED_VALIDATION_REGEXP } : '')}
43
+ {...(required ? {
44
+ onBlur: () => {
45
+ const newValue = value?.trim() || '';
46
+ setValue(name, newValue);
47
+ },
48
+ } : '')}
42
49
  />
43
50
  <label className="label-control" htmlFor={id}>
44
51
  {label} {required && <span className="text-error">*</span>}
@@ -10,6 +10,7 @@ import { PaymentMethodEnum, UserActionEnum } from '../../enums/general';
10
10
  import {
11
11
  OrderFormFiledType,
12
12
  PaymentMethodOptionsType,
13
+ ContactRequestType,
13
14
  } from '../../types/general';
14
15
  import useOrderForm from '../../hooks/useOrderForm';
15
16
  import { orderInvoiceContactFields } from '../../utils/order.helper';
@@ -20,6 +21,7 @@ type Props = {
20
21
  onBack: () => void;
21
22
  submitStartCallback?: (id: string) => void;
22
23
  userActionCallback?: (action: UserActionEnum, args: object | null | undefined) => void;
24
+ setContactCallback?: (contactInfo: ContactRequestType) => void;
23
25
  className?: string;
24
26
  backButtonText?: string;
25
27
  verifyButtonText?: string;
@@ -64,6 +66,7 @@ const EHFForm: FC<Props> = ({
64
66
  onBack,
65
67
  submitStartCallback,
66
68
  userActionCallback,
69
+ setContactCallback,
67
70
  className = '',
68
71
  backButtonText = '',
69
72
  verifyButtonText = '',
@@ -114,6 +117,7 @@ const EHFForm: FC<Props> = ({
114
117
  callback,
115
118
  submitStartCallback,
116
119
  userActionCallback,
120
+ setContactCallback,
117
121
  organizationId,
118
122
  subscriberId,
119
123
  userId,
@@ -15,6 +15,7 @@ import { OrderFormInputsType, OrderInfoType } from '../../types/order';
15
15
  import {
16
16
  PaymentMethodOptionsType,
17
17
  OrderFormFiledType,
18
+ ContactRequestType,
18
19
  } from '../../types/general';
19
20
  import { orderInvoiceContactFields } from '../../utils/order.helper';
20
21
  import useOrderForm from '../../hooks/useOrderForm';
@@ -26,6 +27,7 @@ type Props = {
26
27
  updateFormData: (data: OrderFormInputsType) => void;
27
28
  submitStartCallback?: (id: string) => void;
28
29
  userActionCallback?: (action: UserActionEnum, args: object | null | undefined) => void;
30
+ setContactCallback?: (contactInfo: ContactRequestType) => void;
29
31
  templatePackageId: string;
30
32
  subscriberId?: string;
31
33
  userId?: string;
@@ -74,6 +76,7 @@ const OrderForm: FC<Props> = ({
74
76
  updateFormData,
75
77
  submitStartCallback,
76
78
  userActionCallback,
79
+ setContactCallback,
77
80
  templatePackageId,
78
81
  subscriberId,
79
82
  userId,
@@ -162,6 +165,7 @@ const OrderForm: FC<Props> = ({
162
165
  callback,
163
166
  submitStartCallback,
164
167
  userActionCallback,
168
+ setContactCallback,
165
169
  organizationId,
166
170
  subscriberId,
167
171
  userId,
@@ -11,6 +11,7 @@ import {
11
11
  ErrorsMsg,
12
12
  OrderFormFiledType,
13
13
  PaymentMethodOptionsType,
14
+ ContactRequestType,
14
15
  } from '../types/general';
15
16
  import {
16
17
  prepareAgreementModel,
@@ -27,6 +28,7 @@ type Props = {
27
28
  callback: (url: string | null, orderInfo?: OrderInfoType | null) => void;
28
29
  submitStartCallback?: (id: string) => void;
29
30
  userActionCallback?: (action: UserActionEnum, args: object | null | undefined) => void;
31
+ setContactCallback?: (contactInfo: ContactRequestType) => void;
30
32
  templatePackageId: string;
31
33
  subscriberId?: string;
32
34
  userId?: string;
@@ -50,6 +52,7 @@ const useOrderForm = ({
50
52
  callback,
51
53
  submitStartCallback,
52
54
  userActionCallback,
55
+ setContactCallback,
53
56
  organizationId,
54
57
  subscriberId,
55
58
  userId,
@@ -145,6 +148,10 @@ const useOrderForm = ({
145
148
  }
146
149
  }
147
150
 
151
+ if (setContactCallback) {
152
+ setContactCallback(contactModel);
153
+ }
154
+
148
155
  submitStartCallback?.(id as string);
149
156
 
150
157
  if (id) {
@@ -23,9 +23,21 @@ export type PaymentMethodOptionsType = {
23
23
  };
24
24
  };
25
25
 
26
+ export type ContactRequestType = {
27
+ addressLines?: Array<string> | undefined;
28
+ name?: string;
29
+ email?: string;
30
+ phone?: string;
31
+ country?: string;
32
+ city?: string;
33
+ zip?: string;
34
+ careOf?: string;
35
+ };
36
+
26
37
  export type ConfigType = {
27
38
  submitStartCallback?: (subscriberId: string) => void;
28
39
  userActionCallback?: (action: UserActionEnum, args: object | null | undefined) => void;
40
+ setContactCallback?: (contactInfo: ContactRequestType) => void;
29
41
  domElementId: string;
30
42
  moduleTitle?: string;
31
43
  templatePackageId: string;