diff --git a/static/app/views/issueList/queries/useFetchIssueCounts.tsx b/static/app/views/issueList/queries/useFetchIssueCounts.tsx new file mode 100644 index 00000000000000..386e855332a061 --- /dev/null +++ b/static/app/views/issueList/queries/useFetchIssueCounts.tsx @@ -0,0 +1,36 @@ +import type {ApiQueryKey, UseApiQueryOptions} from 'sentry/utils/queryClient'; +import {useApiQuery} from 'sentry/utils/queryClient'; +import type {QueryCount, QueryCounts} from 'sentry/views/issueList/utils'; + +interface FetchIssueCountsParameters { + environment: string[]; + orgSlug: string; + project: number[]; + query: string[]; + end?: string | null; + groupStatsPeriod?: string | null; + sort?: string; + start?: string | null; + statsPeriod?: string | null; + useGroupSnubaDataset?: boolean; +} + +export const makeFetchIssueCounts = ({ + orgSlug, + ...requestParams +}: FetchIssueCountsParameters): ApiQueryKey => [ + `/organizations/${orgSlug}/issues-count/`, + { + query: requestParams, + }, +]; + +export const useFetchIssueCounts = ( + params: FetchIssueCountsParameters, + options: Partial>> = {} +) => { + return useApiQuery(makeFetchIssueCounts(params), { + staleTime: 0, + ...options, + }); +}; diff --git a/static/app/views/issueList/utils.tsx b/static/app/views/issueList/utils.tsx index 232de49093202c..a43e94f937bd4d 100644 --- a/static/app/views/issueList/utils.tsx +++ b/static/app/views/issueList/utils.tsx @@ -163,7 +163,7 @@ export function isForReviewQuery(query: string | undefined) { // the tab counts will look like 99+ export const TAB_MAX_COUNT = 99; -type QueryCount = { +export type QueryCount = { count: number; hasMore: boolean; };