useFetchSavedSearchesForOrg.tsx 751 B

1234567891011121314151617181920212223242526
  1. import {SavedSearch} from 'sentry/types';
  2. import {useApiQuery, UseApiQueryOptions} from 'sentry/utils/queryClient';
  3. type FetchSavedSearchesForOrgParameters = {
  4. orgSlug: string;
  5. };
  6. type FetchSavedSearchesForOrgResponse = SavedSearch[];
  7. export const makeFetchSavedSearchesForOrgQueryKey = ({
  8. orgSlug,
  9. }: FetchSavedSearchesForOrgParameters) =>
  10. [`/organizations/${orgSlug}/searches/`] as const;
  11. export const useFetchSavedSearchesForOrg = (
  12. {orgSlug}: FetchSavedSearchesForOrgParameters,
  13. options: Partial<UseApiQueryOptions<FetchSavedSearchesForOrgResponse>> = {}
  14. ) => {
  15. return useApiQuery<FetchSavedSearchesForOrgResponse>(
  16. makeFetchSavedSearchesForOrgQueryKey({orgSlug}),
  17. {
  18. staleTime: 30000,
  19. ...options,
  20. }
  21. );
  22. };