@akinon/pz-bkm 2.0.0-beta.1 → 2.0.0-beta.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/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # @akinon/pz-bkm
2
2
 
3
+ ## 2.0.0-beta.11
4
+
5
+ ### Minor Changes
6
+
7
+ - ac783d6: ZERO-3482: Update tailwindcss to version 4.1.11 and enhance button cursor styles
8
+
9
+ ## 2.0.0-beta.10
10
+
11
+ ### Minor Changes
12
+
13
+ - 2806320: ZERO-3390: Update version tailwindcss, autoprefixer, tailwind-merge, postcss
14
+
15
+ ## 2.0.0-beta.9
16
+
17
+ ### Minor Changes
18
+
19
+ - 0fe7711: ZERO-3387: Upgrade nextjs, eslint-config-next
20
+
21
+ ## 2.0.0-beta.8
22
+
23
+ ## 2.0.0-beta.7
24
+
25
+ ## 2.0.0-beta.6
26
+
27
+ ### Minor Changes
28
+
29
+ - 8f05f9b: ZERO-3250: Beta branch synchronized with Main branch
30
+
31
+ ## 2.0.0-beta.5
32
+
33
+ ## 2.0.0-beta.4
34
+
35
+ ## 2.0.0-beta.3
36
+
37
+ ## 2.0.0-beta.2
38
+
39
+ ### Minor Changes
40
+
41
+ - a006015: ZERO-3116: Add not-found page and update default middleware.
42
+ - 1eeb3d8: ZERO-3116: Add not found page
43
+
3
44
  ## 2.0.0-beta.1
4
45
 
5
46
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-bkm",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.11",
4
4
  "license": "MIT",
5
5
  "main": "src/index.tsx",
6
6
  "peerDependencies": {
package/readme.md CHANGED
@@ -1,16 +1,17 @@
1
1
  # @akinon/pz-bkm
2
2
 
3
- ### Install the npm package
3
+ ## Installation method
4
+
5
+ You can use the following command to install the extension with the latest plugins:
4
6
 
5
7
  ```bash
6
- # For latest version
7
- yarn add @akinon/pz-bkm
8
8
 
9
- # Preferred installation method
10
9
  npx @akinon/projectzero@latest --plugins
10
+
11
11
  ```
12
12
 
13
13
  ### Example Usage
14
+
14
15
  ##### File Path: src/views/checkout/steps/payment/options/bkm.tsx
15
16
 
16
17
  ```javascript
@@ -33,7 +34,60 @@ export default Bkm;
33
34
  ```
34
35
 
35
36
  ### Props
36
- | Property | Type | Description |
37
- |----------------|-----------|--------------------------------------------------|
38
- | `translations` | `object` | Object containing translation strings. |
39
- | `classes` | `object` | Object containing custom CSS class names. |
37
+
38
+ | Property | Type | Description |
39
+ | --- | --- | --- |
40
+ | `translations` | `object` | Object containing translation strings. |
41
+ | `classes` | `object` | Object containing custom CSS class names. |
42
+ | `customUIRender` | `React.ReactNode` | Optional function to fully customize the bkm express. Receives control, errors, translations, bkmFrameId and handleSubmit props. |
43
+
44
+ ### Customizing BKM Express
45
+
46
+ ```javascript
47
+ import PluginModule, { Component } from '@akinon/next/components/plugin-module';
48
+
49
+ <PluginModule
50
+ component={Component.BKMExpress}
51
+ props={{
52
+ customUIRender: ({
53
+ handleSubmit,
54
+ onSubmit,
55
+ control,
56
+ errors,
57
+ translations,
58
+ bkmFrameId
59
+ }) => (
60
+ <div className="px-4 py-6">
61
+ <form onSubmit={handleSubmit(onSubmit)}>
62
+ <h2 className="font-semibold text-2xl mb-4">{translations?.title}</h2>
63
+ <p className="text-sm">
64
+ When paying with BKM Express, you will be redirected to
65
+ www.bkmexpress.com.tr. <br />
66
+ You need to log in to the application with the username and password
67
+ you used when signing up to BKM Express. You can easily pay by selecting
68
+ the card you want to make a transaction and the payment method from the
69
+ payment screen that appears. After completing your shopping, you will
70
+ automatically return to site.
71
+ </p>
72
+ <div className="py-4">
73
+ <CheckoutAgreements
74
+ control={control}
75
+ error={errors?.agreement}
76
+ fieldId="agreement"
77
+ />
78
+ </div>
79
+
80
+ <button className="w-full bg-primary text-white h-9" type="submit">
81
+ Pay with BKM Express
82
+ </button>
83
+ </form>
84
+
85
+ <div
86
+ id={bkmFrameId}
87
+ className="bkm-frame !flex justify-center items-center !pt-0"
88
+ ></div>
89
+ </div>
90
+ )
91
+ }}
92
+ />;
93
+ ```
@@ -2,11 +2,21 @@ 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';
5
- import { SubmitHandler, useForm } from 'react-hook-form';
5
+ import {
6
+ SubmitHandler,
7
+ useForm,
8
+ UseFormHandleSubmit,
9
+ Control,
10
+ FieldErrors
11
+ } from 'react-hook-form';
6
12
  import { Button } from '@akinon/next/components';
7
13
  import { useCompleteBkmMutation, useSetBkmMutation } from '../endpoints';
8
14
  import { twMerge } from 'tailwind-merge';
9
15
 
16
+ interface BKMOptionForm {
17
+ agreement: boolean;
18
+ }
19
+
10
20
  type BKMOptionProps = {
11
21
  translations?: {
12
22
  title?: string;
@@ -18,6 +28,14 @@ type BKMOptionProps = {
18
28
  description?: string;
19
29
  button?: string;
20
30
  };
31
+ customUIRender?: (params: {
32
+ handleSubmit: UseFormHandleSubmit<BKMOptionForm>;
33
+ onSubmit: SubmitHandler<BKMOptionForm>;
34
+ control: Control<BKMOptionForm>;
35
+ errors: FieldErrors<BKMOptionForm>;
36
+ translations?: BKMOptionProps['translations'];
37
+ bkmFrameId: string;
38
+ }) => ReactElement;
21
39
  agreementCheckbox?: ReactElement;
22
40
  };
23
41
 
@@ -31,7 +49,8 @@ const formSchema = (requiredText?: string) =>
31
49
  const BKMOption = ({
32
50
  translations,
33
51
  classes,
34
- agreementCheckbox
52
+ agreementCheckbox,
53
+ customUIRender
35
54
  }: BKMOptionProps) => {
36
55
  const id = useId();
37
56
  const {
@@ -39,13 +58,13 @@ const BKMOption = ({
39
58
  control,
40
59
  formState: { errors },
41
60
  getValues
42
- } = useForm({
61
+ } = useForm<BKMOptionForm>({
43
62
  resolver: yupResolver(formSchema(translations?.required))
44
63
  });
45
64
  const [setBkm] = useSetBkmMutation();
46
65
  const [completeBkm] = useCompleteBkmMutation();
47
66
 
48
- const onSubmit: SubmitHandler<null> = async () => {
67
+ const onSubmit: SubmitHandler<BKMOptionForm> = async () => {
49
68
  const response = await setBkm(getValues('agreement')).unwrap();
50
69
 
51
70
  const bexContext = response.context_list.find(
@@ -86,6 +105,25 @@ const BKMOption = ({
86
105
  );
87
106
  };
88
107
 
108
+ if (customUIRender) {
109
+ return (
110
+ <>
111
+ {customUIRender({
112
+ handleSubmit,
113
+ onSubmit,
114
+ control,
115
+ errors,
116
+ translations,
117
+ bkmFrameId: `js-bkm-frame-${id}`
118
+ })}
119
+ <Script
120
+ src="https://js.bkmexpress.com.tr/v1/javascripts/bex.js"
121
+ defer
122
+ />
123
+ </>
124
+ );
125
+ }
126
+
89
127
  return (
90
128
  <>
91
129
  <form className="flex flex-col w-full" onSubmit={handleSubmit(onSubmit)}>
@@ -138,7 +176,7 @@ const BKMOption = ({
138
176
  </form>
139
177
  <div
140
178
  id={`js-bkm-frame-${id}`}
141
- className="bkm-frame !flex justify-center items-center !pt-0"
179
+ className="bkm-frame flex! justify-center items-center pt-0!"
142
180
  ></div>
143
181
  <Script src="https://js.bkmexpress.com.tr/v1/javascripts/bex.js" defer />
144
182
  </>