mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-20 01:33:05 +00:00
- HomeSearchResultsShell renderiza 'Nenhuma sugestão ainda — priorize municípios na planilha de projeção' quando o suggest responde success sem hits (Início e FAB overlay compartilham o shell; SSR initialSuggest e POST cobertos); gateada por !isFetching para não falar sob o skeleton - B126 e2e determinístico: pin um município priority alta claimado; testes OPS29 novos usam advisor sem carteira (scoped, imune a alta global de workers paralelos); settle de animação do overlay no B126 - unit: 3 casos novos no shell + overlap skeleton/mensagem
40 lines
1.7 KiB
TypeScript
40 lines
1.7 KiB
TypeScript
'use client'
|
|
|
|
import type { ReactNode } from 'react'
|
|
|
|
import { useHomeSearch } from '@/components/campaign/dashboard/HomeSearchContext'
|
|
import { useHomeSearchResults } from '@/components/campaign/dashboard/HomeSearchResultsContext'
|
|
import { HomeSearchSuggestSkeleton } from '@/components/campaign/dashboard/HomeSearchSuggestSkeleton'
|
|
import { homeSearchHasAnyHits } from '@/lib/campaignHomeSearchHits'
|
|
import { HOME_SEARCH_SUGGEST_EMPTY_MESSAGE } from '@/lib/campaignHomeSearchMessages'
|
|
|
|
export const HomeSearchResultsShell = ({ children }: { children: ReactNode }) => {
|
|
const { query } = useHomeSearch()
|
|
const { results, resultKind, isFetching } = useHomeSearchResults()
|
|
|
|
const hasRenderableHits = results.status === 'success' && homeSearchHasAnyHits(results.data)
|
|
const showSkeleton = isFetching && !hasRenderableHits && results.status !== 'error'
|
|
|
|
const showEmpty = query.isActive && resultKind === 'search' && !hasRenderableHits
|
|
|
|
// `isFetching` keeps the message out of the debounce/skeleton window: while
|
|
// the user starts typing from an empty suggest, the skeleton covers the
|
|
// transition and the stale empty payload must not also speak (OPS29).
|
|
const showSuggestEmpty = resultKind === 'suggest' && !hasRenderableHits && !isFetching
|
|
|
|
return (
|
|
<>
|
|
{showSkeleton ? <HomeSearchSuggestSkeleton /> : null}
|
|
{!showSkeleton ? children : null}
|
|
{results.status === 'error' ? (
|
|
<p className="text-sm text-destructive" role="alert">
|
|
{results.message}
|
|
</p>
|
|
) : null}
|
|
{showEmpty ? <p className="text-sm text-muted-foreground">Nenhum resultado.</p> : null}
|
|
{showSuggestEmpty ? (
|
|
<p className="text-sm text-muted-foreground">{HOME_SEARCH_SUGGEST_EMPTY_MESSAGE}</p>
|
|
) : null}
|
|
</>
|
|
)
|
|
}
|