Files
Verso/services/web/modules/full-project-search/frontend/js/components/full-project-match-counts.tsx
T
Jakob AckermannandCopybot 67342e9c33 [terraform] clsi: add pre-emp C2D capacity in zone b (#26755)
GitOrigin-RevId: aa52dec1f7135f53f8c887199c1d1e4e31ef70ff
2025-07-03 08:04:53 +00:00

34 lines
864 B
TypeScript

import React, { FC } from 'react'
import LoadingSpinner from '@/shared/components/loading-spinner'
import { MatchedFile } from '../util/search-snapshot'
import { useTranslation } from 'react-i18next'
export const FullProjectMatchCounts: FC<{
loading: boolean
totalResults?: number
matchedFiles?: MatchedFile[]
}> = ({ loading, matchedFiles }) => {
const { t } = useTranslation()
if (loading) {
return <LoadingSpinner delay={500} />
}
if (matchedFiles === undefined) {
return null
}
const totalResults = matchedFiles.flatMap(file => file.hits).length
if (totalResults === 0) {
return <>{t('project_search_result_count', { count: totalResults })}</>
}
return (
<>
{t('project_search_result_count', { count: totalResults })}{' '}
{t('project_search_file_count', { count: matchedFiles.length })}
</>
)
}