@addsign/moje-agenda-shared-lib 0.0.43 → 0.0.46

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/types.d.ts CHANGED
@@ -21,6 +21,7 @@ export interface IEmployee extends IUserInfo {
21
21
  }
22
22
  export type IAuthApps = string[];
23
23
  export interface IEventMessage {
24
+ title?: string;
24
25
  message?: string;
25
26
  timeout?: number;
26
27
  classes?: string;
@@ -1,10 +1,17 @@
1
1
  const handleErrors = (error, emitter, customMessage) => {
2
- var errmsgToDisplay = customMessage || (error == null ? void 0 : error.message);
3
- if (error.code == "ERR_BAD_REQUEST" || error.code == "ERR_NETWORK") {
4
- errmsgToDisplay = "Interní chyba aplikace: " + errmsgToDisplay + " \n" + (/* @__PURE__ */ new Date()).toLocaleString();
2
+ var _a, _b, _c, _d;
3
+ var errmsgToDisplay = (customMessage || "") + " " + (((_c = (_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error) == null ? void 0 : _c.message) || error.message || "");
4
+ var errorTitle = "";
5
+ if (error.code == "ERR_NETWORK") {
6
+ errorTitle = "Síťová chyba";
7
+ errmsgToDisplay = errmsgToDisplay + " " + (/* @__PURE__ */ new Date()).toLocaleString();
8
+ } else if (error.code == "ERR_BAD_REQUEST") {
9
+ errorTitle = "Interní chyba aplikace";
10
+ errmsgToDisplay = (/* @__PURE__ */ new Date()).toLocaleString() + " (" + ((_d = error.response) == null ? void 0 : _d.status) + ") \n" + errmsgToDisplay;
5
11
  }
6
12
  console.error(error);
7
13
  emitter.emit("message", {
14
+ title: errorTitle,
8
15
  message: errmsgToDisplay,
9
16
  classes: "bg-danger ",
10
17
  timeout: 0
@@ -1 +1 @@
1
- {"version":3,"file":"handleErrors.js","sources":["../../lib/utils/handleErrors.ts"],"sourcesContent":["import { AxiosError } from \"axios\";\r\nimport { Emitter } from \"mitt\";\r\nimport { Events } from \"../types\";\r\n\r\nconst handleErrors = (error: AxiosError, emitter: Emitter<Events>, customMessage?: string) => {\r\n var errmsgToDisplay = customMessage || error?.message\r\n if (error.code == 'ERR_BAD_REQUEST' || error.code == 'ERR_NETWORK') {\r\n\r\n errmsgToDisplay = \"Interní chyba aplikace: \" + errmsgToDisplay + \" \\n\" + new Date().toLocaleString();\r\n }\r\n console.error(error);\r\n emitter.emit(\"message\", {\r\n message: errmsgToDisplay,\r\n classes: \"bg-danger \",\r\n timeout: 0\r\n });\r\n}\r\nexport { handleErrors }"],"names":[],"mappings":"AAIA,MAAM,eAAe,CAAC,OAAmB,SAA0B,kBAA2B;AACtF,MAAA,kBAAkB,kBAAiB,+BAAO;AAC9C,MAAI,MAAM,QAAQ,qBAAqB,MAAM,QAAQ,eAAe;AAEhE,sBAAkB,6BAA6B,kBAAkB,SAAY,oBAAA,KAAA,GAAO;EACxF;AACA,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,WAAW;AAAA,IACpB,SAAS;AAAA,IACT,SAAS;AAAA,IACT,SAAS;AAAA,EAAA,CACZ;AACL;"}
1
+ {"version":3,"file":"handleErrors.js","sources":["../../lib/utils/handleErrors.ts"],"sourcesContent":["import { AxiosError } from \"axios\";\r\nimport { Emitter } from \"mitt\";\r\nimport { Events } from \"../types\";\r\n\r\nconst handleErrors = (error: AxiosError, emitter: Emitter<Events>, customMessage?: string) => {\r\n var errmsgToDisplay = (customMessage || \"\") + \" \" + ((error.response?.data as any)?.error?.message || error.message || \"\")\r\n\r\n var errorTitle = \"\"\r\n if (error.code == 'ERR_NETWORK') {\r\n errorTitle = \"Síťová chyba\"\r\n errmsgToDisplay = errmsgToDisplay + \" \" + new Date().toLocaleString();\r\n } else if (error.code == 'ERR_BAD_REQUEST') {\r\n\r\n errorTitle = \"Interní chyba aplikace\"\r\n errmsgToDisplay = new Date().toLocaleString() + \" (\" + error.response?.status + \") \\n\" + errmsgToDisplay;\r\n }\r\n console.error(error);\r\n emitter.emit(\"message\", {\r\n title: errorTitle,\r\n message: errmsgToDisplay,\r\n classes: \"bg-danger \",\r\n timeout: 0\r\n });\r\n}\r\nexport { handleErrors }"],"names":[],"mappings":"AAIA,MAAM,eAAe,CAAC,OAAmB,SAA0B,kBAA2B;AAA9F;AACQ,MAAA,mBAAmB,iBAAiB,MAAM,SAAQ,uBAAM,aAAN,mBAAgB,SAAhB,mBAA8B,UAA9B,mBAAqC,YAAW,MAAM,WAAW;AAEvH,MAAI,aAAa;AACb,MAAA,MAAM,QAAQ,eAAe;AAChB,iBAAA;AACb,sBAAkB,kBAAkB,OAAU,oBAAA,KAAA,GAAO;EAAe,WAC7D,MAAM,QAAQ,mBAAmB;AAE3B,iBAAA;AACK,uBAAA,oBAAI,KAAO,GAAA,mBAAmB,SAAO,WAAM,aAAN,mBAAgB,UAAS,SAAS;AAAA,EAC7F;AACA,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,WAAW;AAAA,IACpB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,SAAS;AAAA,IACT,SAAS;AAAA,EAAA,CACZ;AACL;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@addsign/moje-agenda-shared-lib",
3
3
  "private": false,
4
- "version": "0.0.43",
4
+ "version": "0.0.46",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",