import { raceColor } from '../utils/colors.js'
import { POOL_BY_SEX_ARREST_THRESHOLD } from '../utils/pooling.js'
/**
* The results page's first block: what was actually observed, before any
* modelling. One row per student group plus a district total.
*
* The table doubles as the legend and the control for the density panel — each
* row carries the checkbox that adds or removes that group's curve, and the
* colour swatch is the same hue the curve is drawn in. That's deliberate:
* a separate legend plus a separate group picker would make the reader hold
* three mappings in their head instead of one.
*
* @param {{
* groups: Array<{key:string, race:string, sex:string|null, label:string,
* enroll:number, observed:number, rate:number}>,
* selectedKeys: string[],
* onToggleGroup: (key: string) => void,
* pooled: boolean,
* autoPooled: boolean,
* onPooledChange: (pooled: boolean) => void,
* selectionIsEnrollmentFallback: boolean,
* }} props
*/
export default function DistrictSummaryTable({
groups,
selectedKeys,
onToggleGroup,
pooled,
autoPooled,
onPooledChange,
selectionIsEnrollmentFallback,
}) {
if (!groups?.length) {
return (
Reported arrests and enrollment
No student-group data is available for this district in 2021–22.
No group in this district reported an arrest in 2021–22, so the two largest groups by
enrollment are shown by default.
)}
Students counted are those in the four modelled race groups (American Indian / Alaska
Native, Black, Hispanic, White) — not the district’s total enrollment, which also
includes groups this model does not estimate.
{autoPooled ? (
<>
This district reported {totalObserved.toLocaleString()} arrests in total — fewer than{' '}
{POOL_BY_SEX_ARREST_THRESHOLD} — so Female and Male students are combined within each
race to give each estimate more data to stand on.
>
) : (
<>Female and Male students are combined within each race.>
)}