@addsign/moje-agenda-shared-lib 0.0.30 → 0.0.33

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.
@@ -2,7 +2,7 @@ import { default as React } from 'react';
2
2
 
3
3
  export interface ICalendarItem {
4
4
  id: number;
5
- label: string;
5
+ label?: string;
6
6
  from: Date;
7
7
  to: Date;
8
8
  background?: string;
@@ -95,6 +95,7 @@ const Calendar = ({ items }) => {
95
95
  /* @__PURE__ */ jsx(
96
96
  "button",
97
97
  {
98
+ type: "button",
98
99
  onClick: goToPreviousMonth,
99
100
  className: "mx-1 px-3 py-2 text-black bg-gray-400 hover:bg-gray-500",
100
101
  children: "Předchozí"
@@ -103,6 +104,7 @@ const Calendar = ({ items }) => {
103
104
  /* @__PURE__ */ jsx(
104
105
  "button",
105
106
  {
107
+ type: "button",
106
108
  onClick: goToNextMonth,
107
109
  className: "mx-1 px-3 py-2 text-black bg-gray-400 hover:bg-gray-500",
108
110
  children: "Následující"
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.js","sources":["../../lib/components/Calendar.tsx"],"sourcesContent":["import React, { useState, useEffect, useCallback } from \"react\";\n\nexport interface ICalendarItem {\n id: number;\n label: string;\n from: Date;\n to: Date;\n background?: string;\n color?: string;\n tooltip?: string;\n}\n\ntype ICalendarProps = {\n items: ICalendarItem[];\n};\n\n// Check if a day is within any item's date range\n\nconst Calendar: React.FunctionComponent<ICalendarProps> = ({ items }) => {\n const [currentMonth, setCurrentMonth] = useState<number>(\n new Date().getMonth()\n );\n const [currentYear, setCurrentYear] = useState<number>(\n new Date().getFullYear()\n );\n const [calendarData, setCalendarData] = useState<(string | number)[][]>([]);\n\n const monthNames: string[] = [\n \"Leden\",\n \"Únor\",\n \"Březen\",\n \"Duben\",\n \"Květen\",\n \"Červen\",\n \"Červenec\",\n \"Srpen\",\n \"Září\",\n \"Říjen\",\n \"Listopad\",\n \"Prosinec\",\n ];\n const dayNames: string[] = [\n \"Pondělí\",\n \"Úterý\",\n \"Středa\",\n \"Čtvrtek\",\n \"Pátek\",\n \"Sobota\",\n \"Neděle\",\n ];\n\n // Leap year check\n const isLeapYear = (year: number) =>\n (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n\n // Days in each month\n const daysInMonth = useCallback((month: number, year: number) => {\n if (month === 1) {\n // February\n return isLeapYear(year) ? 29 : 28;\n }\n if ([0, 2, 4, 6, 7, 9, 11].includes(month)) {\n // Months with 31 days\n\n return 31;\n }\n\n return 30; // Months with 30 days\n }, []);\n\n // Generate days for a month\n const generateMonthDays = useCallback(\n (month: number, year: number) => {\n const days = [];\n // const firstDayOfMonth = new Date(year, month, 1).getDay()\n\n // Adjusted to make week start from Monday\n let firstDayOfMonth = new Date(year, month, 1).getDay() - 1;\n if (firstDayOfMonth === -1) firstDayOfMonth = 6; // Sunday becomes 6 instead of -1\n\n let dayCounter = 1;\n\n for (let week = 0; week < 6; week++) {\n const weekDays = [];\n for (let day = 0; day < 7; day++) {\n if (week === 0 && day < firstDayOfMonth) {\n weekDays.push(\"\");\n } else if (dayCounter > daysInMonth(month, year)) {\n weekDays.push(\"\");\n } else {\n weekDays.push(dayCounter++);\n }\n }\n days.push(weekDays);\n }\n return days;\n },\n [daysInMonth]\n );\n\n useEffect(() => {\n setCalendarData(generateMonthDays(currentMonth, currentYear));\n }, [currentMonth, currentYear, generateMonthDays]);\n\n // Navigation handlers\n const goToNextMonth = () => {\n setCurrentMonth((prev) => (prev === 11 ? 0 : prev + 1));\n if (currentMonth === 11) {\n setCurrentYear((prev) => prev + 1);\n }\n };\n\n const goToPreviousMonth = () => {\n setCurrentMonth((prev) => (prev === 0 ? 11 : prev - 1));\n if (currentMonth === 0) {\n setCurrentYear((prev) => prev - 1);\n }\n };\n const findItemsForDay = (\n day: number,\n month: number,\n year: number\n ): ICalendarItem[] => {\n const date = new Date(year, month, day);\n return items.filter((item) => date >= item.from && date <= item.to);\n };\n return (\n <div className=\"flex flex-col bg-white shadow-lg flex-grow text-xs\">\n <div className=\"flex justify-between items-center bg-gray-200 text-black p-4\">\n <h2 className=\"font-semibold text-xl\">\n {monthNames[currentMonth]} {currentYear}\n </h2>\n <div>\n <button\n onClick={goToPreviousMonth}\n className=\"mx-1 px-3 py-2 text-black bg-gray-400 hover:bg-gray-500\"\n >\n Předchozí\n </button>\n <button\n onClick={goToNextMonth}\n className=\"mx-1 px-3 py-2 text-black bg-gray-400 hover:bg-gray-500\"\n >\n Následující\n </button>\n </div>\n </div>\n <div className=\"grid grid-cols-7 divide-x divide-y\">\n {dayNames.map((day, index) => (\n <div key={index} className=\"p-4 text-center font-semibold\">\n {day}\n </div>\n ))}\n {calendarData.map((week, weekIndex) => (\n <React.Fragment key={weekIndex}>\n {week.map((day, dayIndex) => {\n const itemsForDay = day\n ? findItemsForDay(day as number, currentMonth, currentYear)\n : [];\n return (\n <div\n key={dayIndex}\n className=\"p-0 align-middle justify-center text-center\"\n >\n <div className=\"py-1 font-bold\">{day} </div>\n {itemsForDay.map((item, itemIndex) => (\n <div\n key={itemIndex}\n className=\"dataItem w-full py-1 bg-primary text-white text-center mt-0\"\n style={{\n backgroundColor: item.background,\n color: item.color,\n }}\n data-tooltip-target={\"tooltip-\" + item.id}\n title={item.tooltip}\n >\n {item.label}\n </div>\n ))}\n </div>\n );\n })}\n </React.Fragment>\n ))}\n </div>\n </div>\n );\n};\n\nexport default Calendar;\n"],"names":[],"mappings":";;AAkBA,MAAM,WAAoD,CAAC,EAAE,YAAY;AACjE,QAAA,CAAC,cAAc,eAAe,IAAI;AAAA,KACtC,oBAAI,KAAK,GAAE,SAAS;AAAA,EAAA;AAEhB,QAAA,CAAC,aAAa,cAAc,IAAI;AAAA,KACpC,oBAAI,KAAK,GAAE,YAAY;AAAA,EAAA;AAEzB,QAAM,CAAC,cAAc,eAAe,IAAI,SAAgC,CAAE,CAAA;AAE1E,QAAM,aAAuB;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AA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AC,MAAM,UAAN,EACE,UAAA,KAAK,IAAI,CAAC,KAAK,aAAa;AAC3B,cAAM,cAAc,MAChB,gBAAgB,KAAe,cAAc,WAAW,IACxD;AAEF,eAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,WAAU;AAAA,YAEV,UAAA;AAAA,cAAC,qBAAA,OAAA,EAAI,WAAU,kBAAkB,UAAA;AAAA,gBAAA;AAAA,gBAAI;AAAA,cAAA,GAAC;AAAA,cACrC,YAAY,IAAI,CAAC,MAAM,cACtB;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBAEC,WAAU;AAAA,kBACV,OAAO;AAAA,oBACL,iBAAiB,KAAK;AAAA,oBACtB,OAAO,KAAK;AAAA,kBACd;AAAA,kBACA,uBAAqB,aAAa,KAAK;AAAA,kBACvC,OAAO,KAAK;AAAA,kBAEX,UAAK,KAAA;AAAA,gBAAA;AAAA,gBATD;AAAA,cAAA,CAWR;AAAA,YAAA;AAAA,UAAA;AAAA,UAjBI;AAAA,QAAA;AAAA,MAkBP,CAEH,EA3BkB,GAAA,SA4BrB,CACD;AAAA,IAAA,GACH;AAAA,EACF,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"Calendar.js","sources":["../../lib/components/Calendar.tsx"],"sourcesContent":["import React, { useState, useEffect, useCallback } from \"react\";\n\nexport interface ICalendarItem {\n id: number;\n label?: string;\n from: Date;\n to: Date;\n background?: string;\n color?: string;\n tooltip?: string;\n}\n\ntype ICalendarProps = {\n items: ICalendarItem[];\n};\n\n// Check if a day is within any item's date range\n\nconst Calendar: React.FunctionComponent<ICalendarProps> = ({ items }) => {\n const [currentMonth, setCurrentMonth] = useState<number>(\n new Date().getMonth()\n );\n const [currentYear, setCurrentYear] = useState<number>(\n new Date().getFullYear()\n );\n const [calendarData, setCalendarData] = useState<(string | number)[][]>([]);\n\n const monthNames: string[] = [\n \"Leden\",\n \"Únor\",\n \"Březen\",\n \"Duben\",\n \"Květen\",\n \"Červen\",\n \"Červenec\",\n \"Srpen\",\n \"Září\",\n \"Říjen\",\n \"Listopad\",\n \"Prosinec\",\n ];\n const dayNames: string[] = [\n \"Pondělí\",\n \"Úterý\",\n \"Středa\",\n \"Čtvrtek\",\n \"Pátek\",\n \"Sobota\",\n \"Neděle\",\n ];\n\n // Leap year check\n const isLeapYear = (year: number) =>\n (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;\n\n // Days in each month\n const daysInMonth = useCallback((month: number, year: number) => {\n if (month === 1) {\n // February\n return isLeapYear(year) ? 29 : 28;\n }\n if ([0, 2, 4, 6, 7, 9, 11].includes(month)) {\n // Months with 31 days\n\n return 31;\n }\n\n return 30; // Months with 30 days\n }, []);\n\n // Generate days for a month\n const generateMonthDays = useCallback(\n (month: number, year: number) => {\n const days = [];\n // const firstDayOfMonth = new Date(year, month, 1).getDay()\n\n // Adjusted to make week start from Monday\n let firstDayOfMonth = new Date(year, month, 1).getDay() - 1;\n if (firstDayOfMonth === -1) firstDayOfMonth = 6; // Sunday becomes 6 instead of -1\n\n let dayCounter = 1;\n\n for (let week = 0; week < 6; week++) {\n const weekDays = [];\n for (let day = 0; day < 7; day++) {\n if (week === 0 && day < firstDayOfMonth) {\n weekDays.push(\"\");\n } else if (dayCounter > daysInMonth(month, year)) {\n weekDays.push(\"\");\n } else {\n weekDays.push(dayCounter++);\n }\n }\n days.push(weekDays);\n }\n return days;\n },\n [daysInMonth]\n );\n\n useEffect(() => {\n setCalendarData(generateMonthDays(currentMonth, currentYear));\n }, [currentMonth, currentYear, generateMonthDays]);\n\n // Navigation handlers\n const goToNextMonth = () => {\n setCurrentMonth((prev) => (prev === 11 ? 0 : prev + 1));\n if (currentMonth === 11) {\n setCurrentYear((prev) => prev + 1);\n }\n };\n\n const goToPreviousMonth = () => {\n setCurrentMonth((prev) => (prev === 0 ? 11 : prev - 1));\n if (currentMonth === 0) {\n setCurrentYear((prev) => prev - 1);\n }\n };\n const findItemsForDay = (\n day: number,\n month: number,\n year: number\n ): ICalendarItem[] => {\n const date = new Date(year, month, day);\n return items.filter((item) => date >= item.from && date <= item.to);\n };\n return (\n <div className=\"flex flex-col bg-white shadow-lg flex-grow text-xs\">\n <div className=\"flex justify-between items-center bg-gray-200 text-black p-4\">\n <h2 className=\"font-semibold text-xl\">\n {monthNames[currentMonth]} {currentYear}\n </h2>\n <div>\n <button\n type=\"button\"\n onClick={goToPreviousMonth}\n className=\"mx-1 px-3 py-2 text-black bg-gray-400 hover:bg-gray-500\"\n >\n Předchozí\n </button>\n <button\n type=\"button\"\n onClick={goToNextMonth}\n className=\"mx-1 px-3 py-2 text-black bg-gray-400 hover:bg-gray-500\"\n >\n Následující\n </button>\n </div>\n </div>\n <div className=\"grid grid-cols-7 divide-x divide-y\">\n {dayNames.map((day, index) => (\n <div key={index} className=\"p-4 text-center font-semibold\">\n {day}\n </div>\n ))}\n {calendarData.map((week, weekIndex) => (\n <React.Fragment key={weekIndex}>\n {week.map((day, dayIndex) => {\n const itemsForDay = day\n ? findItemsForDay(day as number, currentMonth, currentYear)\n : [];\n return (\n <div\n key={dayIndex}\n className=\"p-0 align-middle justify-center text-center\"\n >\n <div className=\"py-1 font-bold\">{day} </div>\n {itemsForDay.map((item, itemIndex) => (\n <div\n key={itemIndex}\n className=\"dataItem w-full py-1 bg-primary text-white text-center mt-0\"\n style={{\n backgroundColor: item.background,\n color: item.color,\n }}\n data-tooltip-target={\"tooltip-\" + item.id}\n title={item.tooltip}\n >\n {item.label}\n </div>\n ))}\n </div>\n );\n })}\n </React.Fragment>\n ))}\n </div>\n </div>\n );\n};\n\nexport default Calendar;\n"],"names":[],"mappings":";;AAkBA,MAAM,WAAoD,CAAC,EAAE,YAAY;AACjE,QAAA,CAAC,cAAc,eAAe,IAAI;AAAA,KACtC,oBAAI,KAAK,GAAE,SAAS;AAAA,EAAA;AAEhB,QAAA,CAAC,aAAa,cAAc,IAAI;AAAA,KACpC,oBAAI,KAAK,GAAE,YAAY;AAAA,EAAA;AAEzB,QAAM,CAAC,cAAc,eAAe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AA,MAAS,SAAA,IAAI,CAAC,KAAK,UAClB,oBAAC,SAAgB,WAAU,iCACxB,UADO,IAAA,GAAA,KAEV,CACD;AAAA,MACA,aAAa,IAAI,CAAC,MAAM,cACvB,oBAAC,MAAM,UAAN,EACE,UAAA,KAAK,IAAI,CAAC,KAAK,aAAa;AAC3B,cAAM,cAAc,MAChB,gBAAgB,KAAe,cAAc,WAAW,IACxD;AAEF,eAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,WAAU;AAAA,YAEV,UAAA;AAAA,cAAC,qBAAA,OAAA,EAAI,WAAU,kBAAkB,UAAA;AAAA,gBAAA;AAAA,gBAAI;AAAA,cAAA,GAAC;AAAA,cACrC,YAAY,IAAI,CAAC,MAAM,cACtB;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBAEC,WAAU;AAAA,kBACV,OAAO;AAAA,oBACL,iBAAiB,KAAK;AAAA,oBACtB,OAAO,KAAK;AAAA,kBACd;AAAA,kBACA,uBAAqB,aAAa,KAAK;AAAA,kBACvC,OAAO,KAAK;AAAA,kBAEX,UAAK,KAAA;AAAA,gBAAA;AAAA,gBATD;AAAA,cAAA,CAWR;AAAA,YAAA;AAAA,UAAA;AAAA,UAjBI;AAAA,QAAA;AAAA,MAkBP,CAEH,EA3BkB,GAAA,SA4BrB,CACD;AAAA,IAAA,GACH;AAAA,EACF,EAAA,CAAA;AAEJ;"}
package/dist/main.d.ts CHANGED
@@ -13,4 +13,6 @@ export type { DataTableColumn } from './components/DataTable.tsx';
13
13
  export * from './contexts/FederationContext.tsx';
14
14
  export * from './contexts/useFederationContext.ts';
15
15
  export * from './utils/getFullName.ts';
16
+ export * from './utils/getIntersectingDays.ts';
17
+ export * from './utils/handleErrors.ts';
16
18
  export * from './types.ts';
package/dist/main.js CHANGED
@@ -12,6 +12,8 @@ import { default as default10 } from "./components/DataTable.js";
12
12
  import { FederationContext, FederationContextProvider } from "./contexts/FederationContext.js";
13
13
  import { useFederationContext } from "./contexts/useFederationContext.js";
14
14
  import { getFullName, getFullNameList } from "./utils/getFullName.js";
15
+ import { getIntersectingDays } from "./utils/getIntersectingDays.js";
16
+ import { handleErrors } from "./utils/handleErrors.js";
15
17
  export {
16
18
  default3 as AutocompleteSearchBar,
17
19
  default2 as Button,
@@ -27,6 +29,8 @@ export {
27
29
  default7 as Spinner,
28
30
  getFullName,
29
31
  getFullNameList,
32
+ getIntersectingDays,
33
+ handleErrors,
30
34
  useFederationContext
31
35
  };
32
36
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
package/dist/types.d.ts CHANGED
@@ -59,3 +59,40 @@ export interface IEmployeePosition extends IUserInfo {
59
59
  position: IPosition;
60
60
  }
61
61
  export type { ICalendarItem } from './components/Calendar';
62
+ export interface ITimeOffCategoryDto {
63
+ id?: number;
64
+ name?: string;
65
+ }
66
+ export interface ITimeOffData {
67
+ id: number;
68
+ startDate: string;
69
+ endDate: string;
70
+ days?: number;
71
+ year?: number;
72
+ comment?: string;
73
+ applicant?: IUserInfo;
74
+ place?: string;
75
+ leaveType?: string;
76
+ initiator?: string;
77
+ dateFromEvidence?: string;
78
+ dateToEvidence?: string;
79
+ daysEvidence?: number;
80
+ status?: number;
81
+ statusText?: string;
82
+ timeOffCategoryDto: ITimeOffCategoryDto;
83
+ applicantContractGroup?: number;
84
+ name?: string;
85
+ daysOfEvidence?: number;
86
+ daysInStartMonth?: number;
87
+ daysInEndMonth?: number;
88
+ lastChange?: string;
89
+ created?: string;
90
+ updated?: string;
91
+ }
92
+ export interface IDepartment {
93
+ departmentId: string;
94
+ nameLong: string;
95
+ parentDepartmentId: string;
96
+ parentLocationId: number;
97
+ nameShort: string;
98
+ }
@@ -0,0 +1,4 @@
1
+ import { ICalendarItem } from '../types';
2
+
3
+ declare const getIntersectingDays: (range: ICalendarItem, ranges: ICalendarItem[]) => number;
4
+ export { getIntersectingDays };
@@ -0,0 +1,22 @@
1
+ const getIntersectingDays = (range, ranges) => {
2
+ if (!range.from || !range.to || !ranges || ranges.length == 0)
3
+ return 0;
4
+ const msInDay = 1e3 * 60 * 60 * 24;
5
+ const calculateOverlap = (start1, end1, start2, end2) => {
6
+ const start = new Date(Math.max(start1.getTime(), start2.getTime()));
7
+ const end = new Date(Math.min(end1.getTime(), end2.getTime()));
8
+ if (start > end) {
9
+ return 0;
10
+ }
11
+ return Math.ceil((end.getTime() - start.getTime()) / msInDay) + 1;
12
+ };
13
+ let totalIntersectingDays = 0;
14
+ ranges == null ? void 0 : ranges.forEach((item) => {
15
+ totalIntersectingDays += calculateOverlap(range.from, range.to, item.from, item.to);
16
+ });
17
+ return totalIntersectingDays;
18
+ };
19
+ export {
20
+ getIntersectingDays
21
+ };
22
+ //# sourceMappingURL=getIntersectingDays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIntersectingDays.js","sources":["../../lib/utils/getIntersectingDays.ts"],"sourcesContent":["import { ICalendarItem } from \"../types\";\r\n\r\nconst getIntersectingDays = (range: ICalendarItem, ranges: ICalendarItem[]): number => {\r\n if (!range.from || !range.to || !ranges || ranges.length == 0) return 0\r\n\r\n const msInDay = 1000 * 60 * 60 * 24\r\n // Helper function to calculate the number of overlapping days between two ranges\r\n const calculateOverlap = (start1: Date, end1: Date, start2: Date, end2: Date): number => {\r\n const start = new Date(Math.max(start1.getTime(), start2.getTime()))\r\n const end = new Date(Math.min(end1.getTime(), end2.getTime()))\r\n\r\n if (start > end) {\r\n return 0\r\n }\r\n\r\n // Calculate the number of days between the start and end dates\r\n return Math.ceil((end.getTime() - start.getTime()) / msInDay) + 1\r\n }\r\n\r\n let totalIntersectingDays = 0\r\n\r\n ranges?.forEach((item) => {\r\n totalIntersectingDays += calculateOverlap(range.from, range.to, item.from, item.to)\r\n })\r\n\r\n return totalIntersectingDays\r\n}\r\nexport { getIntersectingDays }"],"names":[],"mappings":"AAEM,MAAA,sBAAsB,CAAC,OAAsB,WAAoC;AAC/E,MAAA,CAAC,MAAM,QAAQ,CAAC,MAAM,MAAM,CAAC,UAAU,OAAO,UAAU;AAAU,WAAA;AAEhE,QAAA,UAAU,MAAO,KAAK,KAAK;AAEjC,QAAM,mBAAmB,CAAC,QAAc,MAAY,QAAc,SAAuB;AAC/E,UAAA,QAAQ,IAAI,KAAK,KAAK,IAAI,OAAO,WAAW,OAAO,QAAQ,CAAC,CAAC;AAC7D,UAAA,MAAM,IAAI,KAAK,KAAK,IAAI,KAAK,WAAW,KAAK,QAAQ,CAAC,CAAC;AAE7D,QAAI,QAAQ,KAAK;AACN,aAAA;AAAA,IACX;AAGO,WAAA,KAAK,MAAM,IAAI,QAAA,IAAY,MAAM,QAAa,KAAA,OAAO,IAAI;AAAA,EAAA;AAGpE,MAAI,wBAAwB;AAEpB,mCAAA,QAAQ,CAAC,SAAS;AACG,6BAAA,iBAAiB,MAAM,MAAM,MAAM,IAAI,KAAK,MAAM,KAAK,EAAE;AAAA,EAAA;AAG/E,SAAA;AACX;"}
@@ -0,0 +1,6 @@
1
+ import { AxiosError } from 'axios';
2
+ import { Emitter } from 'mitt';
3
+ import { Events } from '../types';
4
+
5
+ declare const handleErrors: (error: AxiosError, emitter: Emitter<Events>, customMessage?: string) => void;
6
+ export { handleErrors };
@@ -0,0 +1,17 @@
1
+ const handleErrors = (error, emitter, customMessage) => {
2
+ var errmsgToDisplay;
3
+ if (error.code == "ERR_BAD_REQUEST") {
4
+ errmsgToDisplay = "Interní chyba aplikace: " + error.message;
5
+ } else {
6
+ errmsgToDisplay = customMessage || error.message;
7
+ }
8
+ console.error(error);
9
+ emitter.emit("message", {
10
+ message: "Interní chyba aplikace " + errmsgToDisplay,
11
+ classes: "bg-error "
12
+ });
13
+ };
14
+ export {
15
+ handleErrors
16
+ };
17
+ //# sourceMappingURL=handleErrors.js.map
@@ -0,0 +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;\r\n if (error.code == 'ERR_BAD_REQUEST') {\r\n errmsgToDisplay = \"Interní chyba aplikace: \" + error.message;\r\n } else {\r\n errmsgToDisplay = customMessage || error.message;\r\n }\r\n console.error(error);\r\n emitter.emit(\"message\", {\r\n message: \"Interní chyba aplikace \" + errmsgToDisplay,\r\n classes: \"bg-error \",\r\n });\r\n}\r\nexport { handleErrors }"],"names":[],"mappings":"AAIA,MAAM,eAAe,CAAC,OAAmB,SAA0B,kBAA2B;AACtF,MAAA;AACA,MAAA,MAAM,QAAQ,mBAAmB;AACjC,sBAAkB,6BAA6B,MAAM;AAAA,EAAA,OAClD;AACH,sBAAkB,iBAAiB,MAAM;AAAA,EAC7C;AACA,UAAQ,MAAM,KAAK;AACnB,UAAQ,KAAK,WAAW;AAAA,IACpB,SAAS,4BAA4B;AAAA,IACrC,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.30",
4
+ "version": "0.0.33",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",