@akinon/next 1.73.0-rc.2 → 1.73.0-rc.4

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,19 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.73.0-rc.4
4
+
5
+ ### Minor Changes
6
+
7
+ - c594b469: ZERO-3078: get saved cards from page context
8
+
9
+ ## 1.73.0-rc.3
10
+
11
+ ### Minor Changes
12
+
13
+ - 5e3333dc: ZERO-3078: get saved cards from page context
14
+ - 7727ae55: ZERO-3073: Refactor basket page to use server-side data fetching and simplify component structure
15
+ - 07b2298e: ZERO-3074: Exclude url schemes to init url without locales
16
+
3
17
  ## 1.73.0-rc.2
4
18
 
5
19
  ### Minor Changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { useLocalization } from '@akinon/next/hooks';
4
4
  import { LocaleUrlStrategy } from '@akinon/next/localization';
5
- import { urlLocaleMatcherRegex } from '@akinon/next/utils';
5
+ import { urlLocaleMatcherRegex, urlSchemes } from '@akinon/next/utils';
6
6
  import NextLink, { LinkProps as NextLinkProps } from 'next/link';
7
7
  import { useMemo } from 'react';
8
8
 
@@ -21,6 +21,13 @@ export const Link = ({ children, href, ...rest }: LinkProps) => {
21
21
  return '#';
22
22
  }
23
23
 
24
+ if (
25
+ typeof href !== 'string' ||
26
+ urlSchemes.some((scheme) => href.startsWith(scheme))
27
+ ) {
28
+ return href;
29
+ }
30
+
24
31
  if (typeof href === 'string' && !href.startsWith('http')) {
25
32
  const pathnameWithoutLocale = href.replace(urlLocaleMatcherRegex, '');
26
33
  const hrefWithLocale = `/${locale}${pathnameWithoutLocale}`;
@@ -0,0 +1,72 @@
1
+ import { Cache, CacheKey } from '../../lib/cache';
2
+ import { basket } from '../../data/urls';
3
+ import { Basket } from '../../types';
4
+ import appFetch from '../../utils/app-fetch';
5
+ import { ServerVariables } from '../../utils/server-variables';
6
+ import logger from '../../utils/log';
7
+
8
+ type GetBasketParams = {
9
+ locale?: string;
10
+ currency?: string;
11
+ namespace?: string;
12
+ };
13
+
14
+ const getBasketDataHandler = ({
15
+ locale,
16
+ currency,
17
+ namespace
18
+ }: GetBasketParams) => {
19
+ return async function () {
20
+ try {
21
+ const url = namespace
22
+ ? basket.getBasketDetail(namespace)
23
+ : basket.getBasket;
24
+
25
+ const basketData = await appFetch<{ basket: Basket }>({
26
+ url,
27
+ locale,
28
+ currency,
29
+ init: {
30
+ headers: {
31
+ Accept: 'application/json',
32
+ 'Content-Type': 'application/json'
33
+ }
34
+ }
35
+ });
36
+
37
+ if (!basketData?.basket) {
38
+ logger.warn('Basket data is undefined', {
39
+ handler: 'getBasketDataHandler',
40
+ namespace
41
+ });
42
+ }
43
+
44
+ return basketData;
45
+ } catch (error) {
46
+ logger.error('Error fetching basket data', {
47
+ handler: 'getBasketDataHandler',
48
+ error,
49
+ namespace
50
+ });
51
+ throw error;
52
+ }
53
+ };
54
+ };
55
+
56
+ export const getBasketData = async ({
57
+ locale = ServerVariables.locale,
58
+ currency = ServerVariables.currency,
59
+ namespace
60
+ }: GetBasketParams = {}) => {
61
+ return Cache.wrap(
62
+ CacheKey.Basket(namespace),
63
+ locale,
64
+ getBasketDataHandler({ locale, currency, namespace }),
65
+ {
66
+ expire: 0,
67
+ cache: false
68
+ }
69
+ );
70
+ };
71
+
72
+
package/lib/cache.ts CHANGED
@@ -31,6 +31,8 @@ export const CacheKey = {
31
31
  `category_${pk}_${encodeURIComponent(
32
32
  JSON.stringify(searchParams)
33
33
  )}${hashCacheKey(headers)}`,
34
+ Basket: (namespace?: string) => `basket${namespace ? `_${namespace}` : ''}`,
35
+ AllBaskets: () => 'all_baskets',
34
36
  CategorySlug: (slug: string) => `category_${slug}`,
35
37
  SpecialPage: (
36
38
  pk: number,
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.73.0-rc.2",
4
+ "version": "1.73.0-rc.4",
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.73.0-rc.2",
33
+ "@akinon/eslint-plugin-projectzero": "1.73.0-rc.4",
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
@@ -26,8 +26,8 @@ declare module '@akinon/pz-otp/src/redux/reducer' {
26
26
 
27
27
  declare module '@akinon/pz-saved-card' {
28
28
  export const savedCardReducer: any;
29
+ export const savedCardMiddleware: any;
29
30
  export const SavedCardOption: any;
30
- export const savedCardReducer: any;
31
31
  }
32
32
 
33
33
  declare module '@akinon/pz-iyzico-saved-card' {
@@ -13,6 +13,9 @@ import {
13
13
  import { api } from '../../data/client/api';
14
14
  import logger from '@akinon/next/utils/log';
15
15
 
16
+ // Plugin middlewares
17
+ import { savedCardMiddleware } from '@akinon/pz-saved-card';
18
+
16
19
  export const rtkQueryResponseHandler: Middleware =
17
20
  ({ dispatch }) =>
18
21
  (next) =>
@@ -48,7 +51,8 @@ const middlewares = [
48
51
  preOrderMiddleware,
49
52
  contextListMiddleware,
50
53
  hepsiPayMiddleware,
51
- walletPaymentMiddleware
54
+ walletPaymentMiddleware,
55
+ savedCardMiddleware
52
56
  ];
53
57
 
54
58
  export default middlewares;
package/utils/index.ts CHANGED
@@ -174,3 +174,37 @@ export const getPosError = () => {
174
174
 
175
175
  return error;
176
176
  };
177
+
178
+ export const urlSchemes = [
179
+ 'http',
180
+ 'tel:',
181
+ 'mailto:',
182
+ 'sms:',
183
+ 'whatsapp:',
184
+ 'skype:',
185
+ 'ftp:',
186
+ 'file:',
187
+ '//',
188
+ '#',
189
+ 'viber:',
190
+ 'tg:',
191
+ 'slack:',
192
+ 'data:',
193
+ 'market:',
194
+ 'intent:',
195
+ 'webcal:',
196
+ 'geo:',
197
+ 'maps:',
198
+ 'news:',
199
+ 'facetime:',
200
+ 'facetime-audio:',
201
+ 'spotify:',
202
+ 'steam:',
203
+ 'ms-settings:',
204
+ 'zoommtg:',
205
+ 'zoomus:',
206
+ 'blob:',
207
+ 'wss:',
208
+ 'sftp:',
209
+ 'magnet:'
210
+ ] as const;