import {ProductService} from "../../client";
import {useQuery} from "@tanstack/react-query";

export const useGetProductById = (id: number) => {
    const {data, error, isLoading, refetch} = useQuery({
        queryKey: ['getProductById', id],
        queryFn: () => ProductService.getProductById({productId: id}),
        select: (data) => data
    });
    return {product: data, error, isLoading, refetch}
}