@akinon/next 1.25.0-rc.0 → 1.25.0-rc.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 +26 -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/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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.25.0-rc.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6d4aadb: ZERO-2476: Auto install recommendenent extension
|
|
8
|
+
- e20b27f: ZERO-2454:add otp login
|
|
9
|
+
- e0a945e: ZERO-2494:Add LiveCommerce for managing basket and product actions
|
|
10
|
+
- a4674c6: ZERO-2461: add optional chaining for referrer header and add locale value for redirect url
|
|
11
|
+
- 1ec9775: ZERO-2462:add custom span to logs
|
|
12
|
+
- ab5a493: ZERO-2475:add types [key: string]: any; for unknown attributes
|
|
13
|
+
- 3690d3b: ZERO-2485: Check ESLint peerDependency version
|
|
14
|
+
- 92094d4: ZERO-2477: Update Sentry version and add hideSourceMaps option
|
|
15
|
+
- b4452e9: ZERO-2463: Refactor Sentry initialization and add Sentry DSN option to settings
|
|
16
|
+
- b2da5e4: Revert ZERO-2435
|
|
17
|
+
- d3edd3a: ZERO-2499:add style prop in link component
|
|
18
|
+
- f76f079: ZERO-2493: Add redirect util function
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- da1e501: ZERO-2296: Fix ROUTES import
|
|
23
|
+
- 95510c7: ZERO-2508: Enable rc branch pipeline and add check-publish-version step
|
|
24
|
+
- 2e44646: ZERO-2434: Fix category URL in getCategoryDataHandler function
|
|
25
|
+
- 8c7f5bc: ZERO-2440: Pipeline test
|
|
26
|
+
- Updated dependencies [95510c7]
|
|
27
|
+
- @akinon/eslint-plugin-projectzero@1.25.0-rc.1
|
|
28
|
+
|
|
3
29
|
## 1.25.0-rc.0
|
|
4
30
|
|
|
5
31
|
### 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/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
|
+
};
|