import type { ReactElement } from 'react' import { filterText, type Field, type Screen } from './screener' // The funnel: how many companies there are, what each filter passes on its own, and how many pass // all of them. The server counts every filter alone, so the line shows which one does the cutting. interface Props { screen: Screen | null fields: Map } export function Funnel({ screen, fields }: Props): ReactElement | null { if (!screen) return null const n = (value: number): string => value.toLocaleString('en-US') return (
{n(screen.universe)} {screen.tickers.length > 0 ? 'on the list' : 'companies'} {screen.applied.map((filter, index) => ( → {filterText(filter, fields.get(filter.field))} {n(filter.matches)} ))} → {n(screen.count)} pass{screen.applied.length > 1 ? ' all' : ''} {screen.countBefore !== null && screen.countBefore !== screen.count && <> (was {n(screen.countBefore)})} {screen.unknownTickers.length > 0 && No company for {screen.unknownTickers.join(', ')}}
) }