useFetchSavedSearchesForOrg.tsx 808 B

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