@akinon/pz-bkm 1.119.0-rc.3 → 1.119.0
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/CHANGELOG.md +1 -15
- package/package.json +1 -1
- package/src/views/bkm-option.tsx +35 -48
package/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
# @akinon/pz-bkm
|
|
2
2
|
|
|
3
|
-
## 1.119.0
|
|
4
|
-
|
|
5
|
-
## 1.119.0-rc.2
|
|
6
|
-
|
|
7
|
-
### Minor Changes
|
|
8
|
-
|
|
9
|
-
- 6ad72e8d: ZERO-4032: Add loading state management for payment submissions across multiple components and add safe guarding
|
|
10
|
-
|
|
11
|
-
## 1.119.0-rc.1
|
|
12
|
-
|
|
13
|
-
## 1.119.0-rc.0
|
|
14
|
-
|
|
15
|
-
### Minor Changes
|
|
16
|
-
|
|
17
|
-
- 6ad72e8d: ZERO-4032: Add loading state management for payment submissions across multiple components and add safe guarding
|
|
3
|
+
## 1.119.0
|
|
18
4
|
|
|
19
5
|
## 1.118.0
|
|
20
6
|
|
package/package.json
CHANGED
package/src/views/bkm-option.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ReactElement, useId
|
|
1
|
+
import React, { ReactElement, useId } from 'react';
|
|
2
2
|
import Script from 'next/script';
|
|
3
3
|
import * as yup from 'yup';
|
|
4
4
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
@@ -53,68 +53,56 @@ const BKMOption = ({
|
|
|
53
53
|
customUIRender
|
|
54
54
|
}: BKMOptionProps) => {
|
|
55
55
|
const id = useId();
|
|
56
|
-
const [isProcessing, setIsProcessing] = useState(false);
|
|
57
56
|
const {
|
|
58
57
|
handleSubmit,
|
|
59
58
|
control,
|
|
60
|
-
formState: { errors
|
|
59
|
+
formState: { errors },
|
|
61
60
|
getValues
|
|
62
61
|
} = useForm<BKMOptionForm>({
|
|
63
62
|
resolver: yupResolver(formSchema(translations?.required))
|
|
64
63
|
});
|
|
65
|
-
const [setBkm
|
|
64
|
+
const [setBkm] = useSetBkmMutation();
|
|
66
65
|
const [completeBkm] = useCompleteBkmMutation();
|
|
67
66
|
|
|
68
|
-
const isButtonDisabled = isSubmitting || isSettingBkm || isProcessing;
|
|
69
|
-
|
|
70
67
|
const onSubmit: SubmitHandler<BKMOptionForm> = async () => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
setIsProcessing(true);
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const response = await setBkm(getValues('agreement')).unwrap();
|
|
77
|
-
|
|
78
|
-
const bexContext = response.context_list.find(
|
|
79
|
-
(context) => context.page_name === 'BexBinNumberPage'
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
if (!bexContext) {
|
|
83
|
-
setIsProcessing(false);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
68
|
+
const response = await setBkm(getValues('agreement')).unwrap();
|
|
86
69
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
{
|
|
91
|
-
id: bexContext.page_context.transaction_id,
|
|
92
|
-
path: bexContext.page_context.path,
|
|
93
|
-
token: bexContext.page_context.token
|
|
94
|
-
},
|
|
95
|
-
'modal',
|
|
96
|
-
{
|
|
97
|
-
container: `js-bkm-frame-${id}`,
|
|
98
|
-
buttonSize: [500, 500],
|
|
99
|
-
skipButton: true,
|
|
100
|
-
onComplete: async (status) => {
|
|
101
|
-
if (status == 'success') {
|
|
102
|
-
const data = await completeBkm().unwrap();
|
|
103
|
-
const redirectUrl =
|
|
104
|
-
data.context_list?.[0]?.page_context?.redirect_url;
|
|
70
|
+
const bexContext = response.context_list.find(
|
|
71
|
+
(context) => context.page_name === 'BexBinNumberPage'
|
|
72
|
+
);
|
|
105
73
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
74
|
+
if (!bexContext) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
109
77
|
|
|
110
|
-
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
window.Bex.init(
|
|
81
|
+
{
|
|
82
|
+
id: bexContext.page_context.transaction_id,
|
|
83
|
+
path: bexContext.page_context.path,
|
|
84
|
+
token: bexContext.page_context.token
|
|
85
|
+
},
|
|
86
|
+
'modal',
|
|
87
|
+
{
|
|
88
|
+
container: `js-bkm-frame-${id}`,
|
|
89
|
+
buttonSize: [500, 500],
|
|
90
|
+
skipButton: true,
|
|
91
|
+
onComplete: async (status) => {
|
|
92
|
+
if (status == 'success') {
|
|
93
|
+
const data = await completeBkm().unwrap();
|
|
94
|
+
const redirectUrl =
|
|
95
|
+
data.context_list?.[0]?.page_context?.redirect_url;
|
|
96
|
+
|
|
97
|
+
if (!redirectUrl) {
|
|
98
|
+
return;
|
|
111
99
|
}
|
|
100
|
+
|
|
101
|
+
window.location.href = redirectUrl;
|
|
112
102
|
}
|
|
113
103
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
setIsProcessing(false);
|
|
117
|
-
}
|
|
104
|
+
}
|
|
105
|
+
);
|
|
118
106
|
};
|
|
119
107
|
|
|
120
108
|
if (customUIRender) {
|
|
@@ -178,7 +166,6 @@ const BKMOption = ({
|
|
|
178
166
|
classes?.button
|
|
179
167
|
)}
|
|
180
168
|
type="submit"
|
|
181
|
-
disabled={isButtonDisabled}
|
|
182
169
|
data-testid="checkout-bank-account-place-order"
|
|
183
170
|
>
|
|
184
171
|
<span>{translations?.button ?? 'Pay with BKM Express'}</span>
|