@infosoftas/s4-orders-js-sdk 0.0.1-alpha2c.1 → 0.0.1-alpha2c.3
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/.release-it.json +8 -5
- package/package.json +44 -44
- package/src/App.tsx +20 -3
- package/src/components/OrderForm/OrderForm.tsx +5 -0
- package/src/types/general.ts +1 -0
- package/src/utils/order.helper.ts +7 -0
package/.release-it.json
CHANGED
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@infosoftas/s4-orders-js-sdk",
|
|
3
|
+
"version": "0.0.1-alpha2c.3",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "rimraf lib && webpack --env mode=production",
|
|
6
|
+
"release": "release-it"
|
|
7
|
+
},
|
|
8
|
+
"eslintConfig": {
|
|
9
|
+
"extends": [
|
|
10
|
+
"react-app"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"prop-types": "^15.8.1",
|
|
15
|
+
"react": "^18.3.1",
|
|
16
|
+
"react-dom": "^18.3.1",
|
|
17
|
+
"react-hook-form": "^7.53.0"
|
|
18
|
+
},
|
|
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",
|
|
28
|
+
"css-loader": "^7.1.2",
|
|
29
|
+
"dotenv-webpack": "^8.1.0",
|
|
30
|
+
"mini-css-extract-plugin": "^2.9.1",
|
|
31
|
+
"release-it": "^17.10.0",
|
|
32
|
+
"rimraf": "^6.0.1",
|
|
33
|
+
"sass": "^1.79.2",
|
|
34
|
+
"sass-loader": "^16.0.1",
|
|
35
|
+
"style-loader": "^4.0.0",
|
|
36
|
+
"ts-loader": "^9.5.1",
|
|
37
|
+
"typescript": "^5.6.2",
|
|
38
|
+
"webpack": "^5.95.0",
|
|
39
|
+
"webpack-cli": "^5.1.4"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/App.tsx
CHANGED
|
@@ -13,7 +13,11 @@ import Loader from './components/Loader/Loader';
|
|
|
13
13
|
import MainIframe from './components/MainIframe/MainIframe';
|
|
14
14
|
import Alert from './components/Alert/Alert';
|
|
15
15
|
import { ConfigType, ErrorsMsg } from './types/general';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
CompleteOrderParamsType,
|
|
18
|
+
OrderInfoType,
|
|
19
|
+
OrderFormInputsType,
|
|
20
|
+
} from './types/order';
|
|
17
21
|
import { orderComplete, orderDelete } from './api/OrdersApi';
|
|
18
22
|
import { prepareErrorMessage, prepareErrorsArrayMessage } from './utils/helper';
|
|
19
23
|
|
|
@@ -22,6 +26,7 @@ import ErrorBoundary from './ErrorBoundary';
|
|
|
22
26
|
import './App.scss';
|
|
23
27
|
|
|
24
28
|
const App: FC<ConfigType> = ({
|
|
29
|
+
submitStartCallback,
|
|
25
30
|
moduleTitle,
|
|
26
31
|
apiKey,
|
|
27
32
|
apiUrl,
|
|
@@ -45,7 +50,9 @@ const App: FC<ConfigType> = ({
|
|
|
45
50
|
backButtonText: 'Back',
|
|
46
51
|
verifyButtonText: 'Verify',
|
|
47
52
|
organizationNumberLabel: 'CVR',
|
|
53
|
+
paymentMethodLabel: '',
|
|
48
54
|
glnLabel: 'GLN',
|
|
55
|
+
orderDefaultValues: undefined,
|
|
49
56
|
},
|
|
50
57
|
}) => {
|
|
51
58
|
const [loading, setLoading] = useState<boolean>(false);
|
|
@@ -58,6 +65,9 @@ const App: FC<ConfigType> = ({
|
|
|
58
65
|
const [errorsMsg, setErrorsMsg] = useState<string[]>([]);
|
|
59
66
|
const [orderInfo, setOrderInfo] = useState<OrderInfoType | null>(null);
|
|
60
67
|
const [formType, setFormType] = useState(FormTypeEnum.ORDER);
|
|
68
|
+
const [orderFormValues, setOrderFormValues] = useState(
|
|
69
|
+
settings?.orderDefaultValues
|
|
70
|
+
);
|
|
61
71
|
|
|
62
72
|
useEffect(() => {
|
|
63
73
|
if (apiKey) {
|
|
@@ -190,6 +200,9 @@ const App: FC<ConfigType> = ({
|
|
|
190
200
|
setIsFailed(false);
|
|
191
201
|
setOrderId(data?.orderId || null);
|
|
192
202
|
setOrderInfo(data || null);
|
|
203
|
+
if (data) {
|
|
204
|
+
setOrderFormValues(data as unknown as OrderFormInputsType);
|
|
205
|
+
}
|
|
193
206
|
if (window === top) {
|
|
194
207
|
top.postMessage(
|
|
195
208
|
{
|
|
@@ -222,7 +235,10 @@ const App: FC<ConfigType> = ({
|
|
|
222
235
|
return;
|
|
223
236
|
}
|
|
224
237
|
|
|
225
|
-
|
|
238
|
+
setTimeout(() => {
|
|
239
|
+
window.location.href = url;
|
|
240
|
+
}, 300);
|
|
241
|
+
|
|
226
242
|
return;
|
|
227
243
|
}
|
|
228
244
|
|
|
@@ -288,6 +304,7 @@ const App: FC<ConfigType> = ({
|
|
|
288
304
|
formType !== FormTypeEnum.EHF && (
|
|
289
305
|
<OrderForm
|
|
290
306
|
callback={handleForm}
|
|
307
|
+
submitStartCallback={submitStartCallback}
|
|
291
308
|
templatePackageId={templatePackageId}
|
|
292
309
|
subscriberId={subscriberId}
|
|
293
310
|
userId={userId}
|
|
@@ -307,7 +324,7 @@ const App: FC<ConfigType> = ({
|
|
|
307
324
|
errorInvalidPhoneMsg={
|
|
308
325
|
settings?.errorInvalidPhoneMsg
|
|
309
326
|
}
|
|
310
|
-
defaultValues={
|
|
327
|
+
defaultValues={orderFormValues}
|
|
311
328
|
redirectUrl={redirectUrl}
|
|
312
329
|
showIframe={showIframe}
|
|
313
330
|
paymentMethodsOptions={
|
|
@@ -31,6 +31,7 @@ import './orderForm.scss';
|
|
|
31
31
|
|
|
32
32
|
type Props = {
|
|
33
33
|
callback: (url: string | null, orderInfo?: OrderInfoType | null) => void;
|
|
34
|
+
submitStartCallback?: (id: string) => void;
|
|
34
35
|
templatePackageId: string;
|
|
35
36
|
subscriberId?: string;
|
|
36
37
|
userId?: string;
|
|
@@ -70,6 +71,7 @@ const initialData = {
|
|
|
70
71
|
|
|
71
72
|
const OrderForm: FC<Props> = ({
|
|
72
73
|
callback,
|
|
74
|
+
submitStartCallback,
|
|
73
75
|
templatePackageId,
|
|
74
76
|
subscriberId,
|
|
75
77
|
userId,
|
|
@@ -143,6 +145,8 @@ const OrderForm: FC<Props> = ({
|
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
147
|
|
|
148
|
+
submitStartCallback?.(id as string);
|
|
149
|
+
|
|
146
150
|
if (id) {
|
|
147
151
|
const paymentMethod =
|
|
148
152
|
data.paymentMethod || PAYMENT_METHOD_DEFAULT;
|
|
@@ -183,6 +187,7 @@ const OrderForm: FC<Props> = ({
|
|
|
183
187
|
orderReference: data.orderReference || undefined,
|
|
184
188
|
});
|
|
185
189
|
callback(responseOrder.terminalRedirectUrl, {
|
|
190
|
+
...(data || {}),
|
|
186
191
|
orderId: responseOrder.id,
|
|
187
192
|
subscriberId: id,
|
|
188
193
|
paymentMethod: paymentMethod,
|
package/src/types/general.ts
CHANGED
|
@@ -29,6 +29,7 @@ export const prepareAgreementModel = ({
|
|
|
29
29
|
};
|
|
30
30
|
const existUrl = new URL(window.location.href);
|
|
31
31
|
const journey = existUrl.searchParams.get('journey');
|
|
32
|
+
const hashToken = existUrl.searchParams.get('hashToken');
|
|
32
33
|
const url = showIframe
|
|
33
34
|
? window.location.href.split('?')[0]
|
|
34
35
|
: redirectUrl || window.location.href;
|
|
@@ -37,6 +38,9 @@ export const prepareAgreementModel = ({
|
|
|
37
38
|
if (journey) {
|
|
38
39
|
cancelUrl.searchParams.append('journey', journey);
|
|
39
40
|
}
|
|
41
|
+
if (hashToken) {
|
|
42
|
+
cancelUrl.searchParams.append('hashToken', hashToken);
|
|
43
|
+
}
|
|
40
44
|
const confirmUrl = new URL(url);
|
|
41
45
|
confirmUrl.searchParams.append(
|
|
42
46
|
'action',
|
|
@@ -45,6 +49,9 @@ export const prepareAgreementModel = ({
|
|
|
45
49
|
if (journey) {
|
|
46
50
|
confirmUrl.searchParams.append('journey', journey);
|
|
47
51
|
}
|
|
52
|
+
if (hashToken) {
|
|
53
|
+
confirmUrl.searchParams.append('hashToken', hashToken);
|
|
54
|
+
}
|
|
48
55
|
|
|
49
56
|
if (paymentMethod === PaymentMethodEnum.SwedbankPay) {
|
|
50
57
|
model.swedbankPay = {
|