@akinon/pz-akifast 2.0.0-beta.10 → 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,11 @@
1
1
  # @akinon/pz-akifast
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
+
3
9
  ## 2.0.0-beta.10
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -5,9 +5,7 @@
5
5
  You can use the following command to install the extension with the latest plugins:
6
6
 
7
7
  ```bash
8
-
9
8
  npx @akinon/projectzero@latest --plugins
10
-
11
9
  ```
12
10
 
13
11
  ### Setting the Visibility of Buttons
@@ -60,6 +58,75 @@ import PluginModule, { Component } from '@akinon/next/components/plugin-module';
60
58
  />;
61
59
  ```
62
60
 
61
+ ## Customizing Components
62
+
63
+ Both the `CheckoutButton` and `QuickLoginButton` can be customized using the `renderer` prop. This allows you to fully customize the appearance and behavior of these components while maintaining their core functionality.
64
+
65
+ ### Customizing Quick Login Button
66
+
67
+ ```javascript
68
+ import PluginModule, { Component } from '@akinon/next/components/plugin-module';
69
+
70
+ <PluginModule
71
+ component={Component.AkifastQuickLoginButton}
72
+ props={{
73
+ isCaptchaVisible,
74
+ captchaValidated,
75
+ buttonText: 'Quick Login',
76
+ renderer: {
77
+ renderButton: ({ buttonText, disabled, onClick, rest }) => (
78
+ <button
79
+ className="custom-login-button"
80
+ disabled={disabled}
81
+ onClick={onClick}
82
+ {...rest}
83
+ >
84
+ <svg className="icon-login" viewBox="0 0 24 24">
85
+ {/* Your custom SVG icon */}
86
+ </svg>
87
+ {buttonText}
88
+ </button>
89
+ )
90
+ }
91
+ }}
92
+ />;
93
+ ```
94
+
95
+ ### Customizing Checkout Button
96
+
97
+ ```javascript
98
+ import PluginModule, { Component } from '@akinon/next/components/plugin-module';
99
+
100
+ <PluginModule
101
+ component={Component.AkifastCheckoutButton}
102
+ props={{
103
+ isPdp: true,
104
+ renderer: {
105
+ renderButton: ({ provider, rest }) => (
106
+ <div className="custom-checkout-wrapper">
107
+ <button
108
+ className="custom-checkout-button"
109
+ onClick={() => {
110
+ // Your custom logic
111
+ console.log('Provider:', provider);
112
+ // You can still pass through all original props
113
+ console.log('Original props:', rest);
114
+ }}
115
+ >
116
+ Buy Now
117
+ </button>
118
+ </div>
119
+ ),
120
+ renderEmptyState: () => (
121
+ <div className="checkout-unavailable">
122
+ Akifast payment option is not available at the moment.
123
+ </div>
124
+ )
125
+ }
126
+ }}
127
+ />;
128
+ ```
129
+
63
130
  ## Checkout Button Props
64
131
 
65
132
  You can see other props for the button in the `pz-one-click-checkout` package.
@@ -67,6 +134,7 @@ You can see other props for the button in the `pz-one-click-checkout` package.
67
134
  | Property | Type | Description |
68
135
  | -------- | --------- | -------------------------------------- |
69
136
  | isPdp | `boolean` | Indicates if it's a product info page. |
137
+ | renderer | `object` | Custom rendering functions. |
70
138
 
71
139
  ## Quick Login Props
72
140
 
@@ -75,3 +143,28 @@ You can see other props for the button in the `pz-one-click-checkout` package.
75
143
  | buttonText | `string` | Text displayed on the button. |
76
144
  | isCaptchaVisible | `boolean` | Indicates if captcha is visible. |
77
145
  | captchaValidated | `boolean` | Indicates if captcha is validated. |
146
+ | renderer | `object` | Custom rendering functions. |
147
+
148
+ ## Renderer Props Types
149
+
150
+ The full type definitions for the renderer props:
151
+
152
+ ```typescript
153
+ interface AkifastRendererProps {
154
+ quickLoginButton?: {
155
+ renderButton?: (props: {
156
+ buttonText: string;
157
+ disabled: boolean;
158
+ onClick: () => void;
159
+ rest: React.ButtonHTMLAttributes<HTMLButtonElement>;
160
+ }) => React.ReactNode;
161
+ };
162
+ checkoutButton?: {
163
+ renderButton?: (props: {
164
+ provider: ProvidersType;
165
+ rest: OneClickCheckoutButtonProps;
166
+ }) => React.ReactNode;
167
+ renderEmptyState?: () => React.ReactNode;
168
+ };
169
+ }
170
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-akifast",
3
- "version": "2.0.0-beta.10",
3
+ "version": "2.0.0-beta.11",
4
4
  "main": "./src/index.ts",
5
5
  "module": "./src/index.ts",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { QuickLoginButton } from './views/QuickLoginButton';
2
2
  export { CheckoutButton } from './views/CheckoutButton';
3
+ export type { QuickLoginButtonProps, AkifastRendererProps } from './types';
package/src/types.ts ADDED
@@ -0,0 +1,38 @@
1
+ import { PluginModuleComponentProps } from '@akinon/next/types';
2
+ import {
3
+ ProvidersType,
4
+ OneClickCheckoutButtonProps
5
+ } from '@akinon/pz-one-click-checkout/src/types';
6
+ import React from 'react';
7
+
8
+ export interface AkifastRendererProps {
9
+ quickLoginButton?: {
10
+ renderButton?: (props: {
11
+ buttonText: string;
12
+ disabled: boolean;
13
+ onClick: () => void;
14
+ rest: React.ButtonHTMLAttributes<HTMLButtonElement>;
15
+ }) => React.ReactNode;
16
+ };
17
+ checkoutButton?: {
18
+ renderButton?: (props: {
19
+ provider: ProvidersType;
20
+ rest: OneClickCheckoutButtonProps;
21
+ }) => React.ReactNode;
22
+ renderEmptyState?: () => React.ReactNode;
23
+ };
24
+ }
25
+
26
+ export interface QuickLoginButtonProps extends PluginModuleComponentProps {
27
+ isCaptchaVisible: boolean;
28
+ captchaValidated: boolean;
29
+ buttonText?: string;
30
+ renderer?: AkifastRendererProps['quickLoginButton'];
31
+ }
32
+
33
+ export interface CheckoutButtonProps
34
+ extends PluginModuleComponentProps,
35
+ OneClickCheckoutButtonProps {
36
+ isPdp?: boolean;
37
+ renderer?: AkifastRendererProps['checkoutButton'];
38
+ }
@@ -1,21 +1,13 @@
1
1
  import React from 'react';
2
- import { PluginModuleComponentProps } from '@akinon/next/types';
3
2
  import PluginModule, { Component } from '@akinon/next/components/plugin-module';
4
3
  import { useGetCheckoutProvidersQuery } from '@akinon/pz-one-click-checkout/src/endpoints';
5
- import {
6
- OneClickCheckoutButtonProps,
7
- ProvidersType
8
- } from '@akinon/pz-one-click-checkout/src/types';
9
-
10
- interface CheckoutButtonProps
11
- extends PluginModuleComponentProps,
12
- OneClickCheckoutButtonProps {
13
- isPdp?: boolean;
14
- }
4
+ import { ProvidersType } from '@akinon/pz-one-click-checkout/src/types';
5
+ import { CheckoutButtonProps } from '../types';
15
6
 
16
7
  export const CheckoutButton = ({
17
8
  settings,
18
9
  isPdp = false,
10
+ renderer,
19
11
  ...rest
20
12
  }: CheckoutButtonProps) => {
21
13
  const { data: checkoutProviders } = useGetCheckoutProvidersQuery(null, {});
@@ -28,7 +20,14 @@ export const CheckoutButton = ({
28
20
  (isPdp && settings?.pdp === false) ||
29
21
  (!isPdp && settings?.basket === false)
30
22
  ) {
31
- return;
23
+ return renderer?.renderEmptyState ? renderer.renderEmptyState() : null;
24
+ }
25
+
26
+ if (renderer?.renderButton) {
27
+ return renderer.renderButton({
28
+ provider,
29
+ rest: { ...rest }
30
+ });
32
31
  }
33
32
 
34
33
  return (
@@ -1,36 +1,46 @@
1
1
  import React from 'react';
2
2
  import { Button } from '@akinon/next/components';
3
- import { PluginModuleComponentProps } from '@akinon/next/types';
4
-
5
- interface QuickLoginButtonProps extends PluginModuleComponentProps {
6
- isCaptchaVisible: boolean;
7
- captchaValidated: boolean;
8
- buttonText?: string;
9
- }
3
+ import { QuickLoginButtonProps } from '../types';
10
4
 
11
5
  export const QuickLoginButton = ({
12
6
  buttonText = 'Quick Login',
13
7
  isCaptchaVisible,
14
8
  captchaValidated,
15
9
  settings,
10
+ renderer,
16
11
  ...rest
17
12
  }: QuickLoginButtonProps & React.ButtonHTMLAttributes<HTMLButtonElement>) => {
18
13
  if (settings?.quickLogin === false) {
19
- return;
14
+ return null;
20
15
  }
21
16
 
22
- return (
17
+ const handleClick = () => {
18
+ location.href = `/akifast/login/`;
19
+ };
20
+
21
+ const isDisabled = isCaptchaVisible && !captchaValidated;
22
+
23
+ const DefaultButton = ({ buttonText, disabled, onClick, rest }) => (
23
24
  <Button
24
25
  className="w-full h-14 uppercase text-xs font-semibold flex items-center justify-center gap-2 hover:bg-transparent hover:border hover:border-primary-800 hover:text-primary"
25
26
  type="submit"
26
27
  appearance="outlined"
27
- disabled={isCaptchaVisible && !captchaValidated}
28
- onClick={() => {
29
- location.href = `/akifast/login/`;
30
- }}
28
+ disabled={disabled}
29
+ onClick={onClick}
31
30
  {...rest}
32
31
  >
33
32
  {buttonText}
34
33
  </Button>
35
34
  );
35
+
36
+ const RenderButton = renderer?.renderButton || DefaultButton;
37
+
38
+ return (
39
+ <RenderButton
40
+ buttonText={buttonText}
41
+ disabled={isDisabled}
42
+ onClick={handleClick}
43
+ rest={rest}
44
+ />
45
+ );
36
46
  };