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

type Props = {
    withPlaceholders?: boolean;

}
const useServicesList = (props: Props) => {
    const { withPlaceholders = false } = props;

    const { isPending, error, data, refetch } = useQuery({
        queryKey: ["getAllServices", withPlaceholders],
        queryFn: () => ServiceService.getAllServices({ withPlaceholders: withPlaceholders }),
    });
    const services = isPending || error || !data ? [] : data.services;

    return { services, refetch };
};
export default useServicesList;
