11import { useState } from 'react' ;
22import styled from '@emotion/styled' ;
3+ import { useQuery } from '@tanstack/react-query' ;
34
45import { Alert } from '@sentry/scraps/alert' ;
56import { InputGroup } from '@sentry/scraps/input' ;
@@ -24,10 +25,10 @@ import {
2425import { IconBranch } from 'sentry/icons/iconBranch' ;
2526import { t } from 'sentry/locale' ;
2627import { trackAnalytics } from 'sentry/utils/analytics' ;
27- import { getApiUrl } from 'sentry/utils/api/getApiUrl ' ;
28+ import { selectJsonWithHeaders } from 'sentry/utils/api/apiOptions ' ;
2829import { parseApiError } from 'sentry/utils/parseApiError' ;
2930import { parseLinkHeader } from 'sentry/utils/parseLinkHeader' ;
30- import { useApiQuery , useMutation } from 'sentry/utils/queryClient' ;
31+ import { useMutation } from 'sentry/utils/queryClient' ;
3132import { decodeScalar } from 'sentry/utils/queryString' ;
3233import type { RequestError } from 'sentry/utils/requestError/requestError' ;
3334import { useLocationQuery } from 'sentry/utils/url/useLocationQuery' ;
@@ -39,6 +40,7 @@ import {
3940 isSizeInfoCompleted ,
4041 type BuildDetailsApiResponse ,
4142} from 'sentry/views/preprod/types/buildDetailsTypes' ;
43+ import { buildDetailsApiOptions } from 'sentry/views/preprod/utils/buildDetailsApiOptions' ;
4244import {
4345 getCompareApiUrl ,
4446 getCompareBuildPath ,
@@ -88,26 +90,20 @@ export function SizeCompareSelectionContent({
8890 }
8991 const fullQuery = searchFilters . join ( ' ' ) ;
9092
91- const queryParams : Record < string , any > = {
92- per_page : 25 ,
93- project : headBuildDetails . project_id ,
94- query : fullQuery ,
95- ...( cursor && { cursor} ) ,
96- } ;
97-
98- const buildsQuery = useApiQuery < BuildDetailsApiResponse [ ] > (
99- [
100- getApiUrl ( `/organizations/$organizationIdOrSlug/builds/` , {
101- path : { organizationIdOrSlug : organization . slug } ,
102- } ) ,
103- { query : queryParams } ,
104- ] ,
105- {
106- staleTime : 0 ,
107- }
108- ) ;
93+ const buildsQuery = useQuery ( {
94+ ...buildDetailsApiOptions ( {
95+ organization,
96+ queryParams : {
97+ per_page : 25 ,
98+ project : headBuildDetails . project_id ,
99+ query : fullQuery ,
100+ ...( cursor && { cursor} ) ,
101+ } ,
102+ } ) ,
103+ select : selectJsonWithHeaders ,
104+ } ) ;
109105
110- const pageLinks = buildsQuery . getResponseHeader ?. ( ' Link' ) || null ;
106+ const pageLinks = buildsQuery . data ?. headers . Link || null ;
111107
112108 const parsedLinks = pageLinks ? parseLinkHeader ( pageLinks ) : { } ;
113109 const hasPagination =
@@ -194,9 +190,9 @@ export function SizeCompareSelectionContent({
194190 { buildsQuery . isError && (
195191 < Alert variant = "danger" > { buildsQuery . error ?. message } </ Alert >
196192 ) }
197- { buildsQuery . data && (
193+ { buildsQuery . data ?. json && (
198194 < Stack gap = "md" >
199- { buildsQuery . data ? .map ( build => {
195+ { buildsQuery . data . json . map ( build => {
200196 if ( build . id === headBuildDetails . id ) {
201197 return null ;
202198 }
0 commit comments