@akinon/pz-bkm 2.0.0-beta.12 → 2.0.0-beta.14

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 CHANGED
@@ -1,63 +1,110 @@
1
1
  # @akinon/pz-bkm
2
2
 
3
- ## 2.0.0-beta.12
3
+ ## 2.0.0-beta.14
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 1d79e32: ZERO-3540: Next.js Upgrade to 15.4.5
7
+ - 6ad72e8d: ZERO-4032: Add loading state management for payment submissions across multiple components and add safe guarding
8
8
 
9
- ## 2.0.0-beta.11
9
+ ## 2.0.0-beta.13
10
10
 
11
- ### Minor Changes
11
+ ## 1.118.0
12
12
 
13
- - ac783d6: ZERO-3482: Update tailwindcss to version 4.1.11 and enhance button cursor styles
13
+ ## 1.117.0
14
14
 
15
- ## 2.0.0-beta.10
15
+ ## 1.116.0
16
16
 
17
- ### Minor Changes
17
+ ## 1.115.0
18
18
 
19
- - 2806320: ZERO-3390: Update version tailwindcss, autoprefixer, tailwind-merge, postcss
19
+ ## 1.114.0
20
20
 
21
- ## 2.0.0-beta.9
21
+ ## 1.113.0
22
22
 
23
- ### Minor Changes
23
+ ## 1.112.0
24
+
25
+ ## 1.111.0
26
+
27
+ ## 1.110.0
28
+
29
+ ## 1.109.0
30
+
31
+ ## 1.108.0
24
32
 
25
- - 0fe7711: ZERO-3387: Upgrade nextjs, eslint-config-next
33
+ ## 1.107.0
26
34
 
27
- ## 2.0.0-beta.8
35
+ ## 1.106.0
28
36
 
29
- ## 2.0.0-beta.7
37
+ ## 1.105.0
30
38
 
31
- ## 2.0.0-beta.6
39
+ ## 1.104.0
40
+
41
+ ## 1.103.0
42
+
43
+ ## 1.102.0
44
+
45
+ ## 1.101.0
46
+
47
+ ## 1.100.0
48
+
49
+ ## 1.99.0
32
50
 
33
51
  ### Minor Changes
34
52
 
35
- - 8f05f9b: ZERO-3250: Beta branch synchronized with Main branch
53
+ - d58538b: ZERO-3638: Enhance RC pipeline: add fetch, merge, and pre-release setup with conditional commit
54
+
55
+ ## 1.98.0
56
+
57
+ ## 1.97.0
36
58
 
37
- ## 2.0.0-beta.5
59
+ ## 1.96.0
38
60
 
39
- ## 2.0.0-beta.4
61
+ ## 1.95.0
40
62
 
41
- ## 2.0.0-beta.3
63
+ ## 1.94.0
42
64
 
43
- ## 2.0.0-beta.2
65
+ ## 1.93.0
66
+
67
+ ## 1.92.0
68
+
69
+ ## 1.91.0
70
+
71
+ ## 1.90.0
44
72
 
45
73
  ### Minor Changes
46
74
 
47
- - a006015: ZERO-3116: Add not-found page and update default middleware.
48
- - 1eeb3d8: ZERO-3116: Add not found page
75
+ - 1044bce: ZERO-3379: Add custom UI rendering support
76
+
77
+ ## 1.89.0
78
+
79
+ ## 1.88.0
80
+
81
+ ## 1.87.0
82
+
83
+ ## 1.86.0
49
84
 
50
- ## 2.0.0-beta.1
85
+ ## 1.85.0
86
+
87
+ ## 1.84.0
51
88
 
52
89
  ### Minor Changes
53
90
 
54
- - ZERO-3091: Upgrade Next.js to v15 and React to v19
91
+ - 624a4eb: ZERO-3276: Update installation instructions across multiple README files to standardize format and improve clarity
92
+
93
+ ## 1.83.0
94
+
95
+ ## 1.82.0
96
+
97
+ ## 1.81.0
98
+
99
+ ## 1.80.0
100
+
101
+ ## 1.79.0
55
102
 
56
- ## 2.0.0-beta.0
103
+ ## 1.78.0
57
104
 
58
- ### Major Changes
105
+ ## 1.77.0
59
106
 
60
- - be6c09d: ZERO-3114: Create beta version.
107
+ ## 1.76.0
61
108
 
62
109
  ## 1.75.0
63
110
 
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@akinon/pz-bkm",
3
- "version": "2.0.0-beta.12",
3
+ "version": "2.0.0-beta.14",
4
4
  "license": "MIT",
5
5
  "main": "src/index.tsx",
6
6
  "peerDependencies": {
7
- "react": "^19.0.0",
8
- "react-dom": "^19.0.0"
7
+ "react": "^18.0.0 || ^19.0.0",
8
+ "react-dom": "^18.0.0 || ^19.0.0"
9
9
  },
10
10
  "devDependencies": {
11
- "@types/node": "^22.10.2",
12
- "@types/react": "^19.0.2",
13
- "@types/react-dom": "^19.0.2",
14
- "react": "^19.0.0",
15
- "react-dom": "^19.0.0",
16
- "typescript": "^5.7.2"
11
+ "@types/node": "^18.7.8",
12
+ "@types/react": "^18.0.17",
13
+ "@types/react-dom": "^18.0.6",
14
+ "react": "^19.2.4",
15
+ "react-dom": "^19.2.4",
16
+ "typescript": "5.2.2"
17
17
  },
18
18
  "dependencies": {
19
19
  "@hookform/resolvers": "2.9.0",
@@ -1,4 +1,4 @@
1
- import React, { ReactElement, useId } from 'react';
1
+ import React, { ReactElement, useId, useState } 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,56 +53,68 @@ const BKMOption = ({
53
53
  customUIRender
54
54
  }: BKMOptionProps) => {
55
55
  const id = useId();
56
+ const [isProcessing, setIsProcessing] = useState(false);
56
57
  const {
57
58
  handleSubmit,
58
59
  control,
59
- formState: { errors },
60
+ formState: { errors, isSubmitting },
60
61
  getValues
61
62
  } = useForm<BKMOptionForm>({
62
- resolver: yupResolver(formSchema(translations?.required))
63
+ resolver: yupResolver(formSchema(translations?.required)) as any
63
64
  });
64
- const [setBkm] = useSetBkmMutation();
65
+ const [setBkm, { isLoading: isSettingBkm }] = useSetBkmMutation();
65
66
  const [completeBkm] = useCompleteBkmMutation();
66
67
 
68
+ const isButtonDisabled = isSubmitting || isSettingBkm || isProcessing;
69
+
67
70
  const onSubmit: SubmitHandler<BKMOptionForm> = async () => {
68
- const response = await setBkm(getValues('agreement')).unwrap();
71
+ if (isButtonDisabled) return;
69
72
 
70
- const bexContext = response.context_list.find(
71
- (context) => context.page_name === 'BexBinNumberPage'
72
- );
73
+ setIsProcessing(true);
73
74
 
74
- if (!bexContext) {
75
- return;
76
- }
75
+ try {
76
+ const response = await setBkm(getValues('agreement')).unwrap();
77
77
 
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;
99
- }
78
+ const bexContext = response.context_list.find(
79
+ (context) => context.page_name === 'BexBinNumberPage'
80
+ );
81
+
82
+ if (!bexContext) {
83
+ setIsProcessing(false);
84
+ return;
85
+ }
100
86
 
101
- window.location.href = redirectUrl;
87
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
88
+ // @ts-ignore
89
+ window.Bex.init(
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;
105
+
106
+ if (!redirectUrl) {
107
+ return;
108
+ }
109
+
110
+ window.location.href = redirectUrl;
111
+ }
102
112
  }
103
113
  }
104
- }
105
- );
114
+ );
115
+ } catch (error) {
116
+ setIsProcessing(false);
117
+ }
106
118
  };
107
119
 
108
120
  if (customUIRender) {
@@ -155,9 +167,8 @@ const BKMOption = ({
155
167
  <div className="px-4 sm:px-6">
156
168
  <div className="flex items-start flex-col border-t border-solid border-gray-400 py-4 space-y-4">
157
169
  {agreementCheckbox &&
158
- React.cloneElement(agreementCheckbox, {
159
- // @ts-ignore
160
- control: control,
170
+ React.cloneElement(agreementCheckbox as any, {
171
+ control: control as any,
161
172
  error: errors.agreement,
162
173
  fieldId: 'agreement'
163
174
  })}
@@ -167,6 +178,7 @@ const BKMOption = ({
167
178
  classes?.button
168
179
  )}
169
180
  type="submit"
181
+ disabled={isButtonDisabled}
170
182
  data-testid="checkout-bank-account-place-order"
171
183
  >
172
184
  <span>{translations?.button ?? 'Pay with BKM Express'}</span>
@@ -176,7 +188,7 @@ const BKMOption = ({
176
188
  </form>
177
189
  <div
178
190
  id={`js-bkm-frame-${id}`}
179
- className="bkm-frame flex! justify-center items-center pt-0!"
191
+ className="bkm-frame !flex justify-center items-center !pt-0"
180
192
  ></div>
181
193
  <Script src="https://js.bkmexpress.com.tr/v1/javascripts/bex.js" defer />
182
194
  </>