@akinon/next 1.1.0 → 1.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Refactor Sentry config.
8
+ - Add localeIncludedPrettyUrlPattern option to settings.
9
+ - Refactor getRetailStoreStock mutation.
10
+
3
11
  ## 1.1.0
4
12
 
5
13
  ### Minor Changes
@@ -51,6 +51,9 @@ export default function SelectedPaymentOptionView() {
51
51
  } else if (payment_option.payment_type === 'loyalty_money') {
52
52
  promise = import(`views/checkout/steps/payment/options/loyalty`);
53
53
  }
54
+ // else if (payment_option.payment_type === 'gpay') {
55
+ // promise = import(`views/checkout/steps/payment/options/gpay`);
56
+ // }
54
57
  } catch (error) {}
55
58
 
56
59
  return promise
@@ -23,7 +23,7 @@ type GetProduct = {
23
23
  pk: number;
24
24
  searchParams?: URLSearchParams;
25
25
  groupProduct?: boolean;
26
- [key:string]: any;
26
+ [key: string]: any;
27
27
  };
28
28
 
29
29
  export const productApi = api.injectEndpoints({
@@ -34,7 +34,7 @@ export const productApi = api.injectEndpoints({
34
34
  })
35
35
  }),
36
36
  getProductByParams: build.query<ProductResult, GetProduct>({
37
- query: ({pk, searchParams, groupProduct, ...params}) => {
37
+ query: ({ pk, searchParams, groupProduct, ...params }) => {
38
38
  let url = groupProduct
39
39
  ? product.getGroupProductByPk(pk)
40
40
  : product.getProductByPk(pk);
@@ -50,11 +50,10 @@ export const productApi = api.injectEndpoints({
50
50
  }),
51
51
  getRetailStoreStock: build.mutation<StockResultType, FindInStoreFormType>({
52
52
  query: (body) => {
53
- const { productPk, store, variant } = body;
54
- const hasVariant = variant ? `&integration_beden=${variant}` : '';
53
+ const { productPk, queryString } = body;
55
54
  return {
56
55
  url: buildClientRequestUrl(
57
- product.getRetailStoreStock(productPk, store, hasVariant),
56
+ product.getRetailStoreStock(productPk, queryString),
58
57
  {
59
58
  contentType: 'application/json'
60
59
  }
package/data/urls.ts CHANGED
@@ -116,8 +116,8 @@ export const product = {
116
116
  installments: (productId: number) => `/payments/cards/product/${productId}`,
117
117
  getProductByPk: (pk: number) => `/product/${pk}`,
118
118
  getGroupProductByPk: (pk: number) => `/group-product/${pk}`,
119
- getRetailStoreStock: (productPk: string, store: string, hasVariant: string) =>
120
- `/retail_store_stock/${productPk}?city_id=${store}${hasVariant}`,
119
+ getRetailStoreStock: (productPk: string, queryString: string) =>
120
+ `/retail_store_stock/${productPk}?${queryString}`,
121
121
  addProduct: '/baskets/basket',
122
122
  slug: (slug: string) => `/${slug}`,
123
123
  categoryUrl: (pk: number) => `/products/${pk}/category_nodes/?limit=1`,
@@ -76,7 +76,13 @@ const withPrettyUrl =
76
76
  return middleware(req, event);
77
77
  }
78
78
 
79
- const prettyUrlResult = await resolvePrettyUrl(prettyUrlPathname);
79
+ const prettyUrlResult = await resolvePrettyUrl(
80
+ Settings.localization.localeIncludedPrettyUrlPattern?.test(
81
+ prettyUrlPathname
82
+ )
83
+ ? url.pathname
84
+ : prettyUrlPathname
85
+ );
80
86
 
81
87
  if (prettyUrlResult.matched) {
82
88
  req.middlewareParams.rewrites.prettyUrl = prettyUrlResult.path;
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.1.0",
4
+ "version": "1.2.0",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
package/plugins.js CHANGED
@@ -4,4 +4,5 @@ module.exports = [
4
4
  'pz-one-click-checkout',
5
5
  'pz-pay-on-delivery',
6
6
  'pz-checkout-gift-pack',
7
+ 'pz-gpay'
7
8
  ];
@@ -0,0 +1,27 @@
1
+ import * as Sentry from '@sentry/nextjs';
2
+
3
+ const SENTRY_DSN: string =
4
+ process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
5
+
6
+ export const initSentry = (
7
+ type: 'Server' | 'Client' | 'Edge',
8
+ options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {}
9
+ ) => {
10
+ // TODO: Handle options with ESLint rules
11
+
12
+ // TODO: Remove Zero Project DSN
13
+
14
+ Sentry.init({
15
+ dsn:
16
+ SENTRY_DSN ||
17
+ 'https://d8558ef8997543deacf376c7d8d7cf4b@o64293.ingest.sentry.io/4504338423742464',
18
+ initialScope: {
19
+ tags: {
20
+ APP_TYPE: 'ProjectZeroNext',
21
+ TYPE: type
22
+ }
23
+ },
24
+ tracesSampleRate: 1.0,
25
+ integrations: []
26
+ });
27
+ };
@@ -83,9 +83,8 @@ export type StockResultType = [
83
83
  ];
84
84
 
85
85
  export type FindInStoreFormType = {
86
- store: string;
87
- variant: string;
88
86
  productPk: string;
87
+ queryString: string;
89
88
  };
90
89
 
91
90
  export interface ProductCategoryResult {
package/types/index.ts CHANGED
@@ -148,6 +148,20 @@ export interface Settings {
148
148
  locale: string;
149
149
  defaultCurrencyCode: string;
150
150
  }) => string;
151
+ /**
152
+ * By default, pretty url resolver excludes locale from url.
153
+ * In some cases, you may want to create flatpages and include locale in urls.
154
+ * This is useful if you want to manage your flatpages for different countries by using locale value.
155
+ *
156
+ * @example
157
+ * // URL entered in Omnitron: /en-us/pages/about-us
158
+ * // Locale Strategy: LocaleUrlStrategy.ShowAllLocales
159
+ *
160
+ * // If you don't use this option, pretty url resolver will remove the locale and it will be resolved as '/pages/about-us' and you will get 404. Because there is no page with this url. But if you use this option, it will be resolved as '/en-us/pages/about-us' and you will get the page.
161
+ * // Following pattern will include locale for all urls including '/pages/'.
162
+ * localeIncludedPrettyUrlPattern: new RegExp('.+/pages/.+$')
163
+ */
164
+ localeIncludedPrettyUrlPattern?: RegExp;
151
165
  };
152
166
  rewrites?: Array<{
153
167
  source: string;
package/utils/log.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import * as Sentry from '@sentry/nextjs';
2
+
1
3
  enum LogLevel {
2
4
  TRACE = 'trace',
3
5
  DEBUG = 'debug',
@@ -92,6 +94,15 @@ const error: LoggerFn = (message, payload) => {
92
94
  message,
93
95
  payload
94
96
  });
97
+
98
+ Sentry.withScope(function (scope) {
99
+ scope.setLevel('error');
100
+
101
+ Sentry.captureException({
102
+ message,
103
+ extra: payload
104
+ });
105
+ });
95
106
  };
96
107
 
97
108
  const warn: LoggerFn = (message, payload) => {
@@ -100,6 +111,15 @@ const warn: LoggerFn = (message, payload) => {
100
111
  message,
101
112
  payload
102
113
  });
114
+
115
+ Sentry.withScope(function (scope) {
116
+ scope.setLevel('warning');
117
+
118
+ Sentry.captureEvent({
119
+ message,
120
+ extra: payload
121
+ });
122
+ });
103
123
  };
104
124
 
105
125
  const debug: LoggerFn = (message, payload) => {