@resourge/react-fetch
Version:
[](LICENSE)
36 lines (35 loc) • 1.23 kB
TypeScript
/**
* react-fetch v1.41.3
*
* Copyright (c) resourge.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
import { type FetchState } from '../hooks/useFetch';
import { type UseFetchError } from '../services/NotificationService';
import { type PaginationMetadata, type ResetPaginationMetadataType } from './PaginationConfig';
export type PaginationMethod<Data, FilterSearchParams extends Record<string, any> = Record<string, any>> = (metadata: PaginationMetadata<FilterSearchParams>) => Promise<{
data: Data;
totalItems?: number;
}>;
export type PaginationFunctionsType<Data, FilterSearchParams extends Record<string, any> = Record<string, any>> = {
/**
* Changes items per page
*/
changeItemsPerPage: (perPage: number) => void;
data: Data;
error: UseFetchError;
/**
* Fetch current pagination
*/
fetch: () => Promise<Data>;
isLoading: boolean;
/**
* Resets the pagination, sort and/or filter.
*/
reset: (newSearchParams?: ResetPaginationMetadataType<FilterSearchParams>) => void;
setPaginationState: FetchState<Data, any>['setFetchState'];
};