"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useDataTable = void 0;
const react_1 = require("react");
const react_query_1 = require("@tanstack/react-query");
const useDataTable = ({ queryFn, queryKey, transformer, }) => {
    const [{ pageIndex, pageSize }, onPaginationChange] = (0, react_1.useState)({
        pageIndex: 0,
        pageSize: 10,
    });
    const pagination = (0, react_1.useMemo)(() => ({ pageIndex, pageSize }), [pageIndex, pageSize]);
    const queryResponse = (0, react_query_1.useQuery)({
        queryFn: () => queryFn({ pageIndex, pageSize }),
        queryKey: [queryKey, pageIndex, pageSize],
    });
    return {
        pagination,
        onPaginationChange,
        queryResponse,
        transformer,
    };
};
exports.useDataTable = useDataTable;
//# sourceMappingURL=use-data-table.js.map