useFetchFeedbackIssue.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import hydrateFeedbackRecord from 'sentry/components/feedback/hydrateFeedbackRecord';
  2. import {Event, Organization} from 'sentry/types';
  3. import {RawFeedbackItemResponse} from 'sentry/utils/feedback/item/types';
  4. import {useApiQuery, type UseApiQueryOptions} from 'sentry/utils/queryClient';
  5. interface Props {
  6. feedbackId: string;
  7. organization: Organization;
  8. }
  9. export default function useFetchFeedbackIssue(
  10. {feedbackId, organization}: Props,
  11. options: undefined | Partial<UseApiQueryOptions<RawFeedbackItemResponse>> = {}
  12. ) {
  13. const {data: issueData, ...issueResult} = useApiQuery<RawFeedbackItemResponse>(
  14. [
  15. `/organizations/${organization.slug}/issues/${feedbackId}/`,
  16. {
  17. query: {
  18. collapse: ['release', 'tags'],
  19. expand: ['inbox', 'owners'],
  20. },
  21. },
  22. ],
  23. {
  24. staleTime: 0,
  25. ...options,
  26. }
  27. );
  28. const {data: eventData, ...eventResult} = useApiQuery<Event>(
  29. [`/organizations/${organization.slug}/issues/${feedbackId}/events/latest/`],
  30. {
  31. staleTime: 0,
  32. }
  33. );
  34. return {
  35. issueData: issueData ? hydrateFeedbackRecord(issueData) : undefined,
  36. eventData,
  37. eventResult,
  38. ...issueResult,
  39. };
  40. }