refactor: refactored products utils
This commit is contained in:
@ -1,20 +0,0 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { ProductService } from "../../../client";
|
||||
|
||||
type Props = {
|
||||
clientId: number;
|
||||
page?: number;
|
||||
itemsPerPage?: number;
|
||||
searchInput: string;
|
||||
};
|
||||
const useProductsList = (props: Props) => {
|
||||
const { clientId, page, itemsPerPage, searchInput } = props;
|
||||
const { data, refetch, isLoading } = useQuery({
|
||||
queryKey: ["getAllServices", clientId, page, itemsPerPage, searchInput],
|
||||
queryFn: () => ProductService.getProductsByClientId(props),
|
||||
});
|
||||
const products = !data ? [] : data.products;
|
||||
const paginationInfo = data?.paginationInfo;
|
||||
return { products, paginationInfo, refetch, isLoading };
|
||||
};
|
||||
export default useProductsList;
|
||||
Reference in New Issue
Block a user