@akinon/next 2.0.0-beta.0 → 2.0.0-beta.1
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 +6 -0
- package/api/client.ts +3 -2
- package/components/pz-root.tsx +1 -1
- package/hocs/client/with-segment-defaults.tsx +1 -1
- package/hocs/server/with-segment-defaults.tsx +6 -3
- package/package.json +7 -7
- package/types/commerce/checkout.ts +1 -0
- package/types/index.ts +2 -2
- package/utils/app-fetch.ts +2 -2
- package/utils/redirect.ts +2 -2
package/CHANGELOG.md
CHANGED
package/api/client.ts
CHANGED
|
@@ -14,6 +14,7 @@ interface RouteParams {
|
|
|
14
14
|
|
|
15
15
|
async function proxyRequest(...args) {
|
|
16
16
|
const [req, { params }] = args as [req: Request, params: RouteParams];
|
|
17
|
+
const resolvedParams = await params;
|
|
17
18
|
const { searchParams } = new URL(req.url);
|
|
18
19
|
const commerceUrl = settings.commerceUrl;
|
|
19
20
|
|
|
@@ -32,7 +33,7 @@ async function proxyRequest(...args) {
|
|
|
32
33
|
responseType: 'json'
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
const slug = `${
|
|
36
|
+
const slug = `${resolvedParams.slug.join('/')}/`;
|
|
36
37
|
const options_ = JSON.parse(
|
|
37
38
|
decodeURIComponent((searchParams.get('options') as string) ?? '{}')
|
|
38
39
|
);
|
|
@@ -85,7 +86,7 @@ async function proxyRequest(...args) {
|
|
|
85
86
|
}
|
|
86
87
|
} as RequestInit;
|
|
87
88
|
|
|
88
|
-
const nextCookies = cookies();
|
|
89
|
+
const nextCookies = await cookies();
|
|
89
90
|
const segment = nextCookies.get('pz-segment')?.value;
|
|
90
91
|
const currency = nextCookies.get('pz-external-currency')?.value;
|
|
91
92
|
|
package/components/pz-root.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import settings from 'settings';
|
|
2
|
+
import { JSX } from 'react';
|
|
2
3
|
import { LayoutProps, PageProps, RootLayoutProps } from '../../types';
|
|
3
4
|
import { redirect } from 'next/navigation';
|
|
4
5
|
import { ServerVariables } from '../../utils/server-variables';
|
|
@@ -21,6 +22,8 @@ export const withSegmentDefaults =
|
|
|
21
22
|
async (props: T) => {
|
|
22
23
|
let componentProps = { ...props };
|
|
23
24
|
|
|
25
|
+
const { locale, currency } = await props.params;
|
|
26
|
+
|
|
24
27
|
if (options.segmentType === 'root-layout') {
|
|
25
28
|
componentProps = (await addRootLayoutProps(
|
|
26
29
|
componentProps as RootLayoutProps
|
|
@@ -29,8 +32,8 @@ export const withSegmentDefaults =
|
|
|
29
32
|
checkRedisVariables();
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
ServerVariables.locale =
|
|
33
|
-
ServerVariables.currency =
|
|
35
|
+
ServerVariables.locale = await locale;
|
|
36
|
+
ServerVariables.currency = await currency;
|
|
34
37
|
|
|
35
38
|
return await (
|
|
36
39
|
<>
|
|
@@ -40,7 +43,7 @@ export const withSegmentDefaults =
|
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
const addRootLayoutProps = async (componentProps: RootLayoutProps) => {
|
|
43
|
-
const params = componentProps.params;
|
|
46
|
+
const params = await componentProps.params;
|
|
44
47
|
|
|
45
48
|
if (
|
|
46
49
|
params.commerce !== encodeURIComponent(decodeURI(settings.commerceUrl)) ||
|
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": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"set-cookie-parser": "2.6.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@akinon/eslint-plugin-projectzero": "2.0.0-beta.
|
|
33
|
+
"@akinon/eslint-plugin-projectzero": "2.0.0-beta.1",
|
|
34
34
|
"@types/react-redux": "7.1.30",
|
|
35
35
|
"@types/set-cookie-parser": "2.4.7",
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "
|
|
37
|
-
"@typescript-eslint/parser": "
|
|
38
|
-
"eslint": "
|
|
39
|
-
"eslint-config-next": "
|
|
40
|
-
"eslint-config-prettier": "
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "8.18.2",
|
|
37
|
+
"@typescript-eslint/parser": "8.18.2",
|
|
38
|
+
"eslint": "9.17.0",
|
|
39
|
+
"eslint-config-next": "15.1.2",
|
|
40
|
+
"eslint-config-prettier": "9.1.0"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/types/index.ts
CHANGED
|
@@ -239,8 +239,8 @@ export type ImageOptions = CDNOptions & {
|
|
|
239
239
|
export type Translations = { [key: string]: object };
|
|
240
240
|
|
|
241
241
|
export interface PageProps<T = any> {
|
|
242
|
-
params: T & { locale: string; currency: string }
|
|
243
|
-
searchParams: URLSearchParams
|
|
242
|
+
params: Promise<T & { locale: string; currency: string }>;
|
|
243
|
+
searchParams: Promise<URLSearchParams>;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
export interface LayoutProps<T = any> extends PageProps<T> {
|
package/utils/app-fetch.ts
CHANGED
|
@@ -26,8 +26,8 @@ const appFetch = async <T>({
|
|
|
26
26
|
let ip = '';
|
|
27
27
|
|
|
28
28
|
try {
|
|
29
|
-
const nextHeaders = headers();
|
|
30
|
-
const nextCookies = cookies();
|
|
29
|
+
const nextHeaders = await headers();
|
|
30
|
+
const nextCookies = await cookies();
|
|
31
31
|
ip = nextHeaders.get('x-forwarded-for') ?? '';
|
|
32
32
|
|
|
33
33
|
const commerceUrl = Settings.commerceUrl;
|
package/utils/redirect.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { headers } from 'next/headers';
|
|
|
4
4
|
import { ServerVariables } from '@akinon/next/utils/server-variables';
|
|
5
5
|
import { getUrlPathWithLocale } from '@akinon/next/utils/localization';
|
|
6
6
|
|
|
7
|
-
export const redirect = (path: string, type?: RedirectType) => {
|
|
8
|
-
const nextHeaders = headers();
|
|
7
|
+
export const redirect = async (path: string, type?: RedirectType) => {
|
|
8
|
+
const nextHeaders = await headers();
|
|
9
9
|
const pageUrl = new URL(
|
|
10
10
|
nextHeaders.get('pz-url') ?? process.env.NEXT_PUBLIC_URL
|
|
11
11
|
);
|