@addsign/moje-agenda-shared-lib 0.0.88 → 0.0.89

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.
@@ -21698,7 +21698,7 @@ function DataTableServer({
21698
21698
  const [data, setData] = useState();
21699
21699
  const [isLoading, setIsLoading] = useState(false);
21700
21700
  const [tableKey, setTableKey] = useState(0);
21701
- const [currentPage, setCurrentPage] = useState(0);
21701
+ const [currentPage, setCurrentPage] = useState();
21702
21702
  const [selectedItems, setSelectedItems] = useState([]);
21703
21703
  const [fulltextSearch, setFulltextSearch] = useState("");
21704
21704
  const [filterOptions, setFilterOptions] = useState({});
@@ -21720,6 +21720,11 @@ function DataTableServer({
21720
21720
  };
21721
21721
  };
21722
21722
  useEffect(() => {
21723
+ console.log(
21724
+ "%clibcomponentsdatatableDataTableServer.tsx:103 currentPage",
21725
+ "color: #007acc;",
21726
+ currentPage
21727
+ );
21723
21728
  setIsLoading(true);
21724
21729
  federationContext.apiClient.get(url, {
21725
21730
  params: {
@@ -21850,17 +21855,17 @@ function DataTableServer({
21850
21855
  return selectedItems.some((selectedItem) => selectedItem.id === item.id);
21851
21856
  };
21852
21857
  const nextPage = () => {
21853
- setCurrentPage(currentPage + 1);
21858
+ setCurrentPage((currentPage || 0) + 1);
21854
21859
  };
21855
21860
  const prevPage = () => {
21856
- setCurrentPage(currentPage - 1);
21861
+ setCurrentPage((currentPage || 0) - 1);
21857
21862
  };
21858
21863
  const handleSearchChanged = (e) => {
21859
21864
  var _a2;
21860
21865
  setFulltextSearch((_a2 = e.target) == null ? void 0 : _a2.value);
21861
21866
  setCurrentPage(0);
21862
21867
  };
21863
- const paginationDisplay = `Strana ${currentPage + 1} z ${data == null ? void 0 : data.totalPages}`;
21868
+ const paginationDisplay = `Strana ${(currentPage || 0) + 1} z ${data == null ? void 0 : data.totalPages}`;
21864
21869
  const filterHandler = (filterParam, value) => {
21865
21870
  setColumnFilters((prev) => ({ ...prev, [filterParam]: value }));
21866
21871
  setCurrentPage(0);
@@ -21879,18 +21884,24 @@ function DataTableServer({
21879
21884
  const storageObject = JSON.parse(storedStorageObject);
21880
21885
  setColumnFilters(storageObject.columnFilters);
21881
21886
  setShowColFilters(storageObject.showColFilters);
21887
+ setCurrentPage(storageObject.currentPage || 0);
21882
21888
  }
21883
21889
  }
21884
21890
  }, [id]);
21885
21891
  useEffect(() => {
21886
- if (id && columnFilters !== void 0 && showColFilters !== void 0) {
21892
+ if (id) {
21887
21893
  const storageKey = `datatable:${id}`;
21888
- const storageObject = localStorage.getItem(storageKey) ? JSON.parse(localStorage.getItem(storageKey)) : {};
21889
- storageObject.columnFilters = columnFilters;
21890
- storageObject.showColFilters = showColFilters;
21894
+ const storageObject = localStorage.getItem(
21895
+ storageKey
21896
+ ) ? JSON.parse(
21897
+ localStorage.getItem(storageKey)
21898
+ ) : {};
21899
+ storageObject.columnFilters = columnFilters || {};
21900
+ storageObject.showColFilters = showColFilters || false;
21901
+ storageObject.currentPage = currentPage || storageObject.currentPage || 0;
21891
21902
  localStorage.setItem(storageKey, JSON.stringify(storageObject));
21892
21903
  }
21893
- }, [columnFilters, showColFilters, id]);
21904
+ }, [columnFilters, showColFilters, currentPage, id]);
21894
21905
  const rerenderTable = () => {
21895
21906
  setTableKey((previous) => previous + 1);
21896
21907
  };