import { __ } from '@wordpress/i18n'; import type { JSX } from 'react'; import type { Counts } from '../../shared/api/types/status'; import { PROBLEMS, problemLabel } from '../../shared/links/problem'; import { formatNumber } from '../../shared/lib/numbers'; import { setParams } from '../../shared/lib/router'; import { ALL_FILTER, type LinksFilter } from './linksFilter'; type FilterChip = { filter: LinksFilter; label: string; count: number; }; function filterChips( counts: Counts, problemTotal: number ): FilterChip[] { const chips: FilterChip[] = [ { filter: ALL_FILTER, label: __( 'All', 'aiplaz-link-checkup' ), count: problemTotal, }, ]; for ( const problem of PROBLEMS ) { chips.push( { filter: problem, label: problemLabel( problem ), count: counts[ problem ], } ); } return chips; } type FilterChipsProps = { activeFilter: LinksFilter; counts: Counts; problemTotal: number; }; export function FilterChips( { activeFilter, counts, problemTotal, }: FilterChipsProps ): JSX.Element { return (
{ filterChips( counts, problemTotal ).map( ( chip ) => ( ) ) }
); }