@infosoftas/s4-orders-js-sdk 0.1.10 → 0.1.11
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/.editorconfig +8 -0
- package/.release-it.json +8 -8
- package/package.json +2 -2
- package/src/App.scss +6 -7
- package/src/App.tsx +55 -22
- package/src/api/InvoiceApi.ts +1 -2
- package/src/api/OrdersApi.ts +9 -9
- package/src/api/SubscribeApi.ts +1 -2
- package/src/assets/styles/forms.scss +67 -67
- package/src/assets/styles/general.scss +3 -3
- package/src/assets/styles/variables.scss +28 -28
- package/src/components/Alert/alert.scss +9 -9
- package/src/components/Button/button.scss +28 -28
- package/src/components/EHFForm/EHFForm.tsx +9 -6
- package/src/components/FormFields/AddressField.tsx +8 -6
- package/src/components/FormFields/ToggleFiled.tsx +4 -2
- package/src/components/Loader/loader.scss +11 -11
- package/src/components/OIOForm/OIOForm.tsx +9 -6
- package/src/components/OrderForm/OrderForm.tsx +22 -13
- package/src/components/OrderForm/orderForm.scss +6 -6
- package/src/hooks/useOrderForm.tsx +29 -16
- package/src/index.tsx +3 -4
- package/src/types/general.ts +4 -1
- package/src/utils/helper.ts +22 -11
- package/src/utils/order.helper.ts +11 -1
package/.editorconfig
ADDED
package/.release-it.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"$schema": "https://unpkg.com/release-it/schema/release-it.json",
|
|
3
|
+
"git": {
|
|
4
|
+
"changelog": "",
|
|
5
|
+
"requireBranch": "release/*"
|
|
6
|
+
},
|
|
7
|
+
"github": {
|
|
8
|
+
"release": true
|
|
9
|
+
}
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infosoftas/s4-orders-js-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "rimraf lib && webpack --mode production",
|
|
6
6
|
"release": "release-it"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@types/react": "^19.2.6",
|
|
25
25
|
"@types/react-dom": "^19.2.3",
|
|
26
26
|
"babel-loader": "^10.0.0",
|
|
27
|
-
"copy-webpack-plugin": "^
|
|
27
|
+
"copy-webpack-plugin": "^14.0.0",
|
|
28
28
|
"css-loader": "^7.1.2",
|
|
29
29
|
"mini-css-extract-plugin": "^2.9.4",
|
|
30
30
|
"release-it": "^19.0.6",
|
package/src/App.scss
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
@import './assets/styles/general.scss';
|
|
3
3
|
|
|
4
4
|
.sdk-order-container {
|
|
5
|
-
|
|
6
5
|
*,
|
|
7
6
|
*::before,
|
|
8
7
|
*::after {
|
|
@@ -10,15 +9,15 @@
|
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
.sdk-iframe-wrapper {
|
|
13
|
-
display
|
|
12
|
+
display: flex;
|
|
14
13
|
flex-direction: column;
|
|
15
|
-
align-items
|
|
14
|
+
align-items: center;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
iframe {
|
|
19
|
-
max-width
|
|
20
|
-
border
|
|
21
|
-
background
|
|
18
|
+
max-width: 640px;
|
|
19
|
+
border: none;
|
|
20
|
+
background: transparent;
|
|
22
21
|
border-radius: $border-radius * 2;
|
|
23
22
|
}
|
|
24
|
-
}
|
|
23
|
+
}
|
package/src/App.tsx
CHANGED
|
@@ -62,8 +62,10 @@ const App: FC<ConfigType> = ({
|
|
|
62
62
|
errorInvalidEmailMsg: '',
|
|
63
63
|
errorInvalidPhoneMsg: '',
|
|
64
64
|
errorValidationTitleMsg: 'One or more validation errors occurred.',
|
|
65
|
-
errorValidationDenialOrderBlockingMsg:
|
|
66
|
-
|
|
65
|
+
errorValidationDenialOrderBlockingMsg:
|
|
66
|
+
'The order/subscription will not be created because the subscriber has a denial order blocking all.',
|
|
67
|
+
errorValidationBlockingOffersMsg:
|
|
68
|
+
'The order/subscription will not be created because the subscriber has a denial order blocking offers.',
|
|
67
69
|
paymentMethodNotAllowedMsg: '',
|
|
68
70
|
invoiceLookupNotFoundText:
|
|
69
71
|
'There was no recipient found for the given information',
|
|
@@ -110,13 +112,15 @@ const App: FC<ConfigType> = ({
|
|
|
110
112
|
try {
|
|
111
113
|
// There is no way to detect the difference between "cancelled" and "accepted" payment for Vipps via UI
|
|
112
114
|
// Completing an order for cancelled payment is fine. The backend handles it correctly.
|
|
113
|
-
await orderComplete(
|
|
115
|
+
await orderComplete(
|
|
116
|
+
orderId || data.orderId || '',
|
|
114
117
|
userId && identityProviderId
|
|
115
118
|
? {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
: undefined
|
|
119
|
+
userId,
|
|
120
|
+
identityProviderId,
|
|
121
|
+
}
|
|
122
|
+
: undefined
|
|
123
|
+
);
|
|
120
124
|
setIsConfirmed(true);
|
|
121
125
|
setLoading(false);
|
|
122
126
|
if (window === top) {
|
|
@@ -156,7 +160,9 @@ const App: FC<ConfigType> = ({
|
|
|
156
160
|
setLoading(false);
|
|
157
161
|
setShowOrderForm(true);
|
|
158
162
|
setFormType(FormTypeEnum.ORDER);
|
|
159
|
-
userActionCallback?.(UserActionEnum.SELECT_FORM, {
|
|
163
|
+
userActionCallback?.(UserActionEnum.SELECT_FORM, {
|
|
164
|
+
form: FormTypeEnum.ORDER,
|
|
165
|
+
});
|
|
160
166
|
}
|
|
161
167
|
};
|
|
162
168
|
|
|
@@ -250,10 +256,14 @@ const App: FC<ConfigType> = ({
|
|
|
250
256
|
});
|
|
251
257
|
} else if (data?.paymentMethod === PaymentMethodEnum.EHF) {
|
|
252
258
|
setFormType(FormTypeEnum.EHF);
|
|
253
|
-
userActionCallback?.(UserActionEnum.SELECT_FORM, {
|
|
259
|
+
userActionCallback?.(UserActionEnum.SELECT_FORM, {
|
|
260
|
+
form: FormTypeEnum.EHF,
|
|
261
|
+
});
|
|
254
262
|
} else if (data?.paymentMethod === PaymentMethodEnum.OIO) {
|
|
255
263
|
setFormType(FormTypeEnum.OIO);
|
|
256
|
-
userActionCallback?.(UserActionEnum.SELECT_FORM, {
|
|
264
|
+
userActionCallback?.(UserActionEnum.SELECT_FORM, {
|
|
265
|
+
form: FormTypeEnum.OIO,
|
|
266
|
+
});
|
|
257
267
|
} else if (url) {
|
|
258
268
|
if (
|
|
259
269
|
showIframe &&
|
|
@@ -275,13 +285,17 @@ const App: FC<ConfigType> = ({
|
|
|
275
285
|
|
|
276
286
|
const handleInvoiceBack = () => {
|
|
277
287
|
setFormType(FormTypeEnum.ORDER);
|
|
278
|
-
userActionCallback?.(UserActionEnum.SELECT_FORM, {
|
|
288
|
+
userActionCallback?.(UserActionEnum.SELECT_FORM, {
|
|
289
|
+
form: FormTypeEnum.ORDER,
|
|
290
|
+
});
|
|
279
291
|
};
|
|
280
292
|
|
|
281
293
|
const updateFormData = (data: OrderFormInputsType) => {
|
|
282
294
|
setOrderFormValues(data);
|
|
283
295
|
setFormType(data.paymentMethod as unknown as FormTypeEnum);
|
|
284
|
-
userActionCallback?.(UserActionEnum.SELECT_FORM, {
|
|
296
|
+
userActionCallback?.(UserActionEnum.SELECT_FORM, {
|
|
297
|
+
form: data.paymentMethod,
|
|
298
|
+
});
|
|
285
299
|
};
|
|
286
300
|
|
|
287
301
|
const handleInvoiceForm = async (
|
|
@@ -350,9 +364,15 @@ const App: FC<ConfigType> = ({
|
|
|
350
364
|
}
|
|
351
365
|
userActionCallback={userActionCallback}
|
|
352
366
|
setContactCallback={setContactCallback}
|
|
353
|
-
errorValidationTitleMsg={
|
|
354
|
-
|
|
355
|
-
|
|
367
|
+
errorValidationTitleMsg={
|
|
368
|
+
settings?.errorValidationTitleMsg
|
|
369
|
+
}
|
|
370
|
+
errorValidationDenialOrderBlockingMsg={
|
|
371
|
+
settings?.errorValidationDenialOrderBlockingMsg
|
|
372
|
+
}
|
|
373
|
+
errorValidationBlockingOffersMsg={
|
|
374
|
+
settings?.errorValidationBlockingOffersMsg
|
|
375
|
+
}
|
|
356
376
|
/>
|
|
357
377
|
)}
|
|
358
378
|
{formType === FormTypeEnum.EHF && (
|
|
@@ -386,13 +406,20 @@ const App: FC<ConfigType> = ({
|
|
|
386
406
|
}
|
|
387
407
|
userActionCallback={userActionCallback}
|
|
388
408
|
setContactCallback={setContactCallback}
|
|
389
|
-
errorValidationTitleMsg={
|
|
390
|
-
|
|
391
|
-
|
|
409
|
+
errorValidationTitleMsg={
|
|
410
|
+
settings?.errorValidationTitleMsg
|
|
411
|
+
}
|
|
412
|
+
errorValidationDenialOrderBlockingMsg={
|
|
413
|
+
settings?.errorValidationDenialOrderBlockingMsg
|
|
414
|
+
}
|
|
415
|
+
errorValidationBlockingOffersMsg={
|
|
416
|
+
settings?.errorValidationBlockingOffersMsg
|
|
417
|
+
}
|
|
392
418
|
/>
|
|
393
419
|
)}
|
|
394
420
|
{formType !== FormTypeEnum.OIO &&
|
|
395
|
-
formType !== FormTypeEnum.EHF &&
|
|
421
|
+
formType !== FormTypeEnum.EHF &&
|
|
422
|
+
templatePackageId && (
|
|
396
423
|
<OrderForm
|
|
397
424
|
callback={handleForm}
|
|
398
425
|
updateFormData={updateFormData}
|
|
@@ -435,9 +462,15 @@ const App: FC<ConfigType> = ({
|
|
|
435
462
|
}
|
|
436
463
|
userActionCallback={userActionCallback}
|
|
437
464
|
setContactCallback={setContactCallback}
|
|
438
|
-
errorValidationTitleMsg={
|
|
439
|
-
|
|
440
|
-
|
|
465
|
+
errorValidationTitleMsg={
|
|
466
|
+
settings?.errorValidationTitleMsg
|
|
467
|
+
}
|
|
468
|
+
errorValidationDenialOrderBlockingMsg={
|
|
469
|
+
settings?.errorValidationDenialOrderBlockingMsg
|
|
470
|
+
}
|
|
471
|
+
errorValidationBlockingOffersMsg={
|
|
472
|
+
settings?.errorValidationBlockingOffersMsg
|
|
473
|
+
}
|
|
441
474
|
/>
|
|
442
475
|
)}
|
|
443
476
|
</>
|
package/src/api/InvoiceApi.ts
CHANGED
|
@@ -17,8 +17,7 @@ export const invoiceLookup = (
|
|
|
17
17
|
method: 'POST',
|
|
18
18
|
url: '/invoicelookup',
|
|
19
19
|
headers: {
|
|
20
|
-
'S4-ORDERS-API-KEY':
|
|
21
|
-
sessionStorage.getItem('sdk_api_key') || '',
|
|
20
|
+
'S4-ORDERS-API-KEY': sessionStorage.getItem('sdk_api_key') || '',
|
|
22
21
|
},
|
|
23
22
|
body,
|
|
24
23
|
}) as Promise<InvoiceLookupResponseType>;
|
package/src/api/OrdersApi.ts
CHANGED
|
@@ -13,8 +13,8 @@ type RequestOrderStartType = {
|
|
|
13
13
|
orderReference?: string;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
type OrderCompleteRequestType = {
|
|
17
|
-
userId: string;
|
|
16
|
+
type OrderCompleteRequestType = {
|
|
17
|
+
userId: string;
|
|
18
18
|
identityProviderId: string;
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -30,19 +30,20 @@ export const orderStart = (
|
|
|
30
30
|
method: 'POST',
|
|
31
31
|
url: '/order',
|
|
32
32
|
headers: {
|
|
33
|
-
'S4-ORDERS-API-KEY':
|
|
34
|
-
sessionStorage.getItem('sdk_api_key') || '',
|
|
33
|
+
'S4-ORDERS-API-KEY': sessionStorage.getItem('sdk_api_key') || '',
|
|
35
34
|
},
|
|
36
35
|
body,
|
|
37
36
|
}) as Promise<OrderResponseType>;
|
|
38
37
|
|
|
39
|
-
export const orderComplete = (
|
|
38
|
+
export const orderComplete = (
|
|
39
|
+
id: string,
|
|
40
|
+
body?: OrderCompleteRequestType
|
|
41
|
+
): Promise<OrderResponseType> =>
|
|
40
42
|
fetcher<OrderResponseType, OrderCompleteRequestType | null>({
|
|
41
43
|
method: 'POST',
|
|
42
44
|
url: `/order/${id}/complete`,
|
|
43
45
|
headers: {
|
|
44
|
-
'S4-ORDERS-API-KEY':
|
|
45
|
-
sessionStorage.getItem('sdk_api_key') || '',
|
|
46
|
+
'S4-ORDERS-API-KEY': sessionStorage.getItem('sdk_api_key') || '',
|
|
46
47
|
},
|
|
47
48
|
body: body || null,
|
|
48
49
|
}) as Promise<OrderResponseType>;
|
|
@@ -52,8 +53,7 @@ export const orderDelete = (id: string): Promise<OrderResponseType> =>
|
|
|
52
53
|
method: 'DELETE',
|
|
53
54
|
url: `/order/${id}`,
|
|
54
55
|
headers: {
|
|
55
|
-
'S4-ORDERS-API-KEY':
|
|
56
|
-
sessionStorage.getItem('sdk_api_key') || '',
|
|
56
|
+
'S4-ORDERS-API-KEY': sessionStorage.getItem('sdk_api_key') || '',
|
|
57
57
|
},
|
|
58
58
|
body: null,
|
|
59
59
|
}) as Promise<OrderResponseType>;
|
package/src/api/SubscribeApi.ts
CHANGED
|
@@ -12,8 +12,7 @@ export const createSubscriber = (
|
|
|
12
12
|
method: 'POST',
|
|
13
13
|
url: '/subscriber',
|
|
14
14
|
headers: {
|
|
15
|
-
'S4-ORDERS-API-KEY':
|
|
16
|
-
sessionStorage.getItem('sdk_api_key') || '',
|
|
15
|
+
'S4-ORDERS-API-KEY': sessionStorage.getItem('sdk_api_key') || '',
|
|
17
16
|
},
|
|
18
17
|
body,
|
|
19
18
|
}) as Promise<CreateSubscriberResponseType>;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
@import './variables.scss';
|
|
2
2
|
|
|
3
3
|
.field-label {
|
|
4
|
-
display
|
|
4
|
+
display: block;
|
|
5
5
|
margin-bottom: 0.375em;
|
|
6
|
-
font-weight
|
|
7
|
-
text-align
|
|
6
|
+
font-weight: 500;
|
|
7
|
+
text-align: left;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.field-wrapper {
|
|
11
|
-
display
|
|
11
|
+
display: flex;
|
|
12
12
|
flex-direction: column;
|
|
13
|
-
width
|
|
14
|
-
margin-bottom
|
|
13
|
+
width: 100%;
|
|
14
|
+
margin-bottom: 20px;
|
|
15
15
|
|
|
16
16
|
label {
|
|
17
|
-
display
|
|
18
|
-
order
|
|
17
|
+
display: block;
|
|
18
|
+
order: 1;
|
|
19
19
|
margin-bottom: 0.375em;
|
|
20
|
-
font-weight
|
|
21
|
-
text-align
|
|
20
|
+
font-weight: 500;
|
|
21
|
+
text-align: left;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
.caption {
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
.input-control {
|
|
34
|
-
width
|
|
35
|
-
padding
|
|
36
|
-
border
|
|
37
|
-
border-radius
|
|
38
|
-
font-size
|
|
39
|
-
font-size
|
|
40
|
-
font-family
|
|
34
|
+
width: 100%;
|
|
35
|
+
padding: 0.25em 0.5em;
|
|
36
|
+
border: 2px solid $input-border-color;
|
|
37
|
+
border-radius: 4px;
|
|
38
|
+
font-size: 16px;
|
|
39
|
+
font-size: max(16px, 1em);
|
|
40
|
+
font-family: inherit;
|
|
41
41
|
background-color: $white;
|
|
42
42
|
|
|
43
43
|
&[disabled],
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
&:read-only,
|
|
46
46
|
.disabled,
|
|
47
47
|
.red-only {
|
|
48
|
-
border-color
|
|
48
|
+
border-color: $input-border-disabled-color;
|
|
49
49
|
background-color: $input-border-disabled-bg-color;
|
|
50
|
-
cursor
|
|
50
|
+
cursor: not-allowed;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
&:focus {
|
|
@@ -57,18 +57,18 @@
|
|
|
57
57
|
|
|
58
58
|
.radio-button-control {
|
|
59
59
|
label {
|
|
60
|
-
display
|
|
60
|
+
display: flex;
|
|
61
61
|
margin-bottom: 0.375em;
|
|
62
|
-
font-weight
|
|
63
|
-
position
|
|
64
|
-
overflow
|
|
65
|
-
cursor
|
|
62
|
+
font-weight: 500;
|
|
63
|
+
position: relative;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
cursor: pointer;
|
|
66
66
|
|
|
67
67
|
input {
|
|
68
68
|
position: absolute;
|
|
69
|
-
left
|
|
69
|
+
left: -9999px;
|
|
70
70
|
|
|
71
|
-
&:checked+span.value-block {
|
|
71
|
+
&:checked + span.value-block {
|
|
72
72
|
background-color: mix($white, $primary-color, 84%);
|
|
73
73
|
|
|
74
74
|
&:before {
|
|
@@ -78,27 +78,27 @@
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
span.value-block {
|
|
81
|
-
display
|
|
82
|
-
align-items
|
|
83
|
-
padding
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
padding: 0.375em 0.75em 0.375em 0.375em;
|
|
84
84
|
border-radius: 20px;
|
|
85
|
-
transition
|
|
85
|
+
transition: 0.25s ease;
|
|
86
86
|
|
|
87
87
|
&:hover {
|
|
88
88
|
background-color: mix($white, $primary-color, 84%);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
&:before {
|
|
92
|
-
content
|
|
93
|
-
display
|
|
94
|
-
flex-shrink
|
|
95
|
-
width
|
|
96
|
-
height
|
|
97
|
-
margin-right
|
|
98
|
-
border-radius
|
|
92
|
+
content: '';
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-shrink: 0;
|
|
95
|
+
width: 1.5em;
|
|
96
|
+
height: 1.5em;
|
|
97
|
+
margin-right: 0.375em;
|
|
98
|
+
border-radius: 50%;
|
|
99
99
|
background-color: $white;
|
|
100
|
-
box-shadow
|
|
101
|
-
transition
|
|
100
|
+
box-shadow: inset 0 0 0 0.125em $primary-color;
|
|
101
|
+
transition: 0.25s ease;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -110,47 +110,47 @@
|
|
|
110
110
|
|
|
111
111
|
.sdk-on-off {
|
|
112
112
|
position: relative;
|
|
113
|
-
display
|
|
114
|
-
width
|
|
115
|
-
height
|
|
113
|
+
display: inline-block;
|
|
114
|
+
width: 60px;
|
|
115
|
+
height: 28px;
|
|
116
116
|
|
|
117
117
|
input {
|
|
118
118
|
opacity: 0;
|
|
119
|
-
width
|
|
120
|
-
height
|
|
119
|
+
width: 0;
|
|
120
|
+
height: 0;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
input:checked
|
|
123
|
+
input:checked + .slider:before {
|
|
124
124
|
-webkit-transform: translateX(32px);
|
|
125
|
-
-ms-transform
|
|
126
|
-
transform
|
|
125
|
+
-ms-transform: translateX(32px);
|
|
126
|
+
transform: translateX(32px);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
input:checked
|
|
129
|
+
input:checked + .slider {
|
|
130
130
|
background-color: $primary-color;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
.slider {
|
|
134
|
-
position
|
|
135
|
-
cursor
|
|
136
|
-
top
|
|
137
|
-
left
|
|
138
|
-
right
|
|
139
|
-
bottom
|
|
140
|
-
background-color
|
|
141
|
-
-webkit-transition: .4s;
|
|
142
|
-
transition
|
|
134
|
+
position: absolute;
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
top: 0;
|
|
137
|
+
left: 0;
|
|
138
|
+
right: 0;
|
|
139
|
+
bottom: 0;
|
|
140
|
+
background-color: $input-border-disabled-color;
|
|
141
|
+
-webkit-transition: 0.4s;
|
|
142
|
+
transition: 0.4s;
|
|
143
143
|
|
|
144
144
|
&:before {
|
|
145
|
-
position
|
|
146
|
-
content
|
|
147
|
-
height
|
|
148
|
-
width
|
|
149
|
-
left
|
|
150
|
-
bottom
|
|
151
|
-
background-color
|
|
152
|
-
-webkit-transition: .4s;
|
|
153
|
-
transition
|
|
145
|
+
position: absolute;
|
|
146
|
+
content: '';
|
|
147
|
+
height: 24px;
|
|
148
|
+
width: 24px;
|
|
149
|
+
left: 2px;
|
|
150
|
+
bottom: 2px;
|
|
151
|
+
background-color: white;
|
|
152
|
+
-webkit-transition: 0.4s;
|
|
153
|
+
transition: 0.4s;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
&.round {
|
|
@@ -161,4 +161,4 @@
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
}
|
|
164
|
+
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
.gap-2 {
|
|
21
|
-
gap: 0.5rem
|
|
21
|
+
gap: 0.5rem;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
.mt-2 {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
.text-success {
|
|
37
|
-
color: $success-color !important
|
|
37
|
+
color: $success-color !important;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
.text-center {
|
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
|
|
44
44
|
.caption {
|
|
45
45
|
font-size: $xs-font-size;
|
|
46
|
-
}
|
|
46
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
$white
|
|
2
|
-
$black
|
|
3
|
-
$blue
|
|
4
|
-
$green
|
|
5
|
-
$red
|
|
6
|
-
$grey
|
|
7
|
-
$light-gray
|
|
8
|
-
$dark-gray
|
|
9
|
-
$error-color
|
|
10
|
-
$success-test-color
|
|
11
|
-
$text-color
|
|
12
|
-
$primary-color
|
|
13
|
-
$input-border-color
|
|
14
|
-
$input-border-disabled-color
|
|
1
|
+
$white: #fff;
|
|
2
|
+
$black: #000;
|
|
3
|
+
$blue: #007bff;
|
|
4
|
+
$green: #5fa757;
|
|
5
|
+
$red: #c9252d;
|
|
6
|
+
$grey: #6c757d;
|
|
7
|
+
$light-gray: #f8f9fa;
|
|
8
|
+
$dark-gray: #343a40;
|
|
9
|
+
$error-color: $red;
|
|
10
|
+
$success-test-color: $green;
|
|
11
|
+
$text-color: $dark-gray;
|
|
12
|
+
$primary-color: $blue;
|
|
13
|
+
$input-border-color: $grey;
|
|
14
|
+
$input-border-disabled-color: #ccc;
|
|
15
15
|
$input-border-disabled-bg-color: #eee;
|
|
16
|
-
$success-color
|
|
17
|
-
$success-bg-color
|
|
18
|
-
$success-border-color
|
|
19
|
-
$danger-color
|
|
20
|
-
$danger-bg-color
|
|
21
|
-
$danger-border-color
|
|
22
|
-
$input-focus-h
|
|
23
|
-
$input-focus-s
|
|
24
|
-
$input-focus-l
|
|
25
|
-
$font-size
|
|
26
|
-
$sm-font-size
|
|
27
|
-
$xs-font-size
|
|
28
|
-
$border-radius
|
|
29
|
-
$size-bezel
|
|
16
|
+
$success-color: #155724;
|
|
17
|
+
$success-bg-color: #d4edda;
|
|
18
|
+
$success-border-color: #c3e6cb;
|
|
19
|
+
$danger-color: #721c24;
|
|
20
|
+
$danger-bg-color: #f8d7da;
|
|
21
|
+
$danger-border-color: #f5c6cb;
|
|
22
|
+
$input-focus-h: 245;
|
|
23
|
+
$input-focus-s: 100%;
|
|
24
|
+
$input-focus-l: 42%;
|
|
25
|
+
$font-size: 1rem;
|
|
26
|
+
$sm-font-size: 0.875rem;
|
|
27
|
+
$xs-font-size: 0.75rem;
|
|
28
|
+
$border-radius: 4px;
|
|
29
|
+
$size-bezel: 0.5rem;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
@import '../../assets/styles/variables.scss';
|
|
2
2
|
|
|
3
3
|
.sdk-alert {
|
|
4
|
-
position
|
|
5
|
-
padding
|
|
4
|
+
position: relative;
|
|
5
|
+
padding: 0.75rem 1.25rem;
|
|
6
6
|
margin-bottom: 1rem;
|
|
7
|
-
border
|
|
8
|
-
border-radius: .25rem;
|
|
7
|
+
border: 1px solid transparent;
|
|
8
|
+
border-radius: 0.25rem;
|
|
9
9
|
|
|
10
10
|
&.danger {
|
|
11
|
-
color
|
|
11
|
+
color: $danger-color;
|
|
12
12
|
background-color: $danger-bg-color;
|
|
13
|
-
border-color
|
|
13
|
+
border-color: $danger-border-color;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
&.success {
|
|
17
|
-
color
|
|
17
|
+
color: $success-color;
|
|
18
18
|
background-color: $success-bg-color;
|
|
19
|
-
border-color
|
|
19
|
+
border-color: $success-border-color;
|
|
20
20
|
}
|
|
21
|
-
}
|
|
21
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
@use
|
|
1
|
+
@use 'sass:color';
|
|
2
2
|
|
|
3
3
|
@import '../../assets/styles/variables.scss';
|
|
4
4
|
|
|
5
5
|
.sdk-btn {
|
|
6
|
-
appearance
|
|
7
|
-
-webkit-appearance
|
|
8
|
-
display
|
|
9
|
-
padding
|
|
10
|
-
margin-bottom
|
|
11
|
-
border
|
|
12
|
-
border-radius
|
|
13
|
-
white-space
|
|
14
|
-
vertical-align
|
|
15
|
-
font-size
|
|
16
|
-
line-height
|
|
17
|
-
font-weight
|
|
18
|
-
text-align
|
|
19
|
-
background-image
|
|
20
|
-
background-color
|
|
21
|
-
color
|
|
22
|
-
cursor
|
|
6
|
+
appearance: button;
|
|
7
|
+
-webkit-appearance: button;
|
|
8
|
+
display: inline-block;
|
|
9
|
+
padding: 6px 12px;
|
|
10
|
+
margin-bottom: 0;
|
|
11
|
+
border: 1px solid $input-border-color;
|
|
12
|
+
border-radius: $border-radius;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
vertical-align: middle;
|
|
15
|
+
font-size: $sm-font-size;
|
|
16
|
+
line-height: 1.42857143;
|
|
17
|
+
font-weight: 400;
|
|
18
|
+
text-align: center;
|
|
19
|
+
background-image: none;
|
|
20
|
+
background-color: $white;
|
|
21
|
+
color: $text-color;
|
|
22
|
+
cursor: pointer;
|
|
23
23
|
-webkit-user-select: none;
|
|
24
|
-
-moz-user-select
|
|
25
|
-
-ms-user-select
|
|
26
|
-
user-select
|
|
27
|
-
-ms-touch-action
|
|
28
|
-
touch-action
|
|
24
|
+
-moz-user-select: none;
|
|
25
|
+
-ms-user-select: none;
|
|
26
|
+
user-select: none;
|
|
27
|
+
-ms-touch-action: manipulation;
|
|
28
|
+
touch-action: manipulation;
|
|
29
29
|
|
|
30
30
|
&.loading,
|
|
31
31
|
&.disabled,
|
|
32
32
|
&:disabled {
|
|
33
|
-
opacity
|
|
33
|
+
opacity: 0.75;
|
|
34
34
|
pointer-events: none;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
&.primary-btn {
|
|
38
|
-
color
|
|
38
|
+
color: $white;
|
|
39
39
|
background-color: $primary-color;
|
|
40
|
-
border-color
|
|
40
|
+
border-color: color.scale($primary-color, $lightness: -20%);
|
|
41
41
|
|
|
42
42
|
&:hover,
|
|
43
43
|
&:focus {
|
|
44
44
|
background-color: color.scale($primary-color, $lightness: -10%);
|
|
45
|
-
border-color
|
|
45
|
+
border-color: color.scale($primary-color, $lightness: -30%);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
}
|
|
@@ -19,7 +19,10 @@ type Props = {
|
|
|
19
19
|
callback: (url: string | null, orderInfo?: OrderInfoType | null) => void;
|
|
20
20
|
onBack: () => void;
|
|
21
21
|
submitStartCallback?: (id: string) => void;
|
|
22
|
-
userActionCallback?: (
|
|
22
|
+
userActionCallback?: (
|
|
23
|
+
action: UserActionEnum,
|
|
24
|
+
args: object | null | undefined
|
|
25
|
+
) => void;
|
|
23
26
|
setContactCallback?: (contactInfo: ContactRequestType) => void;
|
|
24
27
|
className?: string;
|
|
25
28
|
backButtonText?: string;
|
|
@@ -45,9 +48,9 @@ type Props = {
|
|
|
45
48
|
paymentMethods?: PaymentMethodEnum[];
|
|
46
49
|
};
|
|
47
50
|
invoiceLookupNotFoundText?: string;
|
|
48
|
-
errorValidationTitleMsg?: string
|
|
49
|
-
errorValidationDenialOrderBlockingMsg?: string
|
|
50
|
-
errorValidationBlockingOffersMsg?: string
|
|
51
|
+
errorValidationTitleMsg?: string;
|
|
52
|
+
errorValidationDenialOrderBlockingMsg?: string;
|
|
53
|
+
errorValidationBlockingOffersMsg?: string;
|
|
51
54
|
};
|
|
52
55
|
|
|
53
56
|
type EHFFormInputsType = {
|
|
@@ -84,7 +87,7 @@ const EHFForm: FC<Props> = ({
|
|
|
84
87
|
invoiceLookupNotFoundText,
|
|
85
88
|
errorValidationTitleMsg,
|
|
86
89
|
errorValidationDenialOrderBlockingMsg,
|
|
87
|
-
errorValidationBlockingOffersMsg
|
|
90
|
+
errorValidationBlockingOffersMsg,
|
|
88
91
|
}) => {
|
|
89
92
|
const methods = useForm<EHFFormInputsType>({
|
|
90
93
|
defaultValues: {
|
|
@@ -126,7 +129,7 @@ const EHFForm: FC<Props> = ({
|
|
|
126
129
|
invoiceLookupNotFoundText,
|
|
127
130
|
errorValidationTitleMsg,
|
|
128
131
|
errorValidationDenialOrderBlockingMsg,
|
|
129
|
-
errorValidationBlockingOffersMsg
|
|
132
|
+
errorValidationBlockingOffersMsg,
|
|
130
133
|
});
|
|
131
134
|
|
|
132
135
|
const onSubmit: SubmitHandler<EHFFormInputsType> = async (
|
|
@@ -40,12 +40,14 @@ const AddressField: FC<Props> = ({
|
|
|
40
40
|
{...register(name, {
|
|
41
41
|
required: required ? errorReqMsg : false,
|
|
42
42
|
})}
|
|
43
|
-
{...(required
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
{...(required
|
|
44
|
+
? {
|
|
45
|
+
onBlur: () => {
|
|
46
|
+
const newValue = value?.trim() || '';
|
|
47
|
+
setValue(name, newValue);
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
: '')}
|
|
49
51
|
/>
|
|
50
52
|
<label className="label-control" htmlFor={id}>
|
|
51
53
|
{label} {required && <span className="text-error">*</span>}
|
|
@@ -24,7 +24,7 @@ const ToggleField: FC<Props> = ({
|
|
|
24
24
|
label = '',
|
|
25
25
|
errorReqMsg = 'This field is required!',
|
|
26
26
|
errors,
|
|
27
|
-
toggleCallback
|
|
27
|
+
toggleCallback,
|
|
28
28
|
}) => {
|
|
29
29
|
const { register } = useFormContext();
|
|
30
30
|
const id = uuidv4();
|
|
@@ -46,7 +46,9 @@ const ToggleField: FC<Props> = ({
|
|
|
46
46
|
{...register(name, {
|
|
47
47
|
required: required ? errorReqMsg : false,
|
|
48
48
|
})}
|
|
49
|
-
onClick={(e) =>
|
|
49
|
+
onClick={(e) =>
|
|
50
|
+
toggleCallback?.(e.currentTarget.checked)
|
|
51
|
+
}
|
|
50
52
|
/>
|
|
51
53
|
<span className="slider round"></span>
|
|
52
54
|
</label>
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
@import '../../assets/styles/variables.scss';
|
|
2
2
|
|
|
3
3
|
.sdk-loader {
|
|
4
|
-
border
|
|
5
|
-
border-top
|
|
4
|
+
border: 2px solid $light-gray;
|
|
5
|
+
border-top: 2px solid transparent;
|
|
6
6
|
border-radius: 50%;
|
|
7
|
-
width
|
|
8
|
-
height
|
|
9
|
-
animation
|
|
7
|
+
width: 16px;
|
|
8
|
+
height: 16px;
|
|
9
|
+
animation: spin 2s linear infinite;
|
|
10
10
|
|
|
11
11
|
&.size-md {
|
|
12
12
|
border-width: 4px;
|
|
13
|
-
width
|
|
14
|
-
height
|
|
13
|
+
width: 32px;
|
|
14
|
+
height: 32px;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
&.size-lg {
|
|
18
18
|
border-width: 8px;
|
|
19
|
-
width
|
|
20
|
-
height
|
|
19
|
+
width: 64px;
|
|
20
|
+
height: 64px;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
&.dark-color {
|
|
24
|
-
border-color
|
|
24
|
+
border-color: $dark-gray;
|
|
25
25
|
border-top-color: transparent;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -34,4 +34,4 @@
|
|
|
34
34
|
100% {
|
|
35
35
|
transform: rotate(360deg);
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
}
|
|
@@ -20,7 +20,10 @@ type Props = {
|
|
|
20
20
|
callback: (url: string | null, orderInfo?: OrderInfoType | null) => void;
|
|
21
21
|
onBack: () => void;
|
|
22
22
|
submitStartCallback?: (id: string) => void;
|
|
23
|
-
userActionCallback?: (
|
|
23
|
+
userActionCallback?: (
|
|
24
|
+
action: UserActionEnum,
|
|
25
|
+
args: object | null | undefined
|
|
26
|
+
) => void;
|
|
24
27
|
setContactCallback?: (contactInfo: ContactRequestType) => void;
|
|
25
28
|
className?: string;
|
|
26
29
|
backButtonText?: string;
|
|
@@ -46,9 +49,9 @@ type Props = {
|
|
|
46
49
|
paymentMethods?: PaymentMethodEnum[];
|
|
47
50
|
};
|
|
48
51
|
invoiceLookupNotFoundText?: string;
|
|
49
|
-
errorValidationTitleMsg?: string
|
|
50
|
-
errorValidationDenialOrderBlockingMsg?: string
|
|
51
|
-
errorValidationBlockingOffersMsg?: string
|
|
52
|
+
errorValidationTitleMsg?: string;
|
|
53
|
+
errorValidationDenialOrderBlockingMsg?: string;
|
|
54
|
+
errorValidationBlockingOffersMsg?: string;
|
|
52
55
|
};
|
|
53
56
|
|
|
54
57
|
type OIOFormInputsType = {
|
|
@@ -88,7 +91,7 @@ const EHFForm: FC<Props> = ({
|
|
|
88
91
|
invoiceLookupNotFoundText,
|
|
89
92
|
errorValidationTitleMsg,
|
|
90
93
|
errorValidationDenialOrderBlockingMsg,
|
|
91
|
-
errorValidationBlockingOffersMsg
|
|
94
|
+
errorValidationBlockingOffersMsg,
|
|
92
95
|
}) => {
|
|
93
96
|
const methods = useForm<OIOFormInputsType>({
|
|
94
97
|
defaultValues: {
|
|
@@ -134,7 +137,7 @@ const EHFForm: FC<Props> = ({
|
|
|
134
137
|
invoiceLookupNotFoundText,
|
|
135
138
|
errorValidationTitleMsg,
|
|
136
139
|
errorValidationDenialOrderBlockingMsg,
|
|
137
|
-
errorValidationBlockingOffersMsg
|
|
140
|
+
errorValidationBlockingOffersMsg,
|
|
138
141
|
});
|
|
139
142
|
|
|
140
143
|
const onSubmit: SubmitHandler<OIOFormInputsType> = async (
|
|
@@ -26,7 +26,10 @@ type Props = {
|
|
|
26
26
|
callback: (url: string | null, orderInfo?: OrderInfoType | null) => void;
|
|
27
27
|
updateFormData: (data: OrderFormInputsType) => void;
|
|
28
28
|
submitStartCallback?: (id: string) => void;
|
|
29
|
-
userActionCallback?: (
|
|
29
|
+
userActionCallback?: (
|
|
30
|
+
action: UserActionEnum,
|
|
31
|
+
args: object | null | undefined
|
|
32
|
+
) => void;
|
|
30
33
|
setContactCallback?: (contactInfo: ContactRequestType) => void;
|
|
31
34
|
templatePackageId: string;
|
|
32
35
|
subscriberId?: string;
|
|
@@ -53,9 +56,9 @@ type Props = {
|
|
|
53
56
|
fields?: OrderFormFiledType[];
|
|
54
57
|
paymentMethods?: PaymentMethodEnum[];
|
|
55
58
|
};
|
|
56
|
-
errorValidationTitleMsg?: string
|
|
57
|
-
errorValidationDenialOrderBlockingMsg?: string
|
|
58
|
-
errorValidationBlockingOffersMsg?: string
|
|
59
|
+
errorValidationTitleMsg?: string;
|
|
60
|
+
errorValidationDenialOrderBlockingMsg?: string;
|
|
61
|
+
errorValidationBlockingOffersMsg?: string;
|
|
59
62
|
};
|
|
60
63
|
|
|
61
64
|
const initialData = {
|
|
@@ -99,15 +102,14 @@ const OrderForm: FC<Props> = ({
|
|
|
99
102
|
errorInvalidPhoneMsg = '',
|
|
100
103
|
errorValidationTitleMsg,
|
|
101
104
|
errorValidationDenialOrderBlockingMsg,
|
|
102
|
-
errorValidationBlockingOffersMsg
|
|
105
|
+
errorValidationBlockingOffersMsg,
|
|
103
106
|
}) => {
|
|
104
|
-
|
|
105
107
|
if (!templatePackageId) {
|
|
106
|
-
console.error('"templatePackageId" should be set'
|
|
108
|
+
console.error('"templatePackageId" should be set');
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
if (!organizationId) {
|
|
110
|
-
console.error('"organizationId" should be set'
|
|
112
|
+
console.error('"organizationId" should be set');
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
if (!subscriberId) {
|
|
@@ -118,11 +120,11 @@ const OrderForm: FC<Props> = ({
|
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
if (!userId) {
|
|
121
|
-
console.error('"userId" should be set'
|
|
123
|
+
console.error('"userId" should be set');
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
if (!identityProviderId) {
|
|
125
|
-
console.error('"identityProviderId" should be set'
|
|
127
|
+
console.error('"identityProviderId" should be set');
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
const [orderFields, setOrderFields] = useState<OrderFormFiledType[]>(
|
|
@@ -187,7 +189,7 @@ const OrderForm: FC<Props> = ({
|
|
|
187
189
|
invoiceOrderFields,
|
|
188
190
|
errorValidationTitleMsg,
|
|
189
191
|
errorValidationDenialOrderBlockingMsg,
|
|
190
|
-
errorValidationBlockingOffersMsg
|
|
192
|
+
errorValidationBlockingOffersMsg,
|
|
191
193
|
});
|
|
192
194
|
|
|
193
195
|
const onSubmit: SubmitHandler<OrderFormInputsType> = async (
|
|
@@ -215,7 +217,9 @@ const OrderForm: FC<Props> = ({
|
|
|
215
217
|
setValue('invoiceAddressSelection', false);
|
|
216
218
|
}
|
|
217
219
|
|
|
218
|
-
userActionCallback?.(UserActionEnum.SELECT_PAYMENT_METHOD, {
|
|
220
|
+
userActionCallback?.(UserActionEnum.SELECT_PAYMENT_METHOD, {
|
|
221
|
+
paymentMethod: e.target.value,
|
|
222
|
+
});
|
|
219
223
|
};
|
|
220
224
|
|
|
221
225
|
const allowPaymentMethod = useMemo(() => {
|
|
@@ -311,7 +315,12 @@ const OrderForm: FC<Props> = ({
|
|
|
311
315
|
label={
|
|
312
316
|
invoiceAddressSelection?.label ?? 'Invoice Address'
|
|
313
317
|
}
|
|
314
|
-
toggleCallback={e =>
|
|
318
|
+
toggleCallback={(e) =>
|
|
319
|
+
userActionCallback?.(
|
|
320
|
+
UserActionEnum.TOGGLE_INVOICE_ADDRESS,
|
|
321
|
+
{ value: e }
|
|
322
|
+
)
|
|
323
|
+
}
|
|
315
324
|
/>
|
|
316
325
|
)}
|
|
317
326
|
{showInvoiceFields && (
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
@import '../../assets/styles/variables.scss';
|
|
2
2
|
|
|
3
3
|
.sdk-order-form {
|
|
4
|
-
max-width
|
|
5
|
-
margin
|
|
6
|
-
display
|
|
4
|
+
max-width: 320px;
|
|
5
|
+
margin: auto;
|
|
6
|
+
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
|
-
align-items
|
|
9
|
-
text-align
|
|
10
|
-
}
|
|
8
|
+
align-items: center;
|
|
9
|
+
text-align: left;
|
|
10
|
+
}
|
|
@@ -4,7 +4,11 @@ import { SubmitHandler } from 'react-hook-form';
|
|
|
4
4
|
import { createSubscriber } from '../api/SubscribeApi';
|
|
5
5
|
import { orderStart } from '../api/OrdersApi';
|
|
6
6
|
import { invoiceLookup } from '../api/InvoiceApi';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
InvoiceLookupNetworkEnum,
|
|
9
|
+
PaymentMethodEnum,
|
|
10
|
+
UserActionEnum,
|
|
11
|
+
} from '../enums/general';
|
|
8
12
|
import { WRONG_MSG, PAYMENT_METHOD_DEFAULT } from '../constants/index';
|
|
9
13
|
import { OrderFormInputsType, OrderInfoType } from '../types/order';
|
|
10
14
|
import {
|
|
@@ -27,7 +31,10 @@ import {
|
|
|
27
31
|
type Props = {
|
|
28
32
|
callback: (url: string | null, orderInfo?: OrderInfoType | null) => void;
|
|
29
33
|
submitStartCallback?: (id: string) => void;
|
|
30
|
-
userActionCallback?: (
|
|
34
|
+
userActionCallback?: (
|
|
35
|
+
action: UserActionEnum,
|
|
36
|
+
args: object | null | undefined
|
|
37
|
+
) => void;
|
|
31
38
|
setContactCallback?: (contactInfo: ContactRequestType) => void;
|
|
32
39
|
templatePackageId: string;
|
|
33
40
|
subscriberId?: string;
|
|
@@ -43,9 +50,9 @@ type Props = {
|
|
|
43
50
|
invoiceAddressToggle?: boolean;
|
|
44
51
|
invoiceOrderFields: OrderFormFiledType[];
|
|
45
52
|
invoiceLookupNotFoundText?: string;
|
|
46
|
-
errorValidationTitleMsg?: string
|
|
47
|
-
errorValidationDenialOrderBlockingMsg?: string
|
|
48
|
-
errorValidationBlockingOffersMsg?: string
|
|
53
|
+
errorValidationTitleMsg?: string;
|
|
54
|
+
errorValidationDenialOrderBlockingMsg?: string;
|
|
55
|
+
errorValidationBlockingOffersMsg?: string;
|
|
49
56
|
};
|
|
50
57
|
|
|
51
58
|
const useOrderForm = ({
|
|
@@ -69,7 +76,7 @@ const useOrderForm = ({
|
|
|
69
76
|
invoiceLookupNotFoundText,
|
|
70
77
|
errorValidationTitleMsg,
|
|
71
78
|
errorValidationDenialOrderBlockingMsg,
|
|
72
|
-
errorValidationBlockingOffersMsg
|
|
79
|
+
errorValidationBlockingOffersMsg,
|
|
73
80
|
}: Props) => {
|
|
74
81
|
const [loading, setLoading] = useState<boolean>(false);
|
|
75
82
|
const [apiErrorMsg, setApiErrorMsg] = useState<string>('');
|
|
@@ -100,15 +107,20 @@ const useOrderForm = ({
|
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
// TODO: "recievesInvoice" should be deleted in the future
|
|
103
|
-
const receivesInvoice =
|
|
110
|
+
const receivesInvoice =
|
|
111
|
+
invoiceResponse?.receivesInvoice ||
|
|
112
|
+
invoiceResponse?.recievesInvoice;
|
|
104
113
|
|
|
105
114
|
if (invoiceResponse) {
|
|
106
|
-
userActionCallback?.(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
userActionCallback?.(
|
|
116
|
+
UserActionEnum.SEARCH_ORGANIZATION_NUMBER,
|
|
117
|
+
{
|
|
118
|
+
organizationNumber: data.organizationNumber,
|
|
119
|
+
cvr: data.cvr,
|
|
120
|
+
gln: data.gln,
|
|
121
|
+
found: !!receivesInvoice,
|
|
122
|
+
}
|
|
123
|
+
);
|
|
112
124
|
}
|
|
113
125
|
|
|
114
126
|
if (invoiceResponse && !receivesInvoice) {
|
|
@@ -196,15 +208,16 @@ const useOrderForm = ({
|
|
|
196
208
|
setApiErrorMsg(WRONG_MSG);
|
|
197
209
|
setErrorsMsg([]);
|
|
198
210
|
} catch (error) {
|
|
199
|
-
|
|
200
211
|
const translations = {
|
|
201
212
|
errorValidationTitleMsg,
|
|
202
213
|
errorValidationBlockingOffersMsg,
|
|
203
|
-
errorValidationDenialOrderBlockingMsg
|
|
214
|
+
errorValidationDenialOrderBlockingMsg,
|
|
204
215
|
} as ErrorMessages;
|
|
205
216
|
|
|
206
217
|
console.error(error);
|
|
207
|
-
setApiErrorMsg(
|
|
218
|
+
setApiErrorMsg(
|
|
219
|
+
prepareErrorMessage(error as Error, undefined, translations)
|
|
220
|
+
);
|
|
208
221
|
setErrorsMsg(
|
|
209
222
|
prepareErrorsArrayMessage(
|
|
210
223
|
(
|
package/src/index.tsx
CHANGED
|
@@ -8,13 +8,12 @@ import App from './App';
|
|
|
8
8
|
export const orderComponent = {
|
|
9
9
|
root: null as Root | null,
|
|
10
10
|
init: function (config: ConfigType) {
|
|
11
|
-
|
|
12
11
|
if (!config.apiKey) {
|
|
13
|
-
console.error('"apiKey" should be set'
|
|
12
|
+
console.error('"apiKey" should be set');
|
|
14
13
|
}
|
|
15
|
-
|
|
14
|
+
|
|
16
15
|
if (!config.apiUrl) {
|
|
17
|
-
console.error('"apiUrl" should be set'
|
|
16
|
+
console.error('"apiUrl" should be set');
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
const domNode = document.getElementById(config.domElementId);
|
package/src/types/general.ts
CHANGED
|
@@ -36,7 +36,10 @@ export type ContactRequestType = {
|
|
|
36
36
|
|
|
37
37
|
export type ConfigType = {
|
|
38
38
|
submitStartCallback?: (subscriberId: string) => void;
|
|
39
|
-
userActionCallback?: (
|
|
39
|
+
userActionCallback?: (
|
|
40
|
+
action: UserActionEnum,
|
|
41
|
+
args: object | null | undefined
|
|
42
|
+
) => void;
|
|
40
43
|
setContactCallback?: (contactInfo: ContactRequestType) => void;
|
|
41
44
|
domElementId: string;
|
|
42
45
|
moduleTitle?: string;
|
package/src/utils/helper.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { WRONG_MSG } from '../constants/index';
|
|
2
2
|
import { ErrorsMsg } from '../types/general';
|
|
3
3
|
|
|
4
|
-
export const prepareErrorMessage = (
|
|
4
|
+
export const prepareErrorMessage = (
|
|
5
|
+
error: Error,
|
|
6
|
+
defaultMsg?: string,
|
|
7
|
+
translations?: ErrorMessages
|
|
8
|
+
) => {
|
|
5
9
|
if (typeof error === 'string') {
|
|
6
10
|
try {
|
|
7
11
|
const parsedError = JSON.parse(error);
|
|
@@ -10,12 +14,20 @@ export const prepareErrorMessage = (error: Error, defaultMsg?: string, translati
|
|
|
10
14
|
return translateError(error, translations);
|
|
11
15
|
}
|
|
12
16
|
} else {
|
|
13
|
-
const serverErrorMsg = (error as { message: string })
|
|
14
|
-
|
|
17
|
+
const serverErrorMsg = (error as { message: string })
|
|
18
|
+
?.message as string;
|
|
19
|
+
return (
|
|
20
|
+
translateError(serverErrorMsg, translations) ||
|
|
21
|
+
defaultMsg ||
|
|
22
|
+
WRONG_MSG
|
|
23
|
+
);
|
|
15
24
|
}
|
|
16
25
|
};
|
|
17
26
|
|
|
18
|
-
export const prepareErrorsArrayMessage = (
|
|
27
|
+
export const prepareErrorsArrayMessage = (
|
|
28
|
+
errors: ErrorsMsg | null,
|
|
29
|
+
translations?: ErrorMessages
|
|
30
|
+
) => {
|
|
19
31
|
const msg: string[] = [];
|
|
20
32
|
|
|
21
33
|
if (errors) {
|
|
@@ -43,9 +55,9 @@ export function uuidv4() {
|
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
export type ErrorMessages = {
|
|
46
|
-
errorValidationTitleMsg: string
|
|
47
|
-
errorValidationBlockingOffersMsg: string
|
|
48
|
-
errorValidationDenialOrderBlockingMsg: string
|
|
58
|
+
errorValidationTitleMsg: string;
|
|
59
|
+
errorValidationBlockingOffersMsg: string;
|
|
60
|
+
errorValidationDenialOrderBlockingMsg: string;
|
|
49
61
|
};
|
|
50
62
|
|
|
51
63
|
const translateError = (errorMsg: string, translations?: ErrorMessages) => {
|
|
@@ -53,8 +65,7 @@ const translateError = (errorMsg: string, translations?: ErrorMessages) => {
|
|
|
53
65
|
return errorMsg;
|
|
54
66
|
}
|
|
55
67
|
|
|
56
|
-
switch(errorMsg)
|
|
57
|
-
{
|
|
68
|
+
switch (errorMsg) {
|
|
58
69
|
case 'One or more validation errors occurred.':
|
|
59
70
|
return translations?.errorValidationTitleMsg;
|
|
60
71
|
case 'The order/subscription will not be created because the subscriber has a denial order blocking offers.':
|
|
@@ -62,6 +73,6 @@ const translateError = (errorMsg: string, translations?: ErrorMessages) => {
|
|
|
62
73
|
case 'The order/subscription will not be created because the subscriber has a denial order blocking all.':
|
|
63
74
|
return translations?.errorValidationDenialOrderBlockingMsg;
|
|
64
75
|
default:
|
|
65
|
-
|
|
76
|
+
return errorMsg;
|
|
66
77
|
}
|
|
67
|
-
}
|
|
78
|
+
};
|
|
@@ -15,7 +15,17 @@ type AgreementModelType = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const mapToSwedbankLanguage = (language: string) => {
|
|
18
|
-
const allowedLanguages = [
|
|
18
|
+
const allowedLanguages = [
|
|
19
|
+
'en-US',
|
|
20
|
+
'sv-SE',
|
|
21
|
+
'nb-NO',
|
|
22
|
+
'da-DK',
|
|
23
|
+
'fi-FI',
|
|
24
|
+
'en-GB',
|
|
25
|
+
'nn-NO',
|
|
26
|
+
'no-NO',
|
|
27
|
+
'se-NO',
|
|
28
|
+
];
|
|
19
29
|
if (allowedLanguages.includes(language)) {
|
|
20
30
|
return language;
|
|
21
31
|
}
|