@akinon/pz-one-click-checkout 2.0.0-beta.10 → 2.0.0-beta.12
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 +12 -0
- package/README.md +37 -1
- package/package.json +1 -1
- package/src/types/index.ts +8 -0
- package/src/views/providers/provider-button.tsx +15 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @akinon/pz-one-click-checkout
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.12
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1d79e32: ZERO-3540: Next.js Upgrade to 15.4.5
|
|
8
|
+
|
|
9
|
+
## 2.0.0-beta.11
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- ac783d6: ZERO-3482: Update tailwindcss to version 4.1.11 and enhance button cursor styles
|
|
14
|
+
|
|
3
15
|
## 2.0.0-beta.10
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -25,7 +25,43 @@ npx @akinon/projectzero@latest --plugins
|
|
|
25
25
|
| content | `React.ReactNode` | It is used to create custom content. |
|
|
26
26
|
| openMiniBasket | `boolean` | Manages the opening status of the minibasket. |
|
|
27
27
|
| translations.buttonText | `string` | The text of the button. |
|
|
28
|
+
| customUIRender | `React.ReactNode` | Optional function to fully customize the button rendering. Receives onClick, disabled, loading, provider, productError and content props. |
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
### Customizing Checkout Button
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import PluginModule, { Component } from '@akinon/next/components/plugin-module';
|
|
34
|
+
|
|
35
|
+
<PluginModule
|
|
36
|
+
component={Component.OneClickCheckoutButtons}
|
|
37
|
+
props={{
|
|
38
|
+
customUIRender: ({
|
|
39
|
+
onClick,
|
|
40
|
+
disabled,
|
|
41
|
+
loading,
|
|
42
|
+
provider,
|
|
43
|
+
productError,
|
|
44
|
+
content
|
|
45
|
+
}) => (
|
|
46
|
+
<>
|
|
47
|
+
<button
|
|
48
|
+
onClick={onClick}
|
|
49
|
+
disabled={disabled}
|
|
50
|
+
className="relative w-full py-3 bg-[#ff2000] text-black hover:bg-[#547ee7] text-sm font-semibold flex items-center justify-center"
|
|
51
|
+
>
|
|
52
|
+
{loading && (
|
|
53
|
+
<span className="absolute left-3 w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin" />
|
|
54
|
+
)}
|
|
55
|
+
{loading ? 'Please wait...' : content ?? `Buy with ${provider.name}`}
|
|
56
|
+
</button>
|
|
30
57
|
|
|
58
|
+
{productError && (
|
|
59
|
+
<div className="mt-4 text-xs text-center text-[#d72b01]">
|
|
60
|
+
{productError}
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
63
|
+
</>
|
|
64
|
+
)
|
|
65
|
+
}}
|
|
66
|
+
/>;
|
|
31
67
|
```
|
package/package.json
CHANGED
package/src/types/index.ts
CHANGED
|
@@ -19,6 +19,14 @@ export interface OneClickCheckoutProps {
|
|
|
19
19
|
buttonText?: string;
|
|
20
20
|
};
|
|
21
21
|
content?: React.ReactNode;
|
|
22
|
+
customUIRender?: (props: {
|
|
23
|
+
onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
loading: boolean;
|
|
26
|
+
provider: OneClickCheckoutButtonProps['provider'];
|
|
27
|
+
productError?: string | null;
|
|
28
|
+
content?: React.ReactNode;
|
|
29
|
+
}) => React.ReactNode;
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
export interface OneClickCheckoutButtonProps extends OneClickCheckoutProps {
|
|
@@ -27,7 +27,8 @@ export const OneClickCheckoutButton = (props: OneClickCheckoutButtonProps) => {
|
|
|
27
27
|
onError,
|
|
28
28
|
provider,
|
|
29
29
|
translations,
|
|
30
|
-
content
|
|
30
|
+
content,
|
|
31
|
+
customUIRender
|
|
31
32
|
} = props;
|
|
32
33
|
|
|
33
34
|
const [disabled, setDisabled] = useState(isDisabled);
|
|
@@ -101,9 +102,21 @@ export const OneClickCheckoutButton = (props: OneClickCheckoutButtonProps) => {
|
|
|
101
102
|
setDisabled(false);
|
|
102
103
|
};
|
|
103
104
|
|
|
105
|
+
if (customUIRender) {
|
|
106
|
+
return customUIRender({
|
|
107
|
+
onClick: (e) => handleOnClick(e, provider?.pk),
|
|
108
|
+
disabled,
|
|
109
|
+
loading: disabled,
|
|
110
|
+
provider,
|
|
111
|
+
content,
|
|
112
|
+
productError
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
104
116
|
return (
|
|
105
117
|
<>
|
|
106
118
|
<Button
|
|
119
|
+
data-testid={`one-click-checkout-${provider?.slug}`}
|
|
107
120
|
onClick={(e) => handleOnClick(e, provider.pk)}
|
|
108
121
|
className={twMerge(
|
|
109
122
|
clsx(
|
|
@@ -119,7 +132,7 @@ export const OneClickCheckoutButton = (props: OneClickCheckoutButtonProps) => {
|
|
|
119
132
|
>
|
|
120
133
|
{content
|
|
121
134
|
? content
|
|
122
|
-
: translations?.buttonText ?? `${provider
|
|
135
|
+
: translations?.buttonText ?? `${provider?.name} Checkout`}
|
|
123
136
|
|
|
124
137
|
{disabled && (
|
|
125
138
|
<div className="absolute flex justify-center items-center bg-[#000000] opacity-50 w-full h-full">
|