Substitui o modelo de MunicipalityUpdate (kind/semanal/urgente/nota/sinal + signalType) por um modelo unificado: body obrigatório + polarity (boa/neutra/ruim) + urgent + adversarySignal. - Schema: polarity enum obrigatório, urgent boolean default false, adversarySignal boolean - Wizard: novo WizardUpdateBodyStep com campo de texto + polaridade + urgente - Lista: controle unificado de atualização com polaridade inline - Feed: exibe polaridade como badge colorido + indicador de urgência - V2 status strip: atualização rápida de polaridade - E11: queries atualizadas para polarity + adversarySignal - Migração: 20260807_030000_unify_municipality_update (backfill polarity=neutra, urgent de kind, adversarySignal de kind+signalType) - Testes: 18/18 integração C87, 593/593 total, 1399/1399 unitários - Fix: testes de state deputy usavam nomes fixos que colidiam entre execuções
60 lines
2.3 KiB
TypeScript
60 lines
2.3 KiB
TypeScript
import { Badge } from '@/components/ui/Badge'
|
|
import { municipalityUpdatePolarityLabels } from '@/lib/schemas/municipalityUpdate'
|
|
import type { MunicipalityUpdateViewModel } from '@/utilities/municipality/municipalityUpdatePageData'
|
|
|
|
const dateTimeFormatter = new Intl.DateTimeFormat('pt-BR', {
|
|
dateStyle: 'short',
|
|
timeStyle: 'short',
|
|
})
|
|
|
|
const numberFormatter = new Intl.NumberFormat('pt-BR')
|
|
|
|
const polarityVariant = {
|
|
boa: 'default',
|
|
neutra: 'secondary',
|
|
ruim: 'destructive',
|
|
} as const
|
|
|
|
export const MunicipalityUpdateFeed = ({ updates }: { updates: MunicipalityUpdateViewModel[] }) => {
|
|
if (!updates.length) {
|
|
return (
|
|
<p className="rounded-xl border px-4 py-6 text-sm text-muted-foreground">
|
|
Nenhuma atualização registrada ainda.
|
|
</p>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<ul className="flex flex-col gap-4">
|
|
{updates.map((update) => (
|
|
<li key={update.id} className="flex flex-col gap-3 rounded-xl border p-4">
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
<Badge variant={polarityVariant[update.polarity]}>
|
|
{municipalityUpdatePolarityLabels[update.polarity]}
|
|
</Badge>
|
|
{update.urgent ? <Badge variant="destructive">Urgente</Badge> : null}
|
|
{update.adversarySignal ? <Badge variant="outline">Adversário</Badge> : null}
|
|
<span className="text-sm font-medium">{update.authorName}</span>
|
|
<span className="text-sm text-muted-foreground">
|
|
{dateTimeFormatter.format(new Date(update.createdAt))}
|
|
</span>
|
|
</div>
|
|
<p className="whitespace-pre-wrap text-sm text-muted-foreground">
|
|
{update.body ?? 'Sem texto.'}
|
|
</p>
|
|
{update.activeVolunteers != null || update.newSupports != null ? (
|
|
<p className="text-sm text-muted-foreground">
|
|
{update.activeVolunteers != null
|
|
? `${numberFormatter.format(update.activeVolunteers)} voluntários ativos`
|
|
: null}
|
|
{update.activeVolunteers != null && update.newSupports != null ? ' · ' : null}
|
|
{update.newSupports != null
|
|
? `${numberFormatter.format(update.newSupports)} novos apoios`
|
|
: null}
|
|
</p>
|
|
) : null}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
)
|
|
}
|