refactor: refactored products utils

This commit is contained in:
2025-10-25 19:35:00 +04:00
parent d9da3d1bc5
commit e39df47520
4 changed files with 37 additions and 53 deletions

View File

@ -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;