@akinon/next 1.61.0 → 1.62.0
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 +8 -0
- package/components/index.ts +1 -0
- package/components/plugin-module.tsx +8 -3
- package/components/select.tsx +70 -0
- package/components/selected-payment-option-view.tsx +2 -1
- package/hooks/use-payment-options.ts +1 -0
- package/middlewares/url-redirection.ts +14 -2
- package/package.json +2 -2
- package/plugins.d.ts +5 -0
- package/plugins.js +1 -0
- package/redux/middlewares/checkout.ts +5 -2
- package/redux/middlewares/index.ts +4 -1
- package/redux/reducers/index.ts +3 -1
- package/routes/pretty-url.tsx +7 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.62.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c416d18: ZERO-2915: Add delivery option null check for setAddress
|
|
8
|
+
- 033b084: ZERO-2956: refactor redirect response handling for set-cookie headers
|
|
9
|
+
- fcea495: ZERO-2956: add set-cookies headers in url-redirection middleware
|
|
10
|
+
|
|
3
11
|
## 1.61.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/components/index.ts
CHANGED
|
@@ -19,7 +19,8 @@ enum Plugin {
|
|
|
19
19
|
Masterpass = 'pz-masterpass',
|
|
20
20
|
B2B = 'pz-b2b',
|
|
21
21
|
Akifast = 'pz-akifast',
|
|
22
|
-
MultiBasket = 'pz-multi-basket'
|
|
22
|
+
MultiBasket = 'pz-multi-basket',
|
|
23
|
+
SavedCard = 'pz-saved-card'
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export enum Component {
|
|
@@ -43,7 +44,8 @@ export enum Component {
|
|
|
43
44
|
BasketB2B = 'BasketB2b',
|
|
44
45
|
AkifastQuickLoginButton = 'QuickLoginButton',
|
|
45
46
|
AkifastCheckoutButton = 'CheckoutButton',
|
|
46
|
-
MultiBasket = 'MultiBasket'
|
|
47
|
+
MultiBasket = 'MultiBasket',
|
|
48
|
+
SavedCard = 'Option'
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
const PluginComponents = new Map([
|
|
@@ -75,7 +77,8 @@ const PluginComponents = new Map([
|
|
|
75
77
|
Plugin.Akifast,
|
|
76
78
|
[Component.AkifastQuickLoginButton, Component.AkifastCheckoutButton]
|
|
77
79
|
],
|
|
78
|
-
[Plugin.MultiBasket, [Component.MultiBasket]]
|
|
80
|
+
[Plugin.MultiBasket, [Component.MultiBasket]],
|
|
81
|
+
[Plugin.SavedCard, [Component.SavedCard]]
|
|
79
82
|
]);
|
|
80
83
|
|
|
81
84
|
const getPlugin = (component: Component) => {
|
|
@@ -138,6 +141,8 @@ export default function PluginModule({
|
|
|
138
141
|
promise = import(`${'@akinon/pz-akifast'}`);
|
|
139
142
|
} else if (plugin === Plugin.MultiBasket) {
|
|
140
143
|
promise = import(`${'@akinon/pz-multi-basket'}`);
|
|
144
|
+
} else if (plugin === Plugin.SavedCard) {
|
|
145
|
+
promise = import(`${'@akinon/pz-saved-card'}`);
|
|
141
146
|
}
|
|
142
147
|
} catch (error) {
|
|
143
148
|
logger.error(error);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { SelectProps } from '@theme/components/types';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { Icon } from './icon';
|
|
5
|
+
import { twMerge } from 'tailwind-merge';
|
|
6
|
+
|
|
7
|
+
const Select = forwardRef<HTMLSelectElement, SelectProps>((props, ref) => {
|
|
8
|
+
const {
|
|
9
|
+
className,
|
|
10
|
+
options,
|
|
11
|
+
borderless = false,
|
|
12
|
+
icon,
|
|
13
|
+
iconSize,
|
|
14
|
+
error,
|
|
15
|
+
label,
|
|
16
|
+
required = false,
|
|
17
|
+
...rest
|
|
18
|
+
} = props;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<label
|
|
22
|
+
className={clsx('flex flex-col relative text-xs text-gray-800', {
|
|
23
|
+
'pl-7': icon
|
|
24
|
+
})}
|
|
25
|
+
>
|
|
26
|
+
{icon && (
|
|
27
|
+
<Icon
|
|
28
|
+
name={icon}
|
|
29
|
+
size={iconSize ?? 20}
|
|
30
|
+
className="absolute left-0 top-1/2 transform -translate-y-1/2"
|
|
31
|
+
/>
|
|
32
|
+
)}
|
|
33
|
+
|
|
34
|
+
{label && (
|
|
35
|
+
<span className="mb-1">
|
|
36
|
+
{label} {required && <span className="text-secondary">*</span>}
|
|
37
|
+
</span>
|
|
38
|
+
)}
|
|
39
|
+
<select
|
|
40
|
+
{...rest}
|
|
41
|
+
ref={ref}
|
|
42
|
+
className={twMerge(
|
|
43
|
+
clsx(
|
|
44
|
+
'cursor-pointer truncate h-10 w-40 px-2.5 shrink-0 outline-none',
|
|
45
|
+
!borderless &&
|
|
46
|
+
'border border-gray-200 transition-all duration-150 hover:border-primary'
|
|
47
|
+
),
|
|
48
|
+
className
|
|
49
|
+
)}
|
|
50
|
+
>
|
|
51
|
+
{options.map((option) => (
|
|
52
|
+
<option
|
|
53
|
+
key={option.value}
|
|
54
|
+
value={option.value}
|
|
55
|
+
className={option.class}
|
|
56
|
+
>
|
|
57
|
+
{option.label}
|
|
58
|
+
</option>
|
|
59
|
+
))}
|
|
60
|
+
</select>
|
|
61
|
+
{error && (
|
|
62
|
+
<span className="mt-1 text-sm text-error">{error.message}</span>
|
|
63
|
+
)}
|
|
64
|
+
</label>
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
Select.displayName = 'Select';
|
|
69
|
+
|
|
70
|
+
export { Select };
|
|
@@ -17,7 +17,8 @@ const paymentTypeToView = {
|
|
|
17
17
|
loyalty_money: 'loyalty',
|
|
18
18
|
masterpass: 'credit-card',
|
|
19
19
|
pay_on_delivery: 'pay-on-delivery',
|
|
20
|
-
redirection: 'redirection'
|
|
20
|
+
redirection: 'redirection',
|
|
21
|
+
saved_card: 'saved-card'
|
|
21
22
|
// Add other mappings as needed
|
|
22
23
|
};
|
|
23
24
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NextFetchEvent, NextMiddleware } from 'next/server';
|
|
1
|
+
import { NextFetchEvent, NextMiddleware, NextResponse } from 'next/server';
|
|
2
2
|
import settings from 'settings';
|
|
3
3
|
import { PzNextRequest } from '.';
|
|
4
4
|
import logger from '../utils/log';
|
|
@@ -58,7 +58,19 @@ const withUrlRedirection =
|
|
|
58
58
|
req.middlewareParams.rewrites.locale
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
const setCookies = request.headers.getSetCookie();
|
|
62
|
+
|
|
63
|
+
const response = NextResponse.redirect(redirectUrl.toString(), {
|
|
64
|
+
status: request.status
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (setCookies && setCookies.length > 0) {
|
|
68
|
+
for (const cookie of setCookies) {
|
|
69
|
+
response.headers.append('Set-Cookie', cookie);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return response;
|
|
62
74
|
}
|
|
63
75
|
} catch (error) {
|
|
64
76
|
logger.error('withUrlRedirection error', {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.62.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"set-cookie-parser": "2.6.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@akinon/eslint-plugin-projectzero": "1.
|
|
33
|
+
"@akinon/eslint-plugin-projectzero": "1.62.0",
|
|
34
34
|
"@types/react-redux": "7.1.30",
|
|
35
35
|
"@types/set-cookie-parser": "2.4.7",
|
|
36
36
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
package/plugins.d.ts
CHANGED
package/plugins.js
CHANGED
|
@@ -107,7 +107,8 @@ export const preOrderMiddleware: Middleware = ({
|
|
|
107
107
|
if (
|
|
108
108
|
(!preOrder.shipping_address || !preOrder.billing_address) &&
|
|
109
109
|
addresses.length > 0 &&
|
|
110
|
-
preOrder.delivery_option
|
|
110
|
+
(!preOrder.delivery_option ||
|
|
111
|
+
preOrder.delivery_option.delivery_option_type === 'customer')
|
|
111
112
|
) {
|
|
112
113
|
dispatch(
|
|
113
114
|
apiEndpoints.setAddresses.initiate({
|
|
@@ -225,7 +226,9 @@ export const contextListMiddleware: Middleware = ({
|
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
if (context.page_context.credit_payment_options) {
|
|
228
|
-
dispatch(
|
|
229
|
+
dispatch(
|
|
230
|
+
setCreditPaymentOptions(context.page_context.credit_payment_options)
|
|
231
|
+
);
|
|
229
232
|
}
|
|
230
233
|
|
|
231
234
|
if (context.page_context.payment_choices) {
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
import { api } from '../../data/client/api';
|
|
12
12
|
import logger from '@akinon/next/utils/log';
|
|
13
13
|
|
|
14
|
+
import { savedCardMiddleware } from '@akinon/pz-saved-card';
|
|
15
|
+
|
|
14
16
|
export const rtkQueryResponseHandler: Middleware =
|
|
15
17
|
({ dispatch }) =>
|
|
16
18
|
(next) =>
|
|
@@ -44,7 +46,8 @@ const middlewares = [
|
|
|
44
46
|
rtkQueryErrorHandler,
|
|
45
47
|
errorMiddleware,
|
|
46
48
|
preOrderMiddleware,
|
|
47
|
-
contextListMiddleware
|
|
49
|
+
contextListMiddleware,
|
|
50
|
+
savedCardMiddleware
|
|
48
51
|
];
|
|
49
52
|
|
|
50
53
|
export default middlewares;
|
package/redux/reducers/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { api } from '../../data/client/api';
|
|
|
7
7
|
// Plugin reducers
|
|
8
8
|
import { masterpassReducer } from '@akinon/pz-masterpass';
|
|
9
9
|
import { otpReducer } from '@akinon/pz-otp';
|
|
10
|
+
import { savedCardReducer } from '@akinon/pz-saved-card';
|
|
10
11
|
|
|
11
12
|
const reducers = {
|
|
12
13
|
[api.reducerPath]: api.reducer,
|
|
@@ -15,7 +16,8 @@ const reducers = {
|
|
|
15
16
|
config: configReducer,
|
|
16
17
|
header: headerReducer,
|
|
17
18
|
masterpass: masterpassReducer,
|
|
18
|
-
otp: otpReducer
|
|
19
|
+
otp: otpReducer,
|
|
20
|
+
saved_card: savedCardReducer
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
export default reducers;
|
package/routes/pretty-url.tsx
CHANGED
|
@@ -63,16 +63,13 @@ export async function generateMetadata({ params }: PageProps) {
|
|
|
63
63
|
.filter((x) => !x.startsWith('searchparams'))
|
|
64
64
|
.join('/');
|
|
65
65
|
|
|
66
|
-
const searchParams =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
) ?? {}
|
|
73
|
-
).entries()
|
|
66
|
+
const searchParams = new URLSearchParams(
|
|
67
|
+
decodeURIComponent(
|
|
68
|
+
prettyurl
|
|
69
|
+
.find((x) => x.startsWith('searchparams'))
|
|
70
|
+
?.replace('searchparams%7C', '')
|
|
71
|
+
) ?? {}
|
|
74
72
|
);
|
|
75
|
-
|
|
76
73
|
const prettyUrlResult = await resolvePrettyUrlHandler(pageSlug, null)();
|
|
77
74
|
|
|
78
75
|
if (!prettyUrlResult.matched) {
|
|
@@ -162,7 +159,7 @@ export default async function Page({ params }) {
|
|
|
162
159
|
...params,
|
|
163
160
|
pk: result.pk
|
|
164
161
|
},
|
|
165
|
-
searchParams
|
|
162
|
+
searchParams: urlSearchParams
|
|
166
163
|
};
|
|
167
164
|
|
|
168
165
|
if (result.path.startsWith('/category/')) {
|