useFetchGroupSearchViews.tsx 808 B

123456789101112131415161718192021222324252627
  1. import type {UseApiQueryOptions} from 'sentry/utils/queryClient';
  2. import {useApiQuery} from 'sentry/utils/queryClient';
  3. import type {GroupSearchView} from 'sentry/views/issueList/types';
  4. type FetchGroupSearchViewsParameters = {
  5. orgSlug: string;
  6. };
  7. type FetchGroupSearchViewsResponse = GroupSearchView[];
  8. export const makeFetchGroupSearchViewsKey = ({
  9. orgSlug,
  10. }: FetchGroupSearchViewsParameters) =>
  11. [`/organizations/${orgSlug}/group-search-views/`] as const;
  12. export const useFetchGroupSearchViewsForOrg = (
  13. {orgSlug}: FetchGroupSearchViewsParameters,
  14. options: Partial<UseApiQueryOptions<FetchGroupSearchViewsResponse>> = {}
  15. ) => {
  16. return useApiQuery<FetchGroupSearchViewsResponse>(
  17. makeFetchGroupSearchViewsKey({orgSlug}),
  18. {
  19. staleTime: Infinity,
  20. ...options,
  21. }
  22. );
  23. };