useDeadRageSelectors.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {useApiQuery} from 'sentry/utils/queryClient';
  2. import {useLocation} from 'sentry/utils/useLocation';
  3. import useOrganization from 'sentry/utils/useOrganization';
  4. import {
  5. DeadRageSelectorListResponse,
  6. DeadRageSelectorQueryParams,
  7. } from 'sentry/views/replays/types';
  8. export default function useRageDeadSelectors(params: DeadRageSelectorQueryParams) {
  9. const organization = useOrganization();
  10. const location = useLocation();
  11. const {query} = location;
  12. const {isLoading, isError, data, getResponseHeader} =
  13. useApiQuery<DeadRageSelectorListResponse>(
  14. [
  15. `/organizations/${organization.slug}/replay-selectors/`,
  16. {
  17. query: {
  18. cursor: params.cursor,
  19. environment: query.environment,
  20. project: query.project,
  21. statsPeriod: query.statsPeriod,
  22. per_page: params.per_page,
  23. sort: query[params.prefix + 'sort'] ?? params.sort,
  24. },
  25. },
  26. ],
  27. {staleTime: Infinity}
  28. );
  29. return {
  30. isLoading,
  31. isError,
  32. data: data ? data.data : [],
  33. pageLinks: getResponseHeader?.('Link') ?? undefined,
  34. };
  35. }