'use client' import { ExternalLinkIcon } from 'lucide-react' import Link from 'next/link' import { useActionState, useMemo, useState } 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 { NativeSelect, NativeSelectOption } from '@/components/ui/native-select' import { Spinner } from '@/components/ui/Spinner' import { Textarea } from '@/components/ui/textarea' import { activityKindLabels, activityOriginLabels, activityOrigins, type ActivityKind, type ActivityOrigin, } from '@/lib/schemas/activity' 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' /** The composition came from the numbers; the coordination changes it per stop. */ const DEFAULT_STOP_ORIGIN: ActivityOrigin = 'dado' /** * 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 kind the stop generates, derived from its role. */ kind: ActivityKind metCount: number conditionCount: number unmetConditionLabels: string[] deficitLabel: string contraindicationReason: string | null dossierHref: string } const StopRow = ({ stop, checked, origin, onToggle, onOriginChange, }: { stop: TourStopOption checked: boolean origin: ActivityOrigin onToggle: (checked: boolean) => void onOriginChange: (origin: ActivityOrigin) => void }) => { const checkboxId = `tour-stop-${stop.slug}` const originId = `tour-origin-${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}