import { Link } from 'react-router-dom' import { useTopicOutcomes } from '../../hooks/useTopicOutcomes' import { highlightSnippet } from '../../lib/highlight' import { chainSteps, stepScreen, type ChainStepId } from '../../utils/topicOutcomes' import { upcomingDate } from '../../utils/topicUpcoming' import type { OutcomeExample } from '../../api/topicOutcomes' import './storyCharts.css' import './OutcomesChain.css' interface Props { topic: string stateCode?: string | null city?: string | null scopeLabel: string subject: string /** The topic's own words for the two kinds of action ("Voted to keep or start", "Voted to end"). */ actionWords: { advanced: string; blocked: string } /** Whether this is the Data Center Story (its screens differ from a topic story's). */ dataCenterStory: boolean /** Opens a screen of this story (keeps the place). */ onOpenScreen: (screen: string) => void } const fmt = (n: number) => n.toLocaleString('en-US') const STATUS: Record = { enacted: 'Enacted', passed_chamber: 'Passed one chamber', pending: 'Pending', failed: 'Failed' } const LABEL: Record = { opposed: 'Public mostly opposed', mixed: 'Both sides spoke', supportive: 'Public mostly supportive', advanced: 'Moved it forward', blocked: 'Stopped or limited it', moratorium: 'Moratorium', tabled: 'Tabled or put off', meeting: 'Scheduled meeting', hearing: 'Public hearing', } function exampleDetail(step: ChainStepId, e: OutcomeExample) { if (!e.detail) return null if (e.detail.includes('')) return “{highlightSnippet(e.detail)}” const word = step === 'bills' ? STATUS[e.detail] : LABEL[e.detail] return {word ?? e.detail} } /** * What happened next (#1314): the chain from the meetings where a topic came up to what followed: the public's lean, * what local bodies did, the state bills, the meetings that named a bill, and what's coming up. Each step is one real * count, a line in words and up to three linked examples; tapping a step opens its screen. Vertical on a phone, * left-to-right on a wide screen. A step with no record says "No recorded … yet". */ export default function OutcomesChain({ topic, stateCode, city, scopeLabel, subject, actionWords, dataCenterStory, onOpenScreen }: Props) { const q = useTopicOutcomes(topic, stateCode, city) const title = (

What happened next on {subject} · {scopeLabel}

) if (q.isLoading) { return (
{title}

Loading what happened next…

) } if (q.isError || !q.data) { return (
{title}

What happened next could not be loaded right now.

) } const d = q.data const steps = chainSteps(d, subject, actionWords) const refCount = Math.max(1, d.steps.meetings.count) return (
{title}
    {steps.map((s) => { const ex = d.steps[s.id].examples const screen = stepScreen(s.id, dataCenterStory) const boxCount = s.available && s.count > 0 ? Math.max(1, Math.min(24, Math.round((s.count / refCount) * 24))) : 0 return (
  1. {s.label} {s.available ? fmt(s.count) : '—'}
    {boxCount > 0 && ( )}

    {s.available ? s.line : 'Not available yet.'}

    {ex.length > 0 && (
      {ex.slice(0, 3).map((e) => (
    • {[upcomingDate(e.date), [e.jurisdiction_name, e.state_code].filter(Boolean).join(', ')].filter(Boolean).join(' · ')} {e.url ? ( e.url.startsWith('/') ? ( {e.title ?? 'Open'} ) : ( {e.title ?? 'Open'} ) ) : ( {e.title} )} {exampleDetail(s.id, e)}
    • ))}
    )} {screen && s.count > 0 && ( )}
  2. ) })}

Counts are meetings, never speakers. The public's lean and what the body did are an AI (Jev) reading of each transcript, not official minutes. A meeting is tied to a state bill only when the transcript, a decision, the agenda or minutes write the bill's number, in the same state.

) }