@plentymarkets/shop-core 1.20.0 → 1.21.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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@plentymarkets/shop-core",
3
3
  "configKey": "shopCore",
4
- "version": "1.20.0",
4
+ "version": "1.21.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -1,6 +1,18 @@
1
1
  import { useNuxtApp } from "nuxt/app";
2
2
  import { ApiError } from "@plentymarkets/shop-api";
3
3
  import { useNotification } from "../composables/useNotification.js";
4
+ const formatCause = (value) => {
5
+ return value.split(".").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
6
+ };
7
+ const extractCause = (cause) => {
8
+ try {
9
+ if (cause && typeof cause === "object" && "field" in cause && typeof cause.field === "string") {
10
+ return formatCause(cause.field);
11
+ }
12
+ } catch {
13
+ }
14
+ return null;
15
+ };
4
16
  export const useHandleError = (error) => {
5
17
  if (error && import.meta.client) {
6
18
  const $i18n = useNuxtApp().$i18n;
@@ -9,7 +21,9 @@ export const useHandleError = (error) => {
9
21
  const persist = true;
10
22
  if (error instanceof ApiError) {
11
23
  const translationKey = `storefrontError.${error.key}`;
12
- const message = error.key && $i18n.te(translationKey) ? $i18n.t(translationKey) : error.message;
24
+ const cause = extractCause(error.cause);
25
+ const baseMessage = error.key && $i18n.te(translationKey) ? $i18n.t(translationKey) : error.message;
26
+ const message = cause ? `${baseMessage} (${cause})` : baseMessage;
13
27
  if (error.key === "security.invalidCsrfToken") {
14
28
  send({
15
29
  type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plentymarkets/shop-core",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
4
4
  "description": "Core module for PlentyONE Shop",
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,7 +49,7 @@
49
49
  "test:e2e:dev": "concurrently -k -s first --names \"server,playwright\" \"npm run start\" \"npx wait-on http-get://localhost:3000 && playwright test --ui\""
50
50
  },
51
51
  "dependencies": {
52
- "@plentymarkets/shop-api": "^0.153.0",
52
+ "@plentymarkets/shop-api": "^0.154.0",
53
53
  "@vue-storefront/sdk": "^3.4.1",
54
54
  "cookie": "^1.0.2",
55
55
  "js-sha256": "^0.11.0",