'use client' import { ExternalLinkIcon } from 'lucide-react' import Link from 'next/link' import { startTransition, useActionState, useMemo, useState, type FormEvent } from 'react' import { Alert, AlertDescription, AlertTitle } from '@/components/ui/Alert' import { Badge } from '@/components/ui/Badge' import { Button } from '@/components/ui/button' import { Checkbox } from '@/components/ui/Checkbox' import { Field, FieldDescription, FieldError, FieldLabel } from '@/components/ui/field' import { Input } from '@/components/ui/input' import { Spinner } from '@/components/ui/Spinner' import { Textarea } from '@/components/ui/textarea' import type { CampaignFormActionState } from '@/utilities/campaignFormActionError' import { fieldError } from '@/utilities/campaignFormFields' import type { TourStopRole } from '@/utilities/visit/visitPlannerViews' import { MAX_TOUR_NAME_LENGTH, MAX_TOUR_STOPS, tourStopRoleDescriptions, tourStopRoleLabels, } from '@/utilities/visit/visitPlannerViews' /** * One candidate stop, already reduced to what the decision needs. Numbers arrive * formatted and the dossier href arrives built: the canonical serializers drag * the município catalog with them, and this is a client component (the B14 * lesson — 21 kB of First Load JS for one link). */ export type TourStopOption = { municipalityID: number slug: string name: string role: TourStopRole suggested: boolean /** Activity tags the stop generates, derived from its role. */ tags: string[] metCount: number conditionCount: number unmetConditionLabels: string[] deficitLabel: string contraindicationReason: string | null dossierHref: string } const StopRow = ({ stop, checked, onToggle, }: { stop: TourStopOption checked: boolean onToggle: (checked: boolean) => void }) => { const checkboxId = `tour-stop-${stop.slug}` return (
{tourStopRoleDescriptions[stop.role]}
Faltam {stop.deficitLabel} votos para a meta. {stop.unmetConditionLabels.length > 0 ? ` Ainda não atende: ${stop.unmetConditionLabels.join(', ')}.` : ' Atende as cinco condições.'}
{stop.contraindicationReason ? ({stop.contraindicationReason}
) : null}