@akinon/next 1.89.0 → 1.91.0-rc.0

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.
@@ -5,6 +5,7 @@ import { ROUTES } from 'routes';
5
5
  import type { Middleware } from '@reduxjs/toolkit';
6
6
  import {
7
7
  errorMiddleware,
8
+ redirectUrlMiddleware,
8
9
  contextListMiddleware,
9
10
  hepsiPayMiddleware,
10
11
  walletPaymentMiddleware
@@ -50,6 +51,7 @@ const middlewares = [
50
51
  rtkQueryResponseHandler,
51
52
  rtkQueryErrorHandler,
52
53
  errorMiddleware,
54
+ redirectUrlMiddleware,
53
55
  ...preOrderMiddlewares,
54
56
  contextListMiddleware,
55
57
  hepsiPayMiddleware,
@@ -40,6 +40,7 @@ export interface CheckoutState {
40
40
  shippingOptions: ShippingOption[];
41
41
  dataSourceShippingOptions: DataSource[];
42
42
  paymentOptions: PaymentOption[];
43
+ unavailablePaymentOptions: PaymentOption[];
43
44
  creditPaymentOptions: CheckoutCreditPaymentOption[];
44
45
  selectedCreditPaymentPk: number;
45
46
  paymentChoices: PaymentChoice[];
@@ -94,6 +95,7 @@ const initialState: CheckoutState = {
94
95
  shippingOptions: [],
95
96
  dataSourceShippingOptions: [],
96
97
  paymentOptions: [],
98
+ unavailablePaymentOptions: [],
97
99
  creditPaymentOptions: [],
98
100
  selectedCreditPaymentPk: null,
99
101
  paymentChoices: [],
@@ -157,6 +159,9 @@ const checkoutSlice = createSlice({
157
159
  setPaymentOptions(state, { payload }) {
158
160
  state.paymentOptions = payload;
159
161
  },
162
+ setUnavailablePaymentOptions(state, { payload }) {
163
+ state.unavailablePaymentOptions = payload;
164
+ },
160
165
  setPaymentChoices(state, { payload }) {
161
166
  state.paymentChoices = payload;
162
167
  },
@@ -218,9 +223,10 @@ export const {
218
223
  setShippingOptions,
219
224
  setDataSourceShippingOptions,
220
225
  setPaymentOptions,
226
+ setUnavailablePaymentOptions,
227
+ setPaymentChoices,
221
228
  setCreditPaymentOptions,
222
229
  setSelectedCreditPaymentPk,
223
- setPaymentChoices,
224
230
  setCardType,
225
231
  setInstallmentOptions,
226
232
  setBankAccounts,
@@ -114,6 +114,7 @@ export interface Order {
114
114
  pk: number;
115
115
  name: string;
116
116
  slug: string;
117
+ logo: string;
117
118
  [key: string]: any;
118
119
  };
119
120
  }
@@ -43,12 +43,12 @@ const appFetch = async <T>({
43
43
  const requestURL = `${decodeURIComponent(commerceUrl)}${url}`;
44
44
 
45
45
  init.headers = {
46
+ cookie: nextCookies.toString(),
46
47
  ...(init.headers ?? {}),
47
48
  ...(ServerVariables.globalHeaders ?? {}),
48
49
  'Accept-Language': currentLocale.apiValue,
49
50
  'x-currency': currency,
50
- 'x-forwarded-for': ip,
51
- cookie: nextCookies.toString()
51
+ 'x-forwarded-for': ip
52
52
  };
53
53
 
54
54
  init.next = {
package/utils/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import settings from 'settings';
2
2
  import { LocaleUrlStrategy } from '../localization';
3
- import { CDNOptions, ClientRequestOptions, Locale } from '../types';
3
+ import { CDNOptions, ClientRequestOptions } from '../types';
4
4
 
5
5
  export * from './get-currency';
6
6
  export * from './menu-generator';
@@ -155,14 +155,15 @@ export function buildCDNUrl(url: string, config?: CDNOptions) {
155
155
  const { locales, localeUrlStrategy, defaultLocaleValue } =
156
156
  settings.localization;
157
157
 
158
- const isLocaleExcluded = (locale: Locale) =>
159
- ![LocaleUrlStrategy.ShowAllLocales, LocaleUrlStrategy.Subdomain].includes(
160
- localeUrlStrategy
161
- ) && locale.value !== defaultLocaleValue;
162
-
163
158
  export const urlLocaleMatcherRegex = new RegExp(
164
- `^/(${locales
165
- .filter((l) => !isLocaleExcluded(l))
159
+ `^/(${settings.localization.locales
160
+ .filter((l) =>
161
+ ![LocaleUrlStrategy.ShowAllLocales, LocaleUrlStrategy.Subdomain].includes(
162
+ settings.localization.localeUrlStrategy
163
+ )
164
+ ? l.value !== settings.localization.defaultLocaleValue
165
+ : l
166
+ )
166
167
  .map((l) => l.value)
167
168
  .join('|')})(?=/|$)`
168
169
  );
@@ -0,0 +1,35 @@
1
+ import settings from 'settings';
2
+ import { getUrlPathWithLocale } from './localization';
3
+
4
+ type IgnorePath = string | RegExp;
5
+
6
+ const defaultIgnoreList: string[] = [];
7
+
8
+ const extraIgnores: IgnorePath[] = Array.isArray(
9
+ settings.commerceRedirectionIgnoreList
10
+ )
11
+ ? settings.commerceRedirectionIgnoreList.map((path) => {
12
+ if (path === '/users/reset') {
13
+ return /^\/users\/reset\/[^/]+\/[^/]+\/$/;
14
+ }
15
+ return path;
16
+ })
17
+ : [];
18
+
19
+ export function shouldIgnoreRedirect(
20
+ pathname: string,
21
+ locale: string
22
+ ): boolean {
23
+ if (!pathname) return false;
24
+
25
+ const rawIgnoreList: IgnorePath[] = [...defaultIgnoreList, ...extraIgnores];
26
+
27
+ return rawIgnoreList.some((ignorePath) => {
28
+ if (ignorePath instanceof RegExp) {
29
+ return ignorePath.test(pathname);
30
+ }
31
+
32
+ const localized = getUrlPathWithLocale(ignorePath, locale);
33
+ return localized === pathname;
34
+ });
35
+ }