@sentecacommerce-theme/lib 0.13.21-alpha.0 → 0.14.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.
@@ -44,7 +44,7 @@ var useRelevaQuery = function(payload, isReady, token, interfaceKey) {
44
44
  return _regeneratorRuntime.default.wrap(function _callee$(_ctx) {
45
45
  while(1)switch(_ctx.prev = _ctx.next){
46
46
  case 0:
47
- url = '/hub/releva/collect';
47
+ url = "".concat(process.env.NEXT_PUBLIC_PROXY_URL, "/hub/releva/collect");
48
48
  return _ctx.abrupt("return", fetch(url, {
49
49
  method: 'POST',
50
50
  headers: {
@@ -33,7 +33,9 @@ var NotificationsApiFactory = function() {
33
33
  queryCache.cancelQueries(cacheKeys.useGet);
34
34
  var oldNotifications = queryCache.getQueryData(cacheKeys.useGet);
35
35
  return function() {
36
- return queryCache.setQueryData(cacheKeys.useGet, oldNotifications);
36
+ return queryCache.setQueryData(cacheKeys.useGet, {
37
+ results: oldNotifications
38
+ });
37
39
  };
38
40
  },
39
41
  onError: function(_, __, rollback) {
@@ -44,7 +46,9 @@ var NotificationsApiFactory = function() {
44
46
  var optimisticNotifications = previousNotifications === null || previousNotifications === void 0 ? void 0 : previousNotifications.results.filter(function(n) {
45
47
  return n._id !== params.id;
46
48
  });
47
- queryCache.setQueryData(cacheKeys.useGet, optimisticNotifications);
49
+ queryCache.setQueryData(cacheKeys.useGet, {
50
+ results: optimisticNotifications
51
+ });
48
52
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
49
53
  }
50
54
  });
@@ -19,7 +19,7 @@ function _interopRequireDefault(obj) {
19
19
  var ProductStateContext = /*#__PURE__*/ _react.default.createContext(undefined);
20
20
  var CountDispatchContext = /*#__PURE__*/ _react.default.createContext(undefined);
21
21
  function ProductProvider(param) {
22
- var product = param.product, children = param.children, defaultVariantId = param.defaultVariantId, _includeBrandInName = param.includeBrandInName, includeBrandInName = _includeBrandInName === void 0 ? false : _includeBrandInName;
22
+ var product = param.product, children = param.children, defaultVariantId = param.defaultVariantId, _includeBrandInName = param.includeBrandInName, includeBrandInName = _includeBrandInName === void 0 ? false : _includeBrandInName, _withShortTitle = param.withShortTitle, withShortTitle = _withShortTitle === void 0 ? false : _withShortTitle;
23
23
  var ref38 = (0, _useProductVariants).useProductVariants({
24
24
  product: product,
25
25
  defaultVariantId: defaultVariantId
@@ -30,7 +30,7 @@ function ProductProvider(param) {
30
30
  var rootCategoryId = rootCategory === null || rootCategory === void 0 ? void 0 : rootCategory.resourceId;
31
31
  var metaObj = {
32
32
  _id: product === null || product === void 0 ? void 0 : product._id,
33
- name: includeBrandInName && (product === null || product === void 0 ? void 0 : (ref1 = product.brands) === null || ref1 === void 0 ? void 0 : (ref2 = ref1[0]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.resource) === null || ref3 === void 0 ? void 0 : ref3.name) ? "".concat((0, _).getTranslatableField(product === null || product === void 0 ? void 0 : (ref4 = product.brands) === null || ref4 === void 0 ? void 0 : (ref5 = ref4[0]) === null || ref5 === void 0 ? void 0 : (ref6 = ref5.resource) === null || ref6 === void 0 ? void 0 : ref6.name), " ").concat((0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.name)) : (0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.name),
33
+ name: includeBrandInName && !withShortTitle && (product === null || product === void 0 ? void 0 : (ref1 = product.brands) === null || ref1 === void 0 ? void 0 : (ref2 = ref1[0]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.resource) === null || ref3 === void 0 ? void 0 : ref3.name) ? "".concat((0, _).getTranslatableField(product === null || product === void 0 ? void 0 : (ref4 = product.brands) === null || ref4 === void 0 ? void 0 : (ref5 = ref4[0]) === null || ref5 === void 0 ? void 0 : (ref6 = ref5.resource) === null || ref6 === void 0 ? void 0 : ref6.name), " ").concat((0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.name)) : (0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.name),
34
34
  slug: (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.slug),
35
35
  description: (0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.description) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.description),
36
36
  shortDescription: (0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.metaDescription) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.metaDescription),
@@ -28,17 +28,17 @@ function _interopRequireDefault(obj) {
28
28
  *
29
29
  */ var truncateToCharLength = function(text, maxLenChars) {
30
30
  var separator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ' ';
31
- var cut = text.indexOf(separator, maxLenChars);
31
+ var cut = text === null || text === void 0 ? void 0 : text.indexOf(separator, maxLenChars);
32
32
  if (cut === -1) return text;
33
- return text.substring(0, cut);
33
+ return text === null || text === void 0 ? void 0 : text.substring(0, cut);
34
34
  };
35
35
  function ProductSEO() {
36
- var ref16 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _favorTitleTemplateOverMeta = ref16.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = ref16.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = ref16.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = ref16.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate;
36
+ var ref16 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _favorTitleTemplateOverMeta = ref16.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = ref16.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = ref16.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = ref16.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate, _withShortTitle = ref16.withShortTitle, withShortTitle = _withShortTitle === void 0 ? false : _withShortTitle;
37
37
  var ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14;
38
38
  var ref15 = (0, _useProduct).useProductState(), selectedVariant = ref15.selectedVariant, metaData = ref15.metaData, seoData = ref15.seoData;
39
39
  var domain = (0, _useConfig).useConfigState().domain;
40
40
  var description = (0, _utils).escape(seoData.description || metaData.shortDescription || truncateToCharLength(metaData === null || metaData === void 0 ? void 0 : metaData.description, 200) || '');
41
- var title = seoData.title || metaData.name || '';
41
+ var title = withShortTitle ? metaData.name || '' : seoData.title || metaData.name || '';
42
42
  var price = (0, _usePrice).usePrice({
43
43
  price: selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref1 = selectedVariant.offer) === null || ref1 === void 0 ? void 0 : ref1.originalPrice
44
44
  }).price;
@@ -63,7 +63,7 @@ function ProductSEO() {
63
63
  type: "application/ld+json",
64
64
  dangerouslySetInnerHTML: (0, _utils).createDangerousMarkup(productJSONLd)
65
65
  })), /*#__PURE__*/ _react.default.createElement(_basicSEO.BasicSEO, {
66
- title: formattedTitle,
66
+ title: withShortTitle ? title : formattedTitle,
67
67
  description: formattedDescription,
68
68
  keywords: seoData.keywords
69
69
  }), /*#__PURE__*/ _react.default.createElement(_openGraph.OpenGraph, {
@@ -35,7 +35,7 @@ export var useRelevaQuery = function(payload, isReady, token, interfaceKey) {
35
35
  return regeneratorRuntime.wrap(function _callee$(_ctx) {
36
36
  while(1)switch(_ctx.prev = _ctx.next){
37
37
  case 0:
38
- url = '/hub/releva/collect';
38
+ url = "".concat(process.env.NEXT_PUBLIC_PROXY_URL, "/hub/releva/collect");
39
39
  return _ctx.abrupt("return", fetch(url, {
40
40
  method: 'POST',
41
41
  headers: {
@@ -27,7 +27,9 @@ export var NotificationsApiFactory = function() {
27
27
  queryCache.cancelQueries(cacheKeys.useGet);
28
28
  var oldNotifications = queryCache.getQueryData(cacheKeys.useGet);
29
29
  return function() {
30
- return queryCache.setQueryData(cacheKeys.useGet, oldNotifications);
30
+ return queryCache.setQueryData(cacheKeys.useGet, {
31
+ results: oldNotifications
32
+ });
31
33
  };
32
34
  },
33
35
  onError: function(_, __, rollback) {
@@ -38,7 +40,9 @@ export var NotificationsApiFactory = function() {
38
40
  var optimisticNotifications = previousNotifications === null || previousNotifications === void 0 ? void 0 : previousNotifications.results.filter(function(n) {
39
41
  return n._id !== params.id;
40
42
  });
41
- queryCache.setQueryData(cacheKeys.useGet, optimisticNotifications);
43
+ queryCache.setQueryData(cacheKeys.useGet, {
44
+ results: optimisticNotifications
45
+ });
42
46
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
43
47
  }
44
48
  });
@@ -7,7 +7,7 @@ import { useProductVariants } from '../useProductVariants';
7
7
  var ProductStateContext = /*#__PURE__*/ React.createContext(undefined);
8
8
  var CountDispatchContext = /*#__PURE__*/ React.createContext(undefined);
9
9
  export function ProductProvider(param) {
10
- var product = param.product, children = param.children, defaultVariantId = param.defaultVariantId, _includeBrandInName = param.includeBrandInName, includeBrandInName = _includeBrandInName === void 0 ? false : _includeBrandInName;
10
+ var product = param.product, children = param.children, defaultVariantId = param.defaultVariantId, _includeBrandInName = param.includeBrandInName, includeBrandInName = _includeBrandInName === void 0 ? false : _includeBrandInName, _withShortTitle = param.withShortTitle, withShortTitle = _withShortTitle === void 0 ? false : _withShortTitle;
11
11
  var ref38 = useProductVariants({
12
12
  product: product,
13
13
  defaultVariantId: defaultVariantId
@@ -18,7 +18,7 @@ export function ProductProvider(param) {
18
18
  var rootCategoryId = rootCategory === null || rootCategory === void 0 ? void 0 : rootCategory.resourceId;
19
19
  var metaObj = {
20
20
  _id: product === null || product === void 0 ? void 0 : product._id,
21
- name: includeBrandInName && (product === null || product === void 0 ? void 0 : (ref1 = product.brands) === null || ref1 === void 0 ? void 0 : (ref2 = ref1[0]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.resource) === null || ref3 === void 0 ? void 0 : ref3.name) ? "".concat(getTranslatableField(product === null || product === void 0 ? void 0 : (ref4 = product.brands) === null || ref4 === void 0 ? void 0 : (ref5 = ref4[0]) === null || ref5 === void 0 ? void 0 : (ref6 = ref5.resource) === null || ref6 === void 0 ? void 0 : ref6.name), " ").concat(getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || getTranslatableField(product === null || product === void 0 ? void 0 : product.name)) : getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || getTranslatableField(product === null || product === void 0 ? void 0 : product.name),
21
+ name: includeBrandInName && !withShortTitle && (product === null || product === void 0 ? void 0 : (ref1 = product.brands) === null || ref1 === void 0 ? void 0 : (ref2 = ref1[0]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.resource) === null || ref3 === void 0 ? void 0 : ref3.name) ? "".concat(getTranslatableField(product === null || product === void 0 ? void 0 : (ref4 = product.brands) === null || ref4 === void 0 ? void 0 : (ref5 = ref4[0]) === null || ref5 === void 0 ? void 0 : (ref6 = ref5.resource) === null || ref6 === void 0 ? void 0 : ref6.name), " ").concat(getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || getTranslatableField(product === null || product === void 0 ? void 0 : product.name)) : getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || getTranslatableField(product === null || product === void 0 ? void 0 : product.name),
22
22
  slug: getTranslatableField(product === null || product === void 0 ? void 0 : product.slug),
23
23
  description: getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.description) || getTranslatableField(product === null || product === void 0 ? void 0 : product.description),
24
24
  shortDescription: getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.metaDescription) || getTranslatableField(product === null || product === void 0 ? void 0 : product.metaDescription),
@@ -18,17 +18,17 @@ import { useConfigState } from '../../../hooks/useConfig';
18
18
  *
19
19
  */ var truncateToCharLength = function(text, maxLenChars) {
20
20
  var separator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ' ';
21
- var cut = text.indexOf(separator, maxLenChars);
21
+ var cut = text === null || text === void 0 ? void 0 : text.indexOf(separator, maxLenChars);
22
22
  if (cut === -1) return text;
23
- return text.substring(0, cut);
23
+ return text === null || text === void 0 ? void 0 : text.substring(0, cut);
24
24
  };
25
25
  export function ProductSEO() {
26
- var ref16 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _favorTitleTemplateOverMeta = ref16.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = ref16.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = ref16.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = ref16.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate;
26
+ var ref16 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _favorTitleTemplateOverMeta = ref16.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = ref16.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = ref16.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = ref16.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate, _withShortTitle = ref16.withShortTitle, withShortTitle = _withShortTitle === void 0 ? false : _withShortTitle;
27
27
  var ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14;
28
28
  var ref15 = useProductState(), selectedVariant = ref15.selectedVariant, metaData = ref15.metaData, seoData = ref15.seoData;
29
29
  var domain = useConfigState().domain;
30
30
  var description = escape(seoData.description || metaData.shortDescription || truncateToCharLength(metaData === null || metaData === void 0 ? void 0 : metaData.description, 200) || '');
31
- var title = seoData.title || metaData.name || '';
31
+ var title = withShortTitle ? metaData.name || '' : seoData.title || metaData.name || '';
32
32
  var price = usePrice({
33
33
  price: selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref1 = selectedVariant.offer) === null || ref1 === void 0 ? void 0 : ref1.originalPrice
34
34
  }).price;
@@ -53,7 +53,7 @@ export function ProductSEO() {
53
53
  type: "application/ld+json",
54
54
  dangerouslySetInnerHTML: createDangerousMarkup(productJSONLd)
55
55
  })), /*#__PURE__*/ React.createElement(BasicSEO, {
56
- title: formattedTitle,
56
+ title: withShortTitle ? title : formattedTitle,
57
57
  description: formattedDescription,
58
58
  keywords: seoData.keywords
59
59
  }), /*#__PURE__*/ React.createElement(OpenGraph, {
@@ -13,6 +13,7 @@ export declare type getProductBySlugConfig = {
13
13
  merchantKey?: string;
14
14
  expand?: string;
15
15
  project?: string;
16
+ stockLocationKey?: string;
16
17
  };
17
18
  export declare const ProductsApiFactory: {
18
19
  getInstance: () => ProductsApiType;
@@ -55,6 +55,7 @@ declare type ProductProviderProps = {
55
55
  project?: string;
56
56
  };
57
57
  includeBrandInName?: boolean;
58
+ withShortTitle?: boolean;
58
59
  };
59
60
  declare type ProductStateContextType = {
60
61
  attributeRules: AttributeRulesMap;
@@ -91,7 +92,7 @@ declare type CountFunctionsContextType = {
91
92
  };
92
93
  getProductVideos: () => VideoType[];
93
94
  };
94
- export declare function ProductProvider({ product, children, defaultVariantId, includeBrandInName, }: ProductProviderProps): JSX.Element;
95
+ export declare function ProductProvider({ product, children, defaultVariantId, includeBrandInName, withShortTitle, }: ProductProviderProps): JSX.Element;
95
96
  export declare function useProductState(): ProductStateContextType;
96
97
  export declare function useProductFunctions(): CountFunctionsContextType;
97
98
  export declare function useProduct(slug: string, config?: getProductBySlugConfig): import("react-query").QueryResult<ProductDTO, unknown>;
@@ -8,6 +8,7 @@ declare type Config = {
8
8
  merchantKey?: string;
9
9
  expand?: string;
10
10
  project?: string;
11
+ stockLocationKey?: string;
11
12
  };
12
13
  export declare const prefetchProduct: (queryCache: QueryCache, slug: string, config?: Config) => Promise<import("@sentecacommerce/sdk").ProductDTO | undefined>;
13
14
  export {};
@@ -1,6 +1,7 @@
1
- export declare function ProductSEO({ favorTitleTemplateOverMeta, favorDescriptionTemplateOverMeta, titleTemplate, descriptionTemplate, }?: {
1
+ export declare function ProductSEO({ favorTitleTemplateOverMeta, favorDescriptionTemplateOverMeta, titleTemplate, descriptionTemplate, withShortTitle, }?: {
2
2
  favorTitleTemplateOverMeta?: boolean;
3
3
  favorDescriptionTemplateOverMeta?: boolean;
4
4
  titleTemplate?: string;
5
5
  descriptionTemplate?: string;
6
+ withShortTitle?: boolean;
6
7
  }): JSX.Element;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentecacommerce-theme/lib",
3
3
  "sideEffects": false,
4
- "version": "0.13.21-alpha.0+1eaf982",
4
+ "version": "0.14.1",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
@@ -31,13 +31,13 @@
31
31
  "watch:cjs": "swc src --out-dir dist/cjs -w",
32
32
  "watch:esm": "swc src --out-dir dist/esm --no-swcrc -w"
33
33
  },
34
- "gitHead": "1eaf9822c6a7e00f5e893efbe7b4d74adac6ead9",
34
+ "gitHead": "14811ce20ea0c409009d35c09a1340a808c12413",
35
35
  "peerDependencies": {
36
36
  "react-query": "^2.26.2"
37
37
  },
38
38
  "dependencies": {
39
- "@sentecacommerce-theme/base": "^0.13.21-alpha.0+1eaf982",
40
- "@sentecacommerce-theme/cms": "^0.13.21-alpha.0+1eaf982",
39
+ "@sentecacommerce-theme/base": "^0.14.1",
40
+ "@sentecacommerce-theme/cms": "^0.14.1",
41
41
  "@sentecacommerce/sdk": "2.0.175",
42
42
  "body-scroll-lock": "^3.1.5",
43
43
  "copy-to-clipboard": "^3.3.1",