import { useState } from 'react' import { useQuery } from '@tanstack/react-query' import api from '../lib/api' import { highlightSnippet } from '../lib/highlight' /** * Jev's reading of meetings for one policy question (#1032): how many meetings the classifier read as debating it, * what it read happened (approved, denied, tabled, moratorium, discussed only), and the meetings with the verbatim * passage that put them in the record. Labelled as a classifier's reading, apart from analyzed decisions. Shows * nothing when the question has no Jev reading. */ interface JevItem { video_id: string meeting_title: string | null meeting_date: string | null jurisdiction_name: string | null state_code: string | null outcome: string | null outcome_p: number | null evidence: string | null jump_url: string | null } interface JevOut { available: boolean meetings: number debated: number outcomes: Record items: JevItem[] } const LABEL: Record = { approved: 'approved', denied: 'denied', tabled_or_deferred: 'tabled or deferred', moratorium: 'moratorium', discussed_no_action: 'discussed, no action', } const ORDER = ['approved', 'denied', 'tabled_or_deferred', 'moratorium', 'discussed_no_action'] const fmtDate = (d?: string | null) => { if (!d) return null const t = new Date(`${d.slice(0, 10)}T12:00:00`) return Number.isNaN(t.getTime()) ? null : t.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }) } export default function JevQuestionReading({ questionId, stateCode, city }: { questionId: string; stateCode?: string | null; city?: string | null }) { const [open, setOpen] = useState(false) const [outcome, setOutcome] = useState(null) const params = { ...(stateCode ? { state: stateCode } : {}), ...(city ? { city } : {}), ...(outcome ? { outcome } : {}), limit: 10 } const q = useQuery({ queryKey: ['policy-question', questionId, 'jev', stateCode ?? '', city ?? '', outcome ?? ''], queryFn: async () => (await api.get(`/policy-question/${encodeURIComponent(questionId)}/jev`, { params })).data, staleTime: 5 * 60_000, }) const d = q.data if (!d || !d.available || d.meetings === 0) return null const actions = ORDER.filter((k) => (d.outcomes[k] ?? 0) > 0) return (

Meetings screened by Jev: {d.meetings.toLocaleString()} read as taking up this question {actions.length > 0 && ( <> {' · '} {actions.map((k, i) => ( {i > 0 && ', '} ))} )}

Jev is a classifier: it read each transcript and judged what happened. These are readings, not the decisions analyzed above.

{open && (
    {d.items.map((m) => (
  • {[m.jurisdiction_name, m.state_code].filter(Boolean).join(', ')} {fmtDate(m.meeting_date) ? ` · ${fmtDate(m.meeting_date)}` : ''} {m.outcome ? <> · {LABEL[m.outcome] ?? m.outcome} : null}

    {m.meeting_title &&

    {m.meeting_title}

    } {m.evidence &&

    “{highlightSnippet(m.evidence)}”

    } {m.jump_url && ( Hear it ↗ )}
  • ))}
)}
) }