Skip to content

Commit

Permalink
Removed service object from the props.
Browse files Browse the repository at this point in the history
Signed-off-by: kishor82 <kishorrathva8298@gmail.com>
  • Loading branch information
kishor82 committed Dec 19, 2023
1 parent d04f92f commit f170f1e
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@
*/

import { useState, useMemo, useCallback } from 'react';
import { DiscoverServices } from '../../../build_services';
import { SAMPLE_SIZE_SETTING } from '../../../../common';
import { generatePageSizeOptions } from './page_size_options';
export interface Props {
services: DiscoverServices;
pageSizeLimit: number;
rowCount: number;
}

export const usePagination = ({ rowCount, services }: Props) => {
const { uiSettings } = services;

export const usePagination = ({ rowCount, pageSizeLimit }: Props) => {
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 100 });
const pageCount = useMemo(() => Math.ceil(rowCount / pagination.pageSize), [
rowCount,
pagination,
]);
const sampleSize = uiSettings.get(SAMPLE_SIZE_SETTING);

const pageSizeOptions = generatePageSizeOptions(sampleSize);
const pageSizeOptions = generatePageSizeOptions(pageSizeLimit);

const onChangeItemsPerPage = useCallback(
(pageSize: number) => setPagination((p) => ({ ...p, pageSize })),
Expand Down

0 comments on commit f170f1e

Please sign in to comment.