aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/rest/component-pagination.model.ts
blob: 59d70c1e853afd18bcc39293e3571959179490d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export interface ComponentPagination {
  currentPage: number
  itemsPerPage: number
  totalItems: number
}

export type ComponentPaginationLight = Omit<ComponentPagination, 'totalItems'> & { totalItems?: number }

export function hasMoreItems (componentPagination: ComponentPagination) {
  // No results
  if (componentPagination.totalItems === 0) return false

  // Not loaded yet
  if (!componentPagination.totalItems) return true

  const maxPage = componentPagination.totalItems / componentPagination.itemsPerPage
  return maxPage > componentPagination.currentPage
}