@addsign/moje-agenda-shared-lib 0.0.90 → 0.0.92

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.
@@ -21719,51 +21719,13 @@ function DataTableServer({
21719
21719
  totalPages: ((_g = response.data) == null ? void 0 : _g.totalPages) || 1
21720
21720
  };
21721
21721
  };
21722
+ const [reloadData, setReloadData] = useState(false);
21722
21723
  useEffect(() => {
21723
- console.log(
21724
- "%clibcomponentsdatatableDataTableServer.tsx:103 currentPage",
21725
- "color: #007acc;",
21726
- currentPage
21727
- );
21728
- if (currentPage === void 0)
21729
- return;
21730
- setIsLoading(true);
21731
- federationContext.apiClient.get(url, {
21732
- params: {
21733
- ...filters,
21734
- ...showColFilters ? columnFilters : {},
21735
- pageSize: itemsPerPage,
21736
- page: currentPage,
21737
- sortBy: sortConfig == null ? void 0 : sortConfig.sortParam,
21738
- sortDirection: sortConfig == null ? void 0 : sortConfig.direction
21739
- }
21740
- }).then((response) => {
21741
- const dataPageable = createDataPageable(
21742
- response,
21743
- itemsPerPage
21744
- );
21745
- setData(dataPageable);
21746
- setIsLoading(false);
21747
- }).catch((error) => {
21748
- console.error("Error fetching data:", error);
21749
- handleErrors(error, federationContext.emitter);
21750
- setData({
21751
- content: [],
21752
- empty: true,
21753
- first: true,
21754
- last: true,
21755
- number: 0,
21756
- numberOfElements: 0,
21757
- size: itemsPerPage,
21758
- totalElements: 0,
21759
- totalPages: 1
21760
- });
21761
- setIsLoading(false);
21762
- });
21724
+ setReloadData(true);
21763
21725
  }, [
21764
21726
  url,
21765
21727
  showColFilters,
21766
- id,
21728
+ // id,
21767
21729
  columnFilters,
21768
21730
  itemsPerPage,
21769
21731
  currentPage,
@@ -21773,6 +21735,71 @@ function DataTableServer({
21773
21735
  filters,
21774
21736
  tableKey
21775
21737
  ]);
21738
+ useEffect(() => {
21739
+ if (reloadData) {
21740
+ if (currentPage === void 0)
21741
+ return;
21742
+ setIsLoading(true);
21743
+ federationContext.apiClient.get(url, {
21744
+ params: {
21745
+ ...filters,
21746
+ ...showColFilters ? columnFilters : {},
21747
+ pageSize: itemsPerPage,
21748
+ page: currentPage,
21749
+ sortBy: sortConfig == null ? void 0 : sortConfig.sortParam,
21750
+ sortDirection: sortConfig == null ? void 0 : sortConfig.direction
21751
+ }
21752
+ }).then((response) => {
21753
+ const dataPageable = createDataPageable(
21754
+ response,
21755
+ itemsPerPage
21756
+ );
21757
+ setData(dataPageable);
21758
+ setIsLoading(false);
21759
+ }).catch((error) => {
21760
+ console.error("Error fetching data:", error);
21761
+ handleErrors(error, federationContext.emitter);
21762
+ setData({
21763
+ content: [],
21764
+ empty: true,
21765
+ first: true,
21766
+ last: true,
21767
+ number: 0,
21768
+ numberOfElements: 0,
21769
+ size: itemsPerPage,
21770
+ totalElements: 0,
21771
+ totalPages: 1
21772
+ });
21773
+ setIsLoading(false);
21774
+ });
21775
+ setReloadData(false);
21776
+ }
21777
+ }, [reloadData]);
21778
+ useEffect(() => {
21779
+ Object.keys(localStorage).filter(
21780
+ (key) => key.startsWith("datatable:") && key !== `datatable:${id}`
21781
+ ).forEach((key) => {
21782
+ const storageObject = localStorage.getItem(key);
21783
+ if (storageObject) {
21784
+ const parsedObject = JSON.parse(storageObject);
21785
+ parsedObject.currentPage = 0;
21786
+ localStorage.setItem(key, JSON.stringify(parsedObject));
21787
+ }
21788
+ });
21789
+ }, [id]);
21790
+ useEffect(() => {
21791
+ if (id) {
21792
+ const storageKey = `datatable:${id}`;
21793
+ const storedStorageObject = localStorage.getItem(storageKey);
21794
+ if (storedStorageObject) {
21795
+ const storageObject = JSON.parse(storedStorageObject);
21796
+ setColumnFilters(storageObject.columnFilters);
21797
+ setShowColFilters(storageObject.showColFilters);
21798
+ setCurrentPage(storageObject.currentPage || 0);
21799
+ setSortConfig(null);
21800
+ }
21801
+ }
21802
+ }, [id]);
21776
21803
  useEffect(() => {
21777
21804
  const fetchFilterOptions = async (column) => {
21778
21805
  if (column.filterSource) {
@@ -21878,18 +21905,6 @@ function DataTableServer({
21878
21905
  }
21879
21906
  setShowColFilters(!showColFilters);
21880
21907
  };
21881
- useEffect(() => {
21882
- if (id) {
21883
- const storageKey = `datatable:${id}`;
21884
- const storedStorageObject = localStorage.getItem(storageKey);
21885
- if (storedStorageObject) {
21886
- const storageObject = JSON.parse(storedStorageObject);
21887
- setColumnFilters(storageObject.columnFilters);
21888
- setShowColFilters(storageObject.showColFilters);
21889
- setCurrentPage(storageObject.currentPage || 0);
21890
- }
21891
- }
21892
- }, [id]);
21893
21908
  useEffect(() => {
21894
21909
  if (id) {
21895
21910
  const storageKey = `datatable:${id}`;
@@ -21900,7 +21915,7 @@ function DataTableServer({
21900
21915
  ) : {};
21901
21916
  storageObject.columnFilters = columnFilters || {};
21902
21917
  storageObject.showColFilters = showColFilters || false;
21903
- storageObject.currentPage = currentPage || storageObject.currentPage || 0;
21918
+ storageObject.currentPage = currentPage !== void 0 ? currentPage : storageObject.currentPage || 0;
21904
21919
  localStorage.setItem(storageKey, JSON.stringify(storageObject));
21905
21920
  }
21906
21921
  }, [columnFilters, showColFilters, currentPage, id]);
@@ -21955,11 +21970,6 @@ function DataTableServer({
21955
21970
  handleErrors,
21956
21971
  columns
21957
21972
  ]);
21958
- console.log(
21959
- "%clibcomponentsdatatableDataTableServer.tsx:392 data",
21960
- "color: #007acc;",
21961
- data
21962
- );
21963
21973
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
21964
21974
  "div",
21965
21975
  {
@@ -22206,7 +22216,7 @@ function DataTableServer({
22206
22216
  variant: "secondary",
22207
22217
  onClick: prevPage,
22208
22218
  className: "flex items-center",
22209
- disabled: data.first,
22219
+ disabled: data.first || isLoading,
22210
22220
  children: [
22211
22221
  /* @__PURE__ */ jsx(MdArrowBack, { className: "mr-1.5" }),
22212
22222
  " Předchozí"
@@ -22219,7 +22229,7 @@ function DataTableServer({
22219
22229
  variant: "secondary",
22220
22230
  onClick: nextPage,
22221
22231
  className: "flex items-center",
22222
- disabled: data.last,
22232
+ disabled: data.last || isLoading,
22223
22233
  children: [
22224
22234
  "Následující ",
22225
22235
  /* @__PURE__ */ jsx(MdArrowForward, { className: "ml-2", size: 20 })