All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.util.pebble Maven / Gradle / Ivy

There is a newer version: 3.3.2
Show newest version
import { PageableResult } from "@rocketbase/commons-core";
import { InfiniteData } from '{% if reactQueryVersion.name equals "v4" %}@tanstack/{% endif %}react-query';

export function createPaginationOptions>() {
  return {
    getPreviousPageParam: ({page } : T) => {
      return page !== 0 ? page - 1 : 0;
    },
    getNextPageParam: ({page, totalPages}:  T) => {
      return page < totalPages - 1 ? page + 1 : undefined;
    },
  }
}


export function infiniteTotalElements(
  data: InfiniteData>
): number {
  if (data && Array.isArray(data?.pages) && data?.pages.length) {
    return data.pages[0].totalElements;
  }
  return 0;
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy