File size: 662 Bytes
d15f07c
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import { useMemo } from 'react'
import { useTopicTimeline } from '../stance/TimelineChart'
import type { InsightYear } from '../../utils/chartInsight'

/** The topic's real meetings per year in the scope, for a takeaway title (#1409); undefined while loading or unavailable. */
export function useInsightYears(topicSlug: string | undefined, stateCode?: string, city?: string | null): InsightYear[] | undefined {
  const q = useTopicTimeline(topicSlug ?? '', stateCode, city, Boolean(topicSlug))
  return useMemo(
    () => q.data?.years.map((y) => ({ year: y.year, meetings: y.meetings, share: y.share, recorded: y.all_recorded_meetings })),
    [q.data],
  )
}