Skip to content

Commit 6b8aea6

Browse files
committed
Fix pluralize of rows
1 parent 9e0ba6c commit 6b8aea6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/ColumnWithToggleControls.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ChevronUp, ChevronDown } from 'lucide-react';
55
import React, { useRef } from 'react';
66
import Flex from './Flex';
77
import Scroller from './Scroller';
8+
import { simplePluralize } from '@/lib/utils';
89

910
type ToggleConfig = {
1011
type: 'sort' | 'filter';
@@ -36,6 +37,11 @@ const ColumnWithToggleControls = ({
3637
}: ColumnWithToggleControlsProps) => {
3738
const ref = useRef<HTMLDivElement | null>(null);
3839

40+
const hiddenRows =
41+
typeof totalCount === 'number' && typeof filteredCount === 'number'
42+
? totalCount - filteredCount
43+
: 0;
44+
3945
return (
4046
<Flex ref={ref} className={cn('relisten-column relative flex-1 break-words', className)} column>
4147
<Scroller containerRef={ref} key={heading} />
@@ -81,7 +87,7 @@ const ColumnWithToggleControls = ({
8187
<div className="m-2 rounded border border-amber-500/20 bg-amber-500/10 p-2 text-xs text-amber-700">
8288
{filteredCount === 0 ? (
8389
<>
84-
All {totalCount - filteredCount} rows are hidden by filters.{' '}
90+
All {simplePluralize('row', hiddenRows)} are hidden by filters.{' '}
8591
<button
8692
onClick={onClearFilters}
8793
className="font-medium underline hover:no-underline"
@@ -91,7 +97,7 @@ const ColumnWithToggleControls = ({
9197
</>
9298
) : (
9399
<>
94-
{totalCount - filteredCount} rows are hidden by filters.{' '}
100+
{simplePluralize('row', hiddenRows)} are hidden by filters.{' '}
95101
<button
96102
onClick={onClearFilters}
97103
className="font-medium underline hover:no-underline"

0 commit comments

Comments
 (0)