teqo-backup/src/components/campaign/PlazaUpdateFeed.tsx
Francisco Ignácio Fontoura Solla cf13c441aa Remodel /campanha around predefined Praças replacing electoral nuclei.
436 seeded Praças (municipality-based; per-TSE-zone in Salvador/Camaçari) become
the operational unit; roles renamed to coordinator/advisor/leader with advisors
scoped to administered Praças. Leadership is one record per person across many
Praças/organizations; vote pledges split leader-declared vs staff-estimated
(estimates never serialized to leaders). Adds organizations, demand workflow
with staff-only cost/receipts, action-plan results with deputy presence, manual
political trend, multi-candidate comparison and the diverging red/white/blue
map mode. Migration 20260721_020109_remodel_plazas deliberately resets the
campaign vertical in production (public site untouched); test suite ported to
the new model (unit 187 / int 306 / e2e 9 green).
2026-07-21 02:28:00 -03:00

71 lines
2.7 KiB
TypeScript

import { Badge } from '@/components/ui/Badge'
import { plazaUpdateKindLabels } from '@/lib/schemas/plazaUpdate'
import type { PlazaUpdateViewModel } from '@/utilities/plazaUpdatePageData'
const dateTimeFormatter = new Intl.DateTimeFormat('pt-BR', {
dateStyle: 'short',
timeStyle: 'short',
})
const numberFormatter = new Intl.NumberFormat('pt-BR')
const kindVariant = {
semanal: 'secondary',
urgente: 'destructive',
nota: 'outline',
} as const
export const PlazaUpdateFeed = ({ updates }: { updates: PlazaUpdateViewModel[] }) => {
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={kindVariant[update.kind]}>{plazaUpdateKindLabels[update.kind]}</Badge>
<span className="text-sm font-medium">{update.authorName}</span>
<span className="text-sm text-muted-foreground">
{dateTimeFormatter.format(new Date(update.createdAt))}
</span>
</div>
{update.kind === 'semanal' ? (
<dl className="flex flex-col gap-2 text-sm">
<div>
<dt className="font-medium">O que funcionou</dt>
<dd className="whitespace-pre-wrap text-muted-foreground">{update.worked}</dd>
</div>
<div>
<dt className="font-medium">O que não funcionou</dt>
<dd className="whitespace-pre-wrap text-muted-foreground">{update.failed}</dd>
</div>
<div>
<dt className="font-medium">O que preciso</dt>
<dd className="whitespace-pre-wrap text-muted-foreground">{update.needs}</dd>
</div>
</dl>
) : (
<p className="whitespace-pre-wrap text-sm text-muted-foreground">{update.body}</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>
)
}