import { useQuery } from 'react-query' ; import { useKibana } from '../common/lib/kibana' ; import { GetOnePackagePolicyResponse } from '../../../fleet/common' ; import { OsqueryManagerPackagePolicy } from '../../common/types' ; interface UsePack { packId : string ; skip ? : boolean ; } export const usePack = ( { packId , skip = false } ) => { const { http } = useKibana ( ) . services ; return useQuery < Omit < GetOnePackagePolicyResponse , 'item' > & { item : OsqueryManagerPackagePolicy ; } , unknown , OsqueryManagerPackagePolicy > ( [ 'pack' , { packId } ] , ( ) => http . get ( `/internal/osquery/packs/${ packId }` ) , { keepPreviousData : true , enabled : ! skip || ! packId , } ) ; } ;