/** * @license * Copyright Stbui All Rights Reserved. * https://github.com/stbui/prophet */ import { useSelector, shallowEqual } from 'react-redux'; import useQueryWithStore from './useQueryWithStore'; import { GET_LIST, CRUD_GET_LIST } from '../actions'; import { Pagination, Sort } from '../types'; export interface UseGetListValue { data?: any; total?: number; error?: any; loading?: boolean; loaded?: boolean; ids?: any; } /** * useGetList * * @param {string} resource * @param {Object} pagination * @param {Object} filter * @param {Object} sort * @param {Object} options * @param {string} options.action * @param {Function} options.onSuccess * @param {Function} options.onFailure * * @returns { data, ids, total, loading, loaded, error } * * @example * * import { useGetList } from '@stbui/prophet-core'; * * const UserList = () => { * const { data, ids, loading, error } = useGetList( * 'users', * { page: 1, perPage: 10 }, * { username: 'stbui' }, * { field: 'id', order: 'DESC' } * ); * * if (loading) { return 'loading'; } * if (error) { return error.message; } * * return