useFetchGroupSearchViews.tsx 703 B

12345678910111213141516171819202122
  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. export const makeFetchGroupSearchViewsKey = ({
  8. orgSlug,
  9. }: FetchGroupSearchViewsParameters) =>
  10. [`/organizations/${orgSlug}/group-search-views/`] as const;
  11. export const useFetchGroupSearchViews = (
  12. {orgSlug}: FetchGroupSearchViewsParameters,
  13. options: Partial<UseApiQueryOptions<GroupSearchView[]>> = {}
  14. ) => {
  15. return useApiQuery<GroupSearchView[]>(makeFetchGroupSearchViewsKey({orgSlug}), {
  16. staleTime: Infinity,
  17. ...options,
  18. });
  19. };