mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-20 18:24:45 +00:00
refactor(C216-FOLLOWUP-DRY): heading único dos resultados do acervo (F2) (Related #1325)
This commit is contained in:
parent
329662668e
commit
17cd5d0b8d
1 changed files with 85 additions and 73 deletions
|
|
@ -3,6 +3,7 @@ import { ScissorsIcon, SearchIcon, SearchXIcon, VideoIcon } from 'lucide-react'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { redirect } from 'next/navigation'
|
import { redirect } from 'next/navigation'
|
||||||
import { getPayload } from 'payload'
|
import { getPayload } from 'payload'
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
|
||||||
import { RecordingAcervoFilters } from '@/components/campaign/recording/RecordingAcervoFilters'
|
import { RecordingAcervoFilters } from '@/components/campaign/recording/RecordingAcervoFilters'
|
||||||
import { RecordingResultList } from '@/components/campaign/recording/RecordingResultList'
|
import { RecordingResultList } from '@/components/campaign/recording/RecordingResultList'
|
||||||
|
|
@ -89,6 +90,50 @@ const AcervoHeader = ({ source }: { source: AcervoSource }) => (
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* C216 — the results heading every source repeats: the theme ladder (exact
|
||||||
|
* term / theme / idle) and the hint line of `mode=tema`. The caller owns the
|
||||||
|
* right side (`controls`: the Câmara leaves the retry button bare, the other
|
||||||
|
* two wrap it with their sort select) and whether the row renders at all.
|
||||||
|
*/
|
||||||
|
const AcervoResultsHeading = ({
|
||||||
|
themeMode,
|
||||||
|
themeActive,
|
||||||
|
themeUnavailable,
|
||||||
|
idleTitle,
|
||||||
|
subject,
|
||||||
|
controls,
|
||||||
|
}: {
|
||||||
|
themeMode: boolean
|
||||||
|
themeActive: boolean
|
||||||
|
themeUnavailable: boolean
|
||||||
|
idleTitle: string
|
||||||
|
subject: 'fala' | 'gravação'
|
||||||
|
controls: ReactNode
|
||||||
|
}) => (
|
||||||
|
<div className="flex flex-wrap items-end justify-between gap-3">
|
||||||
|
<div>
|
||||||
|
<h2 className="text-sm font-semibold">
|
||||||
|
{themeUnavailable
|
||||||
|
? 'Resultados por termo exato'
|
||||||
|
: themeActive
|
||||||
|
? 'Resultados por tema'
|
||||||
|
: idleTitle}
|
||||||
|
</h2>
|
||||||
|
{themeMode ? (
|
||||||
|
<p className="mt-0.5 text-xs text-muted-foreground">
|
||||||
|
{themeUnavailable
|
||||||
|
? 'Comportamento atual do acervo.'
|
||||||
|
: themeActive
|
||||||
|
? `Confira o indício em cada ${subject} antes de abrir.`
|
||||||
|
: 'Nenhum termo relacionado foi acrescentado; mostramos a busca literal.'}
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
{controls}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
const RecordingsSource = ({
|
const RecordingsSource = ({
|
||||||
data,
|
data,
|
||||||
}: {
|
}: {
|
||||||
|
|
@ -114,33 +159,22 @@ const RecordingsSource = ({
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<CampaignListResults>
|
<CampaignListResults>
|
||||||
<div className="flex flex-wrap items-end justify-between gap-3">
|
<AcervoResultsHeading
|
||||||
<div>
|
themeMode={themeMode}
|
||||||
<h2 className="text-sm font-semibold">
|
themeActive={themeActive}
|
||||||
{data.themeUnavailable
|
themeUnavailable={data.themeUnavailable}
|
||||||
? 'Resultados por termo exato'
|
idleTitle="Gravações encontradas"
|
||||||
: themeActive
|
subject="gravação"
|
||||||
? 'Resultados por tema'
|
controls={
|
||||||
: 'Gravações encontradas'}
|
<div className="flex flex-wrap items-end gap-2">
|
||||||
</h2>
|
{data.themeUnavailable ? <CampaignThemeRetryButton /> : null}
|
||||||
{themeMode ? (
|
<AcervoSortSelect
|
||||||
<p className="mt-0.5 text-xs text-muted-foreground">
|
state={data.state}
|
||||||
{data.themeUnavailable
|
hint="Gravações sem duração aparecem apenas em Mais recentes."
|
||||||
? 'Comportamento atual do acervo.'
|
/>
|
||||||
: themeActive
|
</div>
|
||||||
? 'Confira o indício em cada gravação antes de abrir.'
|
}
|
||||||
: 'Nenhum termo relacionado foi acrescentado; mostramos a busca literal.'}
|
/>
|
||||||
</p>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-wrap items-end gap-2">
|
|
||||||
{data.themeUnavailable ? <CampaignThemeRetryButton /> : null}
|
|
||||||
<AcervoSortSelect
|
|
||||||
state={data.state}
|
|
||||||
hint="Gravações sem duração aparecem apenas em Mais recentes."
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{data.rows.length > 0 ? (
|
{data.rows.length > 0 ? (
|
||||||
<RecordingResultList rows={data.rows} />
|
<RecordingResultList rows={data.rows} />
|
||||||
|
|
@ -236,33 +270,22 @@ const WebSpeechesSource = ({
|
||||||
{data.themeUnavailable ? <SpeechThemeFallbackNotice /> : null}
|
{data.themeUnavailable ? <SpeechThemeFallbackNotice /> : null}
|
||||||
|
|
||||||
<CampaignListResults>
|
<CampaignListResults>
|
||||||
<div className="flex flex-wrap items-end justify-between gap-3">
|
<AcervoResultsHeading
|
||||||
<div>
|
themeMode={themeMode}
|
||||||
<h2 className="text-sm font-semibold">
|
themeActive={themeActive}
|
||||||
{data.themeUnavailable
|
themeUnavailable={data.themeUnavailable}
|
||||||
? 'Resultados por termo exato'
|
idleTitle="Resultados encontrados"
|
||||||
: themeActive
|
subject="fala"
|
||||||
? 'Resultados por tema'
|
controls={
|
||||||
: 'Resultados encontrados'}
|
<div className="flex flex-wrap items-end gap-2">
|
||||||
</h2>
|
{data.themeUnavailable ? <CampaignThemeRetryButton /> : null}
|
||||||
{themeMode ? (
|
<AcervoSortSelect
|
||||||
<p className="mt-0.5 text-xs text-muted-foreground">
|
state={data.state}
|
||||||
{data.themeUnavailable
|
hint="Falas sem duração aparecem apenas em Mais recentes."
|
||||||
? 'Comportamento atual do acervo.'
|
/>
|
||||||
: themeActive
|
</div>
|
||||||
? 'Confira o indício em cada fala antes de abrir.'
|
}
|
||||||
: 'Nenhum termo relacionado foi acrescentado; mostramos a busca literal.'}
|
/>
|
||||||
</p>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-wrap items-end gap-2">
|
|
||||||
{data.themeUnavailable ? <CampaignThemeRetryButton /> : null}
|
|
||||||
<AcervoSortSelect
|
|
||||||
state={data.state}
|
|
||||||
hint="Falas sem duração aparecem apenas em Mais recentes."
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{data.rows.length > 0 ? (
|
{data.rows.length > 0 ? (
|
||||||
<WebSpeechResultList rows={data.rows} />
|
<WebSpeechResultList rows={data.rows} />
|
||||||
|
|
@ -343,25 +366,14 @@ const CamaraSource = ({ data }: { data: Awaited<ReturnType<typeof loadSpeechAcer
|
||||||
|
|
||||||
<CampaignListResults>
|
<CampaignListResults>
|
||||||
{themeMode ? (
|
{themeMode ? (
|
||||||
<div className="flex flex-wrap items-end justify-between gap-3">
|
<AcervoResultsHeading
|
||||||
<div>
|
themeMode={themeMode}
|
||||||
<h2 className="text-sm font-semibold">
|
themeActive={themeActive}
|
||||||
{data.themeUnavailable
|
themeUnavailable={data.themeUnavailable}
|
||||||
? 'Resultados por termo exato'
|
idleTitle="Resultados"
|
||||||
: themeActive
|
subject="fala"
|
||||||
? 'Resultados por tema'
|
controls={data.themeUnavailable ? <CampaignThemeRetryButton /> : null}
|
||||||
: 'Resultados'}
|
/>
|
||||||
</h2>
|
|
||||||
<p className="mt-0.5 text-xs text-muted-foreground">
|
|
||||||
{data.themeUnavailable
|
|
||||||
? 'Comportamento atual do acervo.'
|
|
||||||
: themeActive
|
|
||||||
? 'Confira o indício em cada fala antes de abrir.'
|
|
||||||
: 'Nenhum termo relacionado foi acrescentado; mostramos a busca literal.'}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
{data.themeUnavailable ? <CampaignThemeRetryButton /> : null}
|
|
||||||
</div>
|
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{data.rows.length > 0 ? (
|
{data.rows.length > 0 ? (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue