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

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.3",
3
+ "version": "0.1.4",
4
4
  "scripts": {
5
5
  "build": "rimraf lib && webpack --mode production",
6
6
  "release": "release-it"
@@ -6,7 +6,8 @@ type RequestInvoiceLookupType = {
6
6
  };
7
7
 
8
8
  type InvoiceLookupResponseType = {
9
- recievesInvoice: boolean;
9
+ receivesInvoice: boolean;
10
+ recievesInvoice: boolean; // TODO: Should be deleted in the future (misspelled), use "receivesInvoice" instead of this.
10
11
  };
11
12
 
12
13
  export const invoiceLookup = (
@@ -105,6 +105,7 @@ const EHFForm: FC<Props> = ({
105
105
  const { orderSubmit, loading, apiErrorMsg, errorsMsg } = useOrderForm({
106
106
  callback,
107
107
  submitStartCallback,
108
+ userActionCallback,
108
109
  organizationId,
109
110
  subscriberId,
110
111
  userId,
@@ -14,6 +14,7 @@ type Props = {
14
14
  message?: string;
15
15
  };
16
16
  };
17
+ toggleCallback?: (value: boolean) => void;
17
18
  };
18
19
 
19
20
  const ToggleField: FC<Props> = ({
@@ -23,6 +24,7 @@ const ToggleField: FC<Props> = ({
23
24
  label = '',
24
25
  errorReqMsg = 'This field is required!',
25
26
  errors,
27
+ toggleCallback
26
28
  }) => {
27
29
  const { register } = useFormContext();
28
30
  const id = uuidv4();
@@ -44,6 +46,7 @@ const ToggleField: FC<Props> = ({
44
46
  {...register(name, {
45
47
  required: required ? errorReqMsg : false,
46
48
  })}
49
+ onClick={(e) => toggleCallback?.(e.currentTarget.checked)}
47
50
  />
48
51
  <span className="slider round"></span>
49
52
  </label>
@@ -113,6 +113,7 @@ const EHFForm: FC<Props> = ({
113
113
  const { orderSubmit, loading, apiErrorMsg, errorsMsg } = useOrderForm({
114
114
  callback,
115
115
  submitStartCallback,
116
+ userActionCallback,
116
117
  organizationId,
117
118
  subscriberId,
118
119
  userId,
@@ -301,6 +301,7 @@ const OrderForm: FC<Props> = ({
301
301
  label={
302
302
  invoiceAddressSelection?.label ?? 'Invoice Address'
303
303
  }
304
+ toggleCallback={e => userActionCallback?.(UserActionEnum.TOGGLE_INVOICE_ADDRESS, { value: e })}
304
305
  />
305
306
  )}
306
307
  {showInvoiceFields && (
@@ -33,4 +33,6 @@ export enum UserActionEnum {
33
33
  SELECT_FORM = 'selectForm',
34
34
  SELECT_PAYMENT_METHOD = 'selectPaymentMethod',
35
35
  RETURN_TO_MAIN = 'returnToMain',
36
- }
36
+ TOGGLE_INVOICE_ADDRESS = 'toggleInvoiceAddress',
37
+ SEARCH_ORGANIZATION_NUMBER = 'searchOrganizationNumber',
38
+ }
@@ -96,7 +96,17 @@ const useOrderForm = ({
96
96
  });
97
97
  }
98
98
 
99
- if (invoiceResponse && !invoiceResponse?.recievesInvoice) {
99
+ // TODO: "recievesInvoice" should be deleted in the future
100
+ const receivesInvoice = invoiceResponse?.receivesInvoice || invoiceResponse?.recievesInvoice;
101
+
102
+ userActionCallback?.(UserActionEnum.SEARCH_ORGANIZATION_NUMBER, {
103
+ organizationNumber: data.organizationNumber,
104
+ cvr: data.cvr,
105
+ gln: data.gln,
106
+ found: !!receivesInvoice
107
+ });
108
+
109
+ if (invoiceResponse && !receivesInvoice) {
100
110
  setLoading(false);
101
111
  const value =
102
112
  data.paymentMethod === PaymentMethodEnum.OIO