@akinon/next 1.25.0-rc.0 → 1.25.0-rc.2
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 +36 -0
- package/bin/pz-install-plugins.js +0 -0
- package/bin/pz-install-theme.js +0 -0
- package/bin/pz-postbuild.js +0 -0
- package/bin/pz-postdev.js +0 -0
- package/bin/pz-postinstall.js +0 -0
- package/bin/pz-poststart.js +0 -0
- package/bin/pz-prebuild.js +0 -0
- package/bin/pz-predev.js +0 -0
- package/bin/pz-prestart.js +0 -0
- package/components/index.ts +2 -1
- package/components/link.tsx +7 -18
- package/components/live-commerce.tsx +42 -0
- package/middlewares/default.ts +6 -0
- package/package.json +1 -1
- package/types/commerce/address.ts +1 -0
- package/types/commerce/category.ts +1 -0
- package/types/commerce/product.ts +4 -0
- package/utils/redirect.ts +30 -0
- package/with-pz-config.js +3 -0
- package/components/redirect-three-d/content/index.tsx +0 -74
- package/components/redirect-three-d/index.tsx +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.25.0-rc.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7e41bdc: BRDG-9158: Remove redirect-three-d page endpoint
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- @akinon/eslint-plugin-projectzero@1.25.0-rc.2
|
|
12
|
+
|
|
13
|
+
## 1.25.0-rc.1
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 6d4aadb: ZERO-2476: Auto install recommendenent extension
|
|
18
|
+
- e20b27f: ZERO-2454:add otp login
|
|
19
|
+
- e0a945e: ZERO-2494:Add LiveCommerce for managing basket and product actions
|
|
20
|
+
- a4674c6: ZERO-2461: add optional chaining for referrer header and add locale value for redirect url
|
|
21
|
+
- 1ec9775: ZERO-2462:add custom span to logs
|
|
22
|
+
- ab5a493: ZERO-2475:add types [key: string]: any; for unknown attributes
|
|
23
|
+
- 3690d3b: ZERO-2485: Check ESLint peerDependency version
|
|
24
|
+
- 92094d4: ZERO-2477: Update Sentry version and add hideSourceMaps option
|
|
25
|
+
- b4452e9: ZERO-2463: Refactor Sentry initialization and add Sentry DSN option to settings
|
|
26
|
+
- b2da5e4: Revert ZERO-2435
|
|
27
|
+
- d3edd3a: ZERO-2499:add style prop in link component
|
|
28
|
+
- f76f079: ZERO-2493: Add redirect util function
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- da1e501: ZERO-2296: Fix ROUTES import
|
|
33
|
+
- 95510c7: ZERO-2508: Enable rc branch pipeline and add check-publish-version step
|
|
34
|
+
- 2e44646: ZERO-2434: Fix category URL in getCategoryDataHandler function
|
|
35
|
+
- 8c7f5bc: ZERO-2440: Pipeline test
|
|
36
|
+
- Updated dependencies [95510c7]
|
|
37
|
+
- @akinon/eslint-plugin-projectzero@1.25.0-rc.1
|
|
38
|
+
|
|
3
39
|
## 1.25.0-rc.0
|
|
4
40
|
|
|
5
41
|
### Minor Changes
|
|
File without changes
|
package/bin/pz-install-theme.js
CHANGED
|
File without changes
|
package/bin/pz-postbuild.js
CHANGED
|
File without changes
|
package/bin/pz-postdev.js
CHANGED
|
File without changes
|
package/bin/pz-postinstall.js
CHANGED
|
File without changes
|
package/bin/pz-poststart.js
CHANGED
|
File without changes
|
package/bin/pz-prebuild.js
CHANGED
|
File without changes
|
package/bin/pz-predev.js
CHANGED
|
File without changes
|
package/bin/pz-prestart.js
CHANGED
|
File without changes
|
package/components/index.ts
CHANGED
package/components/link.tsx
CHANGED
|
@@ -6,19 +6,13 @@ import { urlLocaleMatcherRegex } from '@akinon/next/utils';
|
|
|
6
6
|
import NextLink, { LinkProps as NextLinkProps } from 'next/link';
|
|
7
7
|
import { useEffect, useState } from 'react';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
type LinkProps = Omit<
|
|
10
|
+
React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
11
|
+
keyof NextLinkProps
|
|
12
|
+
> &
|
|
13
|
+
NextLinkProps;
|
|
14
14
|
|
|
15
|
-
export const Link = ({
|
|
16
|
-
children,
|
|
17
|
-
target,
|
|
18
|
-
className,
|
|
19
|
-
href,
|
|
20
|
-
...rest
|
|
21
|
-
}: LinkProps) => {
|
|
15
|
+
export const Link = ({ children, href, ...rest }: LinkProps) => {
|
|
22
16
|
const { locale, defaultLocaleValue, localeUrlStrategy } = useLocalization();
|
|
23
17
|
const [formattedHref, setFormattedHref] = useState(href ?? '#');
|
|
24
18
|
|
|
@@ -40,12 +34,7 @@ export const Link = ({
|
|
|
40
34
|
}, [href, defaultLocaleValue, locale, localeUrlStrategy]);
|
|
41
35
|
|
|
42
36
|
return (
|
|
43
|
-
<NextLink
|
|
44
|
-
href={formattedHref}
|
|
45
|
-
target={target}
|
|
46
|
-
className={className}
|
|
47
|
-
{...rest}
|
|
48
|
-
>
|
|
37
|
+
<NextLink href={formattedHref} {...rest}>
|
|
49
38
|
{children}
|
|
50
39
|
</NextLink>
|
|
51
40
|
);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { memo, useEffect } from 'react';
|
|
4
|
+
import { useAppDispatch } from '@akinon/next/redux/hooks';
|
|
5
|
+
import { useAddProductMutation } from '../data/client/product';
|
|
6
|
+
import { basketApi } from '@akinon/next/data/client/basket';
|
|
7
|
+
import { useGetBasketQuery } from '@akinon/next/data/client/basket';
|
|
8
|
+
|
|
9
|
+
export const LiveCommerce = memo(function Callback() {
|
|
10
|
+
const dispatch = useAppDispatch();
|
|
11
|
+
const { refetch: refetchBasketData } = useGetBasketQuery();
|
|
12
|
+
const [addProduct] = useAddProductMutation();
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
document.addEventListener('refresh-basket', () => refetchBasketData());
|
|
16
|
+
|
|
17
|
+
document.addEventListener('add-to-cart', async (e: CustomEvent) => {
|
|
18
|
+
const productData = e.detail.data;
|
|
19
|
+
|
|
20
|
+
await addProduct({
|
|
21
|
+
product: productData.product,
|
|
22
|
+
quantity: productData.quantity,
|
|
23
|
+
attributes: productData.attributes
|
|
24
|
+
})
|
|
25
|
+
.unwrap()
|
|
26
|
+
.then((data) =>
|
|
27
|
+
dispatch(
|
|
28
|
+
basketApi.util.updateQueryData(
|
|
29
|
+
'getBasket',
|
|
30
|
+
undefined,
|
|
31
|
+
(draftBasket) => {
|
|
32
|
+
Object.assign(draftBasket, data.basket);
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
return null;
|
|
42
|
+
});
|
package/middlewares/default.ts
CHANGED
|
@@ -97,6 +97,12 @@ const withPzDefault =
|
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
if (req.nextUrl.pathname.startsWith('/orders/redirect-three-d')) {
|
|
101
|
+
return NextResponse.rewrite(
|
|
102
|
+
new URL(`${encodeURI(Settings.commerceUrl)}/orders/redirect-three-d/`)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
100
106
|
// If commerce redirects to /orders/checkout/ without locale
|
|
101
107
|
if (
|
|
102
108
|
req.nextUrl.pathname.match(new RegExp('^/orders/checkout/$')) &&
|
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { redirect as nextRedirect, RedirectType } from 'next/navigation';
|
|
2
|
+
import Settings from 'settings';
|
|
3
|
+
import { headers } from 'next/headers';
|
|
4
|
+
import { ServerVariables } from '@akinon/next/utils/server-variables';
|
|
5
|
+
import { getUrlPathWithLocale } from '@akinon/next/utils/localization';
|
|
6
|
+
|
|
7
|
+
export const redirect = (path: string, type?: RedirectType) => {
|
|
8
|
+
const nextHeaders = headers();
|
|
9
|
+
const pageUrl = new URL(
|
|
10
|
+
nextHeaders.get('pz-url') ?? process.env.NEXT_PUBLIC_URL
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const currentLocale = Settings.localization.locales.find(
|
|
14
|
+
(locale) => locale.value === ServerVariables.locale
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const callbackUrl = pageUrl.pathname;
|
|
18
|
+
const redirectUrlWithLocale = getUrlPathWithLocale(
|
|
19
|
+
path,
|
|
20
|
+
currentLocale.localePath ?? currentLocale.value
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const redirectUrl = `${redirectUrlWithLocale}?callbackUrl=${callbackUrl}`;
|
|
24
|
+
|
|
25
|
+
if (type) {
|
|
26
|
+
return nextRedirect(redirectUrl, type);
|
|
27
|
+
} else {
|
|
28
|
+
return nextRedirect(redirectUrl);
|
|
29
|
+
}
|
|
30
|
+
};
|
package/with-pz-config.js
CHANGED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
import { ROUTES } from 'routes';
|
|
5
|
-
import { useGet3dRedirectFormQuery } from '@akinon/next/data/client/checkout';
|
|
6
|
-
import { LoaderSpinner } from 'components';
|
|
7
|
-
import { useLocalization } from '../../../hooks/use-localization';
|
|
8
|
-
import { getUrlPathWithLocale } from '../../../utils/localization';
|
|
9
|
-
import { useSearchParams } from 'next/navigation';
|
|
10
|
-
|
|
11
|
-
interface RedirectThreeDContentProps {
|
|
12
|
-
sessionId: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default function RedirectThreeDContent({
|
|
16
|
-
sessionId
|
|
17
|
-
}: RedirectThreeDContentProps) {
|
|
18
|
-
const searchParams = useSearchParams();
|
|
19
|
-
const { data } = useGet3dRedirectFormQuery();
|
|
20
|
-
const [error, setError] = useState(null);
|
|
21
|
-
const { locale } = useLocalization();
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (data) {
|
|
25
|
-
const fragment = document.createElement('fragment');
|
|
26
|
-
fragment.innerHTML = data.result;
|
|
27
|
-
|
|
28
|
-
const form = fragment.querySelector('form');
|
|
29
|
-
|
|
30
|
-
// a way to determine if response includes a redirection form or not
|
|
31
|
-
if (fragment.querySelector('link[rel="canonical"]') || !form) {
|
|
32
|
-
setError('Redirecting to checkout page. Please wait...');
|
|
33
|
-
|
|
34
|
-
setTimeout(() => {
|
|
35
|
-
let checkoutUrl = `${ROUTES.CHECKOUT}`;
|
|
36
|
-
|
|
37
|
-
// iframe param is used to prevent header and footer rendering
|
|
38
|
-
if (searchParams.get('iframe') === 'true') {
|
|
39
|
-
checkoutUrl = `${checkoutUrl}?iframe=true`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Use `window.location.href` instead of `router.push`
|
|
43
|
-
// to capture the url change event in iframe
|
|
44
|
-
location.href = getUrlPathWithLocale(checkoutUrl, locale);
|
|
45
|
-
}, 3000);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const pzParamsInput = document.createElement('input');
|
|
50
|
-
pzParamsInput.setAttribute('type', 'hidden');
|
|
51
|
-
pzParamsInput.setAttribute('name', 'pzparams');
|
|
52
|
-
pzParamsInput.setAttribute(
|
|
53
|
-
'value',
|
|
54
|
-
encodeURIComponent(
|
|
55
|
-
JSON.stringify({
|
|
56
|
-
session: sessionId,
|
|
57
|
-
locale
|
|
58
|
-
})
|
|
59
|
-
)
|
|
60
|
-
);
|
|
61
|
-
form.appendChild(pzParamsInput);
|
|
62
|
-
|
|
63
|
-
form.style.display = 'none';
|
|
64
|
-
document.body.appendChild(form);
|
|
65
|
-
form.submit();
|
|
66
|
-
}
|
|
67
|
-
}, [data]);
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<div className="flex items-center justify-center py-20">
|
|
71
|
-
{error ?? <LoaderSpinner />}
|
|
72
|
-
</div>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { cookies } from 'next/headers';
|
|
2
|
-
import { redirect } from 'next/navigation';
|
|
3
|
-
import RedirectThreeDContent from './content';
|
|
4
|
-
import { ROUTES } from 'routes';
|
|
5
|
-
|
|
6
|
-
const RedirectThreeD = async () => {
|
|
7
|
-
const nextCookies = cookies();
|
|
8
|
-
const sessionId = await nextCookies.get('osessionid')?.value;
|
|
9
|
-
|
|
10
|
-
if (!sessionId) {
|
|
11
|
-
return redirect(ROUTES.CHECKOUT);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return <RedirectThreeDContent sessionId={sessionId} />;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default RedirectThreeD;
|