import Link from 'next/link' import { Badge } from '@/components/ui/Badge' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Progress } from '@/components/ui/Progress' import { actionPlanKindLabels } from '@/lib/schemas/actionPlan' import { formatBahiaDateTimeLabel } from '@/utilities/campaignTime' import type { NucleusListOverviewViewModel } from '@/utilities/nucleusListOverviewViewModels' import { nucleusUpdateKindLabels } from '@/utilities/nucleusUpdateUi' const numberFormatter = new Intl.NumberFormat('pt-BR') const relativeFormatter = new Intl.RelativeTimeFormat('pt-BR', { numeric: 'auto' }) const relativeDateLabel = (value: string, now: Date): string => { const days = Math.floor((new Date(value).getTime() - now.getTime()) / (24 * 60 * 60 * 1000)) return relativeFormatter.format(days, 'day') } export const NucleusListOverview = ({ view, now, }: { view: NucleusListOverviewViewModel now: Date }) => (

Visão geral dos núcleos filtrados

Mostrando agregados de{' '} {numberFormatter.format(view.totalFiltered)} {' '} {view.totalFiltered === 1 ? 'núcleo filtrado' : 'núcleos filtrados'}

Estimativa de votos {numberFormatter.format(view.estimate.confirmedTotal)}
{view.estimate.confirmedPercent}% com estimativa confirmada {numberFormatter.format(view.estimate.confirmedCount)} confirmadas ·{' '} {numberFormatter.format(view.estimate.unconfirmedCount)} pendentes
{view.estimate.pendingSuggestionsCount ? ( {numberFormatter.format(view.estimate.pendingSuggestionsCount)}{' '} {view.estimate.pendingSuggestionsCount === 1 ? 'sugestão pendente' : 'sugestões pendentes'} ) : null}
Cobertura {view.coverage.percent}%

{numberFormatter.format(view.coverage.coordinatedCount)} de{' '} {numberFormatter.format(view.totalFiltered)} com coordenador

{view.baseline2022 ? ( Baseline 2022 {view.baseline2022.gapTotal === null ? '—' : `${view.baseline2022.gapTotal >= 0 ? '+' : ''}${numberFormatter.format(view.baseline2022.gapTotal)}`}

{view.baseline2022.gapTotal === null ? 'Sem estimativas comparáveis ao patamar de 2022' : view.baseline2022.gapTotal >= 0 ? 'votos acima do patamar' : 'votos abaixo do patamar'}

{numberFormatter.format(view.baseline2022.above)} acima {' · '} {numberFormatter.format(view.baseline2022.below)} abaixo

) : null}
Últimas atualizações {view.recentUpdates.length ? (
    {view.recentUpdates.map((update) => (
  • {update.authorName} {nucleusUpdateKindLabels[update.kind]} {relativeDateLabel(update.createdAt, now)}
    {update.nucleusName}
  • ))}
) : (

Nenhuma atualização recente

)}
Próximos eventos {view.upcomingActionPlans.length ? (
    {view.upcomingActionPlans.map((plan) => (
  • {actionPlanKindLabels[plan.kind]} {formatBahiaDateTimeLabel(plan.startAt)} {plan.city ? ` · ${plan.city}` : ''}
    {plan.title}
  • ))}
) : (

Nenhum evento agendado

)}
)