@akinon/next 1.60.0 → 1.61.0-rc.23

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +668 -0
  2. package/api/client.ts +23 -2
  3. package/assets/styles/index.css +49 -0
  4. package/assets/styles/index.css.map +1 -0
  5. package/assets/styles/index.scss +50 -26
  6. package/bin/pz-generate-translations.js +41 -0
  7. package/bin/pz-install-plugins.js +0 -0
  8. package/bin/pz-install-theme.js +0 -0
  9. package/bin/pz-postbuild.js +0 -0
  10. package/bin/pz-postdev.js +0 -0
  11. package/bin/pz-postinstall.js +0 -0
  12. package/bin/pz-poststart.js +0 -0
  13. package/bin/pz-prebuild.js +1 -0
  14. package/bin/pz-predev.js +1 -0
  15. package/bin/pz-prestart.js +0 -0
  16. package/components/file-input.tsx +8 -0
  17. package/components/index.ts +1 -0
  18. package/components/input.tsx +21 -7
  19. package/components/link.tsx +17 -13
  20. package/components/plugin-module.tsx +8 -3
  21. package/components/price.tsx +11 -4
  22. package/components/pz-root.tsx +15 -3
  23. package/components/selected-payment-option-view.tsx +2 -1
  24. package/data/client/account.ts +3 -2
  25. package/data/client/api.ts +1 -1
  26. package/data/client/b2b.ts +35 -2
  27. package/data/client/basket.ts +6 -5
  28. package/data/client/checkout.ts +55 -10
  29. package/data/client/user.ts +3 -2
  30. package/data/server/category.ts +39 -19
  31. package/data/server/flatpage.ts +29 -7
  32. package/data/server/form.ts +29 -11
  33. package/data/server/landingpage.ts +26 -7
  34. package/data/server/list.ts +12 -6
  35. package/data/server/menu.ts +15 -2
  36. package/data/server/product.ts +29 -12
  37. package/data/server/seo.ts +17 -24
  38. package/data/server/special-page.ts +10 -5
  39. package/data/server/widget.ts +14 -7
  40. package/data/urls.ts +17 -4
  41. package/hocs/server/with-segment-defaults.tsx +4 -1
  42. package/hooks/index.ts +2 -1
  43. package/hooks/use-message-listener.ts +24 -0
  44. package/hooks/use-pagination.ts +2 -2
  45. package/hooks/use-payment-options.ts +2 -1
  46. package/lib/cache.ts +4 -6
  47. package/middlewares/complete-gpay.ts +1 -1
  48. package/middlewares/complete-masterpass.ts +1 -1
  49. package/middlewares/currency.ts +1 -0
  50. package/middlewares/default.ts +226 -167
  51. package/middlewares/index.ts +3 -1
  52. package/middlewares/oauth-login.ts +6 -1
  53. package/middlewares/pretty-url.ts +7 -1
  54. package/middlewares/saved-card-redirection.ts +179 -0
  55. package/middlewares/three-d-redirection.ts +1 -1
  56. package/middlewares/url-redirection.ts +14 -2
  57. package/package.json +2 -2
  58. package/plugins.d.ts +6 -0
  59. package/plugins.js +2 -1
  60. package/redux/middlewares/checkout.ts +77 -13
  61. package/redux/reducers/checkout.ts +23 -3
  62. package/redux/reducers/index.ts +3 -1
  63. package/routes/pretty-url.tsx +7 -9
  64. package/types/commerce/address.ts +1 -1
  65. package/types/commerce/b2b.ts +12 -2
  66. package/types/commerce/checkout.ts +31 -0
  67. package/types/commerce/order.ts +1 -0
  68. package/types/index.ts +15 -1
  69. package/utils/app-fetch.ts +15 -7
  70. package/utils/index.ts +27 -6
  71. package/utils/redirection-iframe.ts +85 -0
  72. package/utils/server-translation.ts +11 -1
  73. package/with-pz-config.js +2 -1
@@ -57,6 +57,7 @@ export interface CompleteCreditCardParams {
57
57
  card_month: string;
58
58
  card_year: string;
59
59
  use_three_d?: boolean;
60
+ save?: boolean;
60
61
  }
61
62
 
62
63
  interface GetContractResponse {
@@ -228,7 +229,8 @@ export const checkoutApi = api.injectEndpoints({
228
229
  card_number,
229
230
  card_month,
230
231
  card_year,
231
- use_three_d = true
232
+ use_three_d = true,
233
+ save = undefined
232
234
  }) => {
233
235
  const paymentOption =
234
236
  store.getState().checkout?.preOrder?.payment_option;
@@ -242,20 +244,26 @@ export const checkoutApi = api.injectEndpoints({
242
244
  };
243
245
  }
244
246
 
247
+ const body: Record<string, string> = {
248
+ agreement: '1',
249
+ use_three_d: use_three_d ? '1' : '0',
250
+ card_cvv,
251
+ card_holder,
252
+ card_month,
253
+ card_number,
254
+ card_year
255
+ };
256
+
257
+ if (save !== undefined) {
258
+ body.save = save ? '1' : '0';
259
+ }
260
+
245
261
  return {
246
262
  url: buildClientRequestUrl(checkout.completeCreditCardPayment, {
247
263
  useFormData: true
248
264
  }),
249
265
  method: 'POST',
250
- body: {
251
- agreement: '1',
252
- use_three_d: use_three_d ? '1' : '0',
253
- card_cvv,
254
- card_holder,
255
- card_month,
256
- card_number,
257
- card_year
258
- }
266
+ body
259
267
  };
260
268
  },
261
269
  async onQueryStarted(args, { dispatch, queryFulfilled }) {
@@ -380,6 +388,22 @@ export const checkoutApi = api.injectEndpoints({
380
388
  dispatch(setShippingStepBusy(false));
381
389
  }
382
390
  }),
391
+ setDataSourceShippingOptions: build.mutation<CheckoutResponse, number[]>({
392
+ query: (pks) => ({
393
+ url: buildClientRequestUrl(checkout.setDataSourceShippingOption, {
394
+ useFormData: true
395
+ }),
396
+ method: 'POST',
397
+ body: {
398
+ data_source_shipping_options: JSON.stringify(pks)
399
+ }
400
+ }),
401
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
402
+ dispatch(setShippingStepBusy(true));
403
+ await queryFulfilled;
404
+ dispatch(setShippingStepBusy(false));
405
+ }
406
+ }),
383
407
  setRetailStore: build.mutation<CheckoutResponse, SetRetailStoreParams>({
384
408
  query: ({ retailStorePk, billingAddressPk }) => ({
385
409
  url: buildClientRequestUrl(
@@ -681,6 +705,25 @@ export const checkoutApi = api.injectEndpoints({
681
705
  };
682
706
  }
683
707
  }),
708
+ setAttributeBasedShippingOptions: build.mutation<
709
+ CheckoutResponse,
710
+ Record<string, number>
711
+ >({
712
+ query: (options) => ({
713
+ url: buildClientRequestUrl(checkout.setAttributeBasedShippingOption, {
714
+ useFormData: true
715
+ }),
716
+ method: 'POST',
717
+ body: {
718
+ attribute_based_shipping_options: JSON.stringify(options)
719
+ }
720
+ }),
721
+ async onQueryStarted(arg, { dispatch, queryFulfilled }) {
722
+ dispatch(setShippingStepBusy(true));
723
+ await queryFulfilled;
724
+ dispatch(setShippingStepBusy(false));
725
+ }
726
+ }),
684
727
  setOrderSelectionPage: build.mutation<
685
728
  CheckoutResponse,
686
729
  { extra_field: ExtraField }
@@ -712,6 +755,7 @@ export const {
712
755
  useSetDeliveryOptionMutation,
713
756
  useSetAddressesMutation,
714
757
  useSetShippingOptionMutation,
758
+ useSetDataSourceShippingOptionsMutation,
715
759
  useSetPaymentOptionMutation,
716
760
  useSetBinNumberMutation,
717
761
  useSetInstallmentOptionMutation,
@@ -730,5 +774,6 @@ export const {
730
774
  usePayWithLoyaltyBalanceMutation,
731
775
  useSetOrderNoteMutation,
732
776
  useSetDeliveryBagsMutation,
777
+ useSetAttributeBasedShippingOptionsMutation,
733
778
  useSetOrderSelectionPageMutation
734
779
  } = checkoutApi;
@@ -22,11 +22,12 @@ const userApi = api.injectEndpoints({
22
22
  getCaptcha: build.query<GetCaptchaResponse, void>({
23
23
  query: () => buildClientRequestUrl(user.captcha),
24
24
  transformResponse: (response: { html: string }) => {
25
- const siteKeyMatch = response.html.match(/sitekey=["|'][^"']+/gi);
25
+ const siteKey = response.html.match(/data-sitekey="([^"]+)"/i)[1];
26
+
26
27
  const csrfTokenMatch = response.html.match(
27
28
  /name=['|"]csrfmiddlewaretoken['|"] value=['|"][^'"]+/gi
28
29
  );
29
- const siteKey = siteKeyMatch?.[0].replace(/sitekey=["|']/, '') || '';
30
+
30
31
  const csrfToken =
31
32
  csrfTokenMatch?.[0].replace(
32
33
  /name=['|"]csrfmiddlewaretoken['|"] value=['|"]/gi,
@@ -5,6 +5,8 @@ import { category, product } from '../urls';
5
5
  import { Cache, CacheKey } from '../../lib/cache';
6
6
  import { parse } from 'lossless-json';
7
7
  import logger from '../../utils/log';
8
+ import { headers as nHeaders } from 'next/headers';
9
+ import { ServerVariables } from '../../utils/server-variables';
8
10
 
9
11
  function getCategoryDataHandler(
10
12
  pk: number,
@@ -14,17 +16,19 @@ function getCategoryDataHandler(
14
16
  return async function () {
15
17
  const params = generateCommerceSearchParams(searchParams);
16
18
 
17
- const rawData = await appFetch<string>(
18
- `${category.getCategoryByPk(pk)}${params ? params : ''}`,
19
- {
19
+ const rawData = await appFetch<string>({
20
+ url: `${category.getCategoryByPk(pk)}${params ? params : ''}`,
21
+ locale,
22
+ currency,
23
+ init: {
20
24
  headers: {
21
25
  Accept: 'application/json',
22
26
  'Content-Type': 'application/json',
23
27
  ...(headers ?? {})
24
28
  }
25
29
  },
26
- FetchResponseType.TEXT
27
- );
30
+ responseType: FetchResponseType.TEXT
31
+ });
28
32
 
29
33
  let data: GetCategoryResponse;
30
34
 
@@ -58,15 +62,17 @@ function getCategoryDataHandler(
58
62
  return { data, breadcrumbData: undefined };
59
63
  }
60
64
 
61
- const breadcrumbData = await appFetch<any>(
62
- product.breadcrumbUrl(menuItemModel),
63
- {
65
+ const breadcrumbData = await appFetch<any>({
66
+ url: product.breadcrumbUrl(menuItemModel),
67
+ locale,
68
+ currency,
69
+ init: {
64
70
  headers: {
65
71
  Accept: 'application/json',
66
72
  'Content-Type': 'application/json'
67
73
  }
68
74
  }
69
- );
75
+ });
70
76
 
71
77
  return { data, breadcrumbData: breadcrumbData?.menu };
72
78
  };
@@ -75,7 +81,9 @@ function getCategoryDataHandler(
75
81
  export const getCategoryData = ({
76
82
  pk,
77
83
  searchParams,
78
- headers
84
+ headers,
85
+ locale = ServerVariables.locale,
86
+ currency = ServerVariables.currency
79
87
  }: {
80
88
  pk: number;
81
89
  searchParams?: URLSearchParams;
@@ -83,25 +91,32 @@ export const getCategoryData = ({
83
91
  }) => {
84
92
  return Cache.wrap(
85
93
  CacheKey.Category(pk, searchParams, headers),
86
- getCategoryDataHandler(pk, searchParams, headers),
94
+ locale,
95
+ getCategoryDataHandler(pk, locale, currency, searchParams, headers),
87
96
  {
88
97
  expire: 300
89
98
  }
90
99
  );
91
100
  };
92
101
 
93
- function getCategoryBySlugDataHandler(slug: string) {
102
+ function getCategoryBySlugDataHandler(
103
+ slug: string,
104
+ locale: string,
105
+ currency: string
106
+ ) {
94
107
  return async function () {
95
- const rawData = await appFetch<string>(
96
- category.getCategoryBySlug(slug),
97
- {
108
+ const rawData = await appFetch<string>({
109
+ url: category.getCategoryBySlug(slug),
110
+ locale,
111
+ currency,
112
+ init: {
98
113
  headers: {
99
114
  Accept: 'application/json',
100
115
  'Content-Type': 'application/json'
101
116
  }
102
117
  },
103
- FetchResponseType.TEXT
104
- );
118
+ responseType: FetchResponseType.TEXT
119
+ });
105
120
 
106
121
  let data: GetCategoryResponse;
107
122
 
@@ -129,10 +144,15 @@ function getCategoryBySlugDataHandler(slug: string) {
129
144
  };
130
145
  }
131
146
 
132
- export const getCategoryBySlugData = async ({ slug }) => {
147
+ export const getCategoryBySlugData = async ({
148
+ slug,
149
+ locale = ServerVariables.locale,
150
+ currency = ServerVariables.currency
151
+ }) => {
133
152
  return Cache.wrap(
134
153
  CacheKey.CategorySlug(slug),
135
- getCategoryBySlugDataHandler(slug),
154
+ locale,
155
+ getCategoryBySlugDataHandler(slug, locale, currency),
136
156
  {
137
157
  expire: 300
138
158
  }
@@ -2,13 +2,23 @@ import { flatpage } from '../urls';
2
2
  import { FlatPage } from '../../types';
3
3
  import appFetch from '../../utils/app-fetch';
4
4
  import { Cache, CacheKey } from '../../lib/cache';
5
+ import { ServerVariables } from '../../utils/server-variables';
5
6
 
6
- const getFlatPageDataHandler = (pk: number) => {
7
+ const getFlatPageDataHandler = (
8
+ pk: number,
9
+ locale: string,
10
+ currency: string
11
+ ) => {
7
12
  return async function () {
8
- const data = await appFetch<FlatPage>(flatpage.getFlatPageByPk(pk), {
9
- headers: {
10
- Accept: 'application/json',
11
- 'Content-Type': 'application/json'
13
+ const data = await appFetch<FlatPage>({
14
+ url: flatpage.getFlatPageByPk(pk),
15
+ locale,
16
+ currency,
17
+ init: {
18
+ headers: {
19
+ Accept: 'application/json',
20
+ 'Content-Type': 'application/json'
21
+ }
12
22
  }
13
23
  });
14
24
 
@@ -16,6 +26,18 @@ const getFlatPageDataHandler = (pk: number) => {
16
26
  };
17
27
  };
18
28
 
19
- export const getFlatPageData = ({ pk }: { pk: number }) => {
20
- return Cache.wrap(CacheKey.FlatPage(pk), getFlatPageDataHandler(pk));
29
+ export const getFlatPageData = ({
30
+ pk,
31
+ locale = ServerVariables.locale,
32
+ currency = ServerVariables.currency
33
+ }: {
34
+ pk: number;
35
+ locale?: string;
36
+ currency?: string;
37
+ }) => {
38
+ return Cache.wrap(
39
+ CacheKey.FlatPage(pk),
40
+ locale,
41
+ getFlatPageDataHandler(pk, locale, currency)
42
+ );
21
43
  };
@@ -1,15 +1,21 @@
1
- import { Cache, CacheKey } from "../../lib/cache";
2
- import { FormType } from "../../types/commerce/form";
1
+ import { Cache, CacheKey } from '../../lib/cache';
2
+ import { FormType } from '../../types/commerce/form';
3
3
 
4
- import appFetch from "../../utils/app-fetch";
5
- import { form } from "../urls";
4
+ import appFetch from '../../utils/app-fetch';
5
+ import { ServerVariables } from '../../utils/server-variables';
6
+ import { form } from '../urls';
6
7
 
7
- const getFormDataHandler = (pk: number) => {
8
+ const getFormDataHandler = (pk: number, locale: string, currency: string) => {
8
9
  return async function () {
9
- const data = await appFetch<FormType>(form.getForm(pk), {
10
- headers: {
11
- Accept: 'application/json',
12
- 'Content-Type': 'application/json'
10
+ const data = await appFetch<FormType>({
11
+ url: form.getForm(pk),
12
+ locale,
13
+ currency,
14
+ init: {
15
+ headers: {
16
+ Accept: 'application/json',
17
+ 'Content-Type': 'application/json'
18
+ }
13
19
  }
14
20
  });
15
21
 
@@ -17,6 +23,18 @@ const getFormDataHandler = (pk: number) => {
17
23
  };
18
24
  };
19
25
 
20
- export const getFormData = ({ pk }: { pk: number }) => {
21
- return Cache.wrap(CacheKey.Form(pk), getFormDataHandler(pk));
26
+ export const getFormData = ({
27
+ pk,
28
+ locale = ServerVariables.locale,
29
+ currency = ServerVariables.currency
30
+ }: {
31
+ pk: number;
32
+ locale?: string;
33
+ currency?: string;
34
+ }) => {
35
+ return Cache.wrap(
36
+ CacheKey.Form(pk),
37
+ locale,
38
+ getFormDataHandler(pk, locale, currency)
39
+ );
22
40
  };
@@ -2,23 +2,42 @@ import { landingpage } from '../urls';
2
2
  import { LandingPage } from '../../types/commerce/landingpage';
3
3
  import appFetch from '../../utils/app-fetch';
4
4
  import { Cache, CacheKey } from '../../lib/cache';
5
+ import { ServerVariables } from '../../utils/server-variables';
5
6
 
6
- const getLandingPageHandler = (pk: number) => {
7
+ const getLandingPageHandler = (
8
+ pk: number,
9
+ locale: string,
10
+ currency: string
11
+ ) => {
7
12
  return async function () {
8
- const data = await appFetch<LandingPage>(
9
- landingpage.getLandingPageByPk(pk),
10
- {
13
+ const data = await appFetch<LandingPage>({
14
+ url: landingpage.getLandingPageByPk(pk),
15
+ locale,
16
+ currency,
17
+ init: {
11
18
  headers: {
12
19
  Accept: 'application/json',
13
20
  'Content-Type': 'application/json'
14
21
  }
15
22
  }
16
- );
23
+ });
17
24
 
18
25
  return data;
19
26
  };
20
27
  };
21
28
 
22
- export const getLandingPageData = ({ pk }: { pk: number }) => {
23
- return Cache.wrap(CacheKey.LandingPage(pk), getLandingPageHandler(pk));
29
+ export const getLandingPageData = ({
30
+ pk,
31
+ locale = ServerVariables.locale,
32
+ currency = ServerVariables.currency
33
+ }: {
34
+ pk: number;
35
+ locale?: string;
36
+ currency?: string;
37
+ }) => {
38
+ return Cache.wrap(
39
+ CacheKey.LandingPage(pk),
40
+ locale,
41
+ getLandingPageHandler(pk, locale, currency)
42
+ );
24
43
  };
@@ -5,6 +5,7 @@ import { generateCommerceSearchParams } from '../../utils';
5
5
  import appFetch, { FetchResponseType } from '../../utils/app-fetch';
6
6
  import { parse } from 'lossless-json';
7
7
  import logger from '../../utils/log';
8
+ import { ServerVariables } from '../../utils/server-variables';
8
9
 
9
10
  const getListDataHandler = (
10
11
  searchParams: URLSearchParams,
@@ -13,17 +14,19 @@ const getListDataHandler = (
13
14
  return async function () {
14
15
  const params = generateCommerceSearchParams(searchParams);
15
16
 
16
- const rawData = await appFetch<string>(
17
- `${category.list}${params}`,
18
- {
17
+ const rawData = await appFetch<string>({
18
+ url: `${category.list}${params}`,
19
+ locale,
20
+ currency,
21
+ init: {
19
22
  headers: {
20
23
  Accept: 'application/json',
21
24
  'Content-Type': 'application/json',
22
25
  ...(headers ?? {})
23
26
  }
24
27
  },
25
- FetchResponseType.TEXT
26
- );
28
+ responseType: FetchResponseType.TEXT
29
+ });
27
30
 
28
31
  let data: GetCategoryResponse;
29
32
 
@@ -51,6 +54,8 @@ const getListDataHandler = (
51
54
  };
52
55
 
53
56
  export const getListData = async ({
57
+ locale = ServerVariables.locale,
58
+ currency = ServerVariables.currency,
54
59
  searchParams,
55
60
  headers
56
61
  }: {
@@ -59,7 +64,8 @@ export const getListData = async ({
59
64
  }) => {
60
65
  return Cache.wrap(
61
66
  CacheKey.List(searchParams, headers),
62
- getListDataHandler(searchParams, headers),
67
+ locale,
68
+ getListDataHandler(locale, currency, searchParams, headers),
63
69
  {
64
70
  expire: 300
65
71
  }
@@ -1,6 +1,7 @@
1
1
  import { Cache, CacheKey } from '../../lib/cache';
2
2
  import { MenuItemType } from '../../types';
3
3
  import appFetch from '../../utils/app-fetch';
4
+ import { ServerVariables } from '../../utils/server-variables';
4
5
  import { misc } from '../urls';
5
6
 
6
7
  interface MenuResponse {
@@ -8,6 +9,8 @@ interface MenuResponse {
8
9
  }
9
10
 
10
11
  interface MenuHandlerParams {
12
+ locale?: string;
13
+ currency?: string;
11
14
  depth?: number;
12
15
  parent?: string;
13
16
  }
@@ -15,9 +18,18 @@ interface MenuHandlerParams {
15
18
  const DEFAULT_DEPTH = 3;
16
19
 
17
20
  const getMenuHandler =
18
- ({ depth, parent }: MenuHandlerParams = { depth: DEFAULT_DEPTH }) =>
21
+ ({
22
+ locale = ServerVariables.locale,
23
+ currency = ServerVariables.currency,
24
+ depth,
25
+ parent
26
+ }: MenuHandlerParams = {}) =>
19
27
  async () => {
20
- const response = await appFetch<MenuResponse>(misc.menus(depth, parent));
28
+ const response = await appFetch<MenuResponse>({
29
+ url: misc.menus(depth ?? DEFAULT_DEPTH, parent),
30
+ locale,
31
+ currency
32
+ });
21
33
 
22
34
  return response?.menu;
23
35
  };
@@ -30,6 +42,7 @@ const getMenuHandler =
30
42
  export const getMenu = async (params?: MenuHandlerParams) => {
31
43
  return Cache.wrap(
32
44
  CacheKey.Menu(params?.depth ?? DEFAULT_DEPTH, params?.parent),
45
+ params?.locale ?? ServerVariables.locale,
33
46
  getMenuHandler(params)
34
47
  );
35
48
  };
@@ -2,6 +2,7 @@ import { Cache, CacheKey } from '../../lib/cache';
2
2
  import { product } from '../urls';
3
3
  import { ProductCategoryResult, ProductResult } from '../../types';
4
4
  import appFetch from '../../utils/app-fetch';
5
+ import { ServerVariables } from '../../utils/server-variables';
5
6
  import logger from '../../utils/log';
6
7
 
7
8
  type GetProduct = {
@@ -12,6 +13,8 @@ type GetProduct = {
12
13
 
13
14
  const getProductDataHandler = ({
14
15
  pk,
16
+ locale,
17
+ currency,
15
18
  searchParams,
16
19
  groupProduct
17
20
  }: GetProduct) => {
@@ -28,24 +31,31 @@ const getProductDataHandler = ({
28
31
  .join('&');
29
32
  }
30
33
 
31
- const data = await appFetch<ProductResult>(url, {
32
- headers: {
33
- Accept: 'application/json',
34
- 'Content-Type': 'application/json'
34
+ const data = await appFetch<ProductResult>({
35
+ url,
36
+ locale,
37
+ currency,
38
+ init: {
39
+ headers: {
40
+ Accept: 'application/json',
41
+ 'Content-Type': 'application/json'
42
+ }
35
43
  }
36
44
  });
37
45
 
38
46
  const categoryUrl = product.categoryUrl(data.product.pk);
39
47
 
40
- const productCategoryData = await appFetch<ProductCategoryResult>(
41
- categoryUrl,
42
- {
48
+ const productCategoryData = await appFetch<ProductCategoryResult>({
49
+ url: categoryUrl,
50
+ locale,
51
+ currency,
52
+ init: {
43
53
  headers: {
44
54
  Accept: 'application/json',
45
55
  'Content-Type': 'application/json'
46
56
  }
47
57
  }
48
- );
58
+ });
49
59
 
50
60
  const menuItemModel = productCategoryData?.results[0]?.menuitemmodel;
51
61
 
@@ -59,10 +69,15 @@ const getProductDataHandler = ({
59
69
 
60
70
  const breadcrumbUrl = product.breadcrumbUrl(menuItemModel);
61
71
 
62
- const breadcrumbData = await appFetch<any>(breadcrumbUrl, {
63
- headers: {
64
- Accept: 'application/json',
65
- 'Content-Type': 'application/json'
72
+ const breadcrumbData = await appFetch<any>({
73
+ url: breadcrumbUrl,
74
+ locale,
75
+ currency,
76
+ init: {
77
+ headers: {
78
+ Accept: 'application/json',
79
+ 'Content-Type': 'application/json'
80
+ }
66
81
  }
67
82
  });
68
83
 
@@ -75,6 +90,8 @@ const getProductDataHandler = ({
75
90
 
76
91
  export const getProductData = async ({
77
92
  pk,
93
+ locale = ServerVariables.locale,
94
+ currency = ServerVariables.currency,
78
95
  searchParams,
79
96
  groupProduct
80
97
  }: GetProduct) => {
@@ -1,23 +1,15 @@
1
1
  import appFetch from '../../utils/app-fetch';
2
2
  import { Cache, CacheKey } from '../../lib/cache';
3
3
  import { misc } from '../../data/urls';
4
- import logger from '../../utils/log';
4
+ import { ServerVariables } from '../../utils/server-variables';
5
5
 
6
- function getRootSeoDataHandler() {
7
- return async function () {
8
- let data = {};
9
-
10
- try {
11
- data = await appFetch<{ [key: string]: string }>(misc.cmsSeo('/'));
12
- } catch (error) {
13
- logger.error('Error while fetching root seo data', error);
14
- }
15
-
16
- return data;
17
- };
6
+ interface SeoDataParams {
7
+ url: string;
8
+ locale?: string;
9
+ currency?: string;
18
10
  }
19
11
 
20
- function getSeoDataHandler(url: string) {
12
+ function getSeoDataHandler({ url, locale, currency }: SeoDataParams) {
21
13
  return async function () {
22
14
  let data = {} as {
23
15
  title: string;
@@ -27,7 +19,7 @@ function getSeoDataHandler(url: string) {
27
19
  };
28
20
 
29
21
  try {
30
- data = await appFetch(misc.cmsSeo(url));
22
+ data = await appFetch({ url: misc.cmsSeo(url), locale, currency });
31
23
  } catch (error) {
32
24
  // logger.error('Error while fetching seo data', { url, error });
33
25
  }
@@ -36,13 +28,14 @@ function getSeoDataHandler(url: string) {
36
28
  };
37
29
  }
38
30
 
39
- /**
40
- * @deprecated Use getSeoData instead
41
- */
42
- export const getRootSeo = async () => {
43
- return Cache.wrap(CacheKey.RootSeo, getRootSeoDataHandler());
44
- };
45
-
46
- export const getSeoData = async (url: string) => {
47
- return Cache.wrap(CacheKey.Seo(url), getSeoDataHandler(url));
31
+ export const getSeoData = async (
32
+ url,
33
+ locale = ServerVariables.locale,
34
+ currency = ServerVariables.currency
35
+ ) => {
36
+ return Cache.wrap(
37
+ CacheKey.Seo(url),
38
+ locale,
39
+ getSeoDataHandler({ url, locale, currency })
40
+ );
48
41
  };