@akinon/pz-akifast 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-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
+
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/README.md CHANGED
@@ -1,16 +1,15 @@
1
1
  # @akinon/pz-akifast
2
2
 
3
- ### Install the npm package
3
+ ## Installation
4
4
 
5
- ```bash
6
- # For latest version
7
- yarn add @akinon/pz-akifast
5
+ You can use the following command to install the extension with the latest plugins:
8
6
 
9
- # Preferred installation method
7
+ ```bash
10
8
  npx @akinon/projectzero@latest --plugins
11
9
  ```
12
10
 
13
11
  ### Setting the Visibility of Buttons
12
+
14
13
  (all buttons are visible by default)
15
14
 
16
15
  ```javascript
@@ -23,9 +22,9 @@ module.exports = {
23
22
  'pz-akifast': {
24
23
  quickLogin: false,
25
24
  pdp: false,
26
- basket: false,
27
- },
28
- },
25
+ basket: false
26
+ }
27
+ }
29
28
  };
30
29
  ```
31
30
 
@@ -42,7 +41,7 @@ import PluginModule, { Component } from '@akinon/next/components/plugin-module';
42
41
  ...checkoutProviderProps, // same with one click checkout props
43
42
  isPdp: true
44
43
  }}
45
- />
44
+ />;
46
45
  ```
47
46
 
48
47
  ## Quick Login Button
@@ -56,7 +55,76 @@ import PluginModule, { Component } from '@akinon/next/components/plugin-module';
56
55
  isCaptchaVisible,
57
56
  captchaValidated
58
57
  }}
59
- />
58
+ />;
59
+ ```
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
+ />;
60
128
  ```
61
129
 
62
130
  ## Checkout Button Props
@@ -64,13 +132,39 @@ import PluginModule, { Component } from '@akinon/next/components/plugin-module';
64
132
  You can see other props for the button in the `pz-one-click-checkout` package.
65
133
 
66
134
  | Property | Type | Description |
67
- |----------|-----------|----------------------------------------|
135
+ | -------- | --------- | -------------------------------------- |
68
136
  | isPdp | `boolean` | Indicates if it's a product info page. |
137
+ | renderer | `object` | Custom rendering functions. |
69
138
 
70
139
  ## Quick Login Props
71
140
 
72
141
  | Property | Type | Description |
73
- |------------------|-----------|------------------------------------|
142
+ | ---------------- | --------- | ---------------------------------- |
74
143
  | buttonText | `string` | Text displayed on the button. |
75
144
  | isCaptchaVisible | `boolean` | Indicates if captcha is visible. |
76
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.1",
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
  };