@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 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
File without changes
File without changes
package/bin/pz-postdev.js CHANGED
File without changes
File without changes
File without changes
File without changes
package/bin/pz-predev.js CHANGED
File without changes
File without changes
@@ -17,4 +17,5 @@ export * from './react-portal';
17
17
  export * from './selected-payment-option-view';
18
18
  export * from './trans';
19
19
  export * from './link';
20
- export * from './pagination';
20
+ export * from './pagination';
21
+ export * from './live-commerce';
@@ -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
- interface LinkProps extends NextLinkProps {
10
- children: React.ReactNode;
11
- className?: string;
12
- target?: '_blank' | '_self' | '_parent' | '_top';
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/next",
3
3
  "description": "Core package for Project Zero Next",
4
- "version": "1.25.0-rc.0",
4
+ "version": "1.25.0-rc.1",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -91,4 +91,5 @@ export interface Address {
91
91
  address: string;
92
92
  fax_phone_number: string;
93
93
  image: string;
94
+ [key: string]: any;
94
95
  }
@@ -93,6 +93,7 @@ export interface GetCategoryResponse {
93
93
  search_text: string | null;
94
94
  sorters: SortOption[];
95
95
  special_page: SpecialPageType;
96
+ [key: string]: any;
96
97
  }
97
98
 
98
99
  export type BreadcrumbResultType = {
@@ -54,6 +54,10 @@ export interface Product {
54
54
  modified_date: string;
55
55
  description?: string;
56
56
  quantity: string;
57
+ extra_data: {
58
+ [key: string]: any;
59
+ };
60
+ [key: string]: any;
57
61
  }
58
62
 
59
63
  export interface FavoriteItem {
@@ -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
@@ -59,6 +59,9 @@ const defaultConfig = {
59
59
  }, {})
60
60
  };
61
61
  return config;
62
+ },
63
+ sentry: {
64
+ hideSourceMaps: true
62
65
  }
63
66
  };
64
67