Show number of rows in table header

This commit is contained in:
David Corbitt
2023-08-14 19:56:15 -07:00
parent d8a5617dee
commit 3d3ddbe7a9

View File

@@ -34,7 +34,7 @@ export const TableHeader = ({ showCheckbox }: { showCheckbox?: boolean }) => {
const addAll = useAppStore((s) => s.selectedLogs.addSelectedLogIds); const addAll = useAppStore((s) => s.selectedLogs.addSelectedLogIds);
const clearAll = useAppStore((s) => s.selectedLogs.clearSelectedLogIds); const clearAll = useAppStore((s) => s.selectedLogs.clearSelectedLogIds);
const allSelected = useMemo(() => { const allSelected = useMemo(() => {
if (!matchingLogIds) return false; if (!matchingLogIds || !matchingLogIds.length) return false;
return matchingLogIds.every((id) => selectedLogIds.has(id)); return matchingLogIds.every((id) => selectedLogIds.has(id));
}, [selectedLogIds, matchingLogIds]); }, [selectedLogIds, matchingLogIds]);
return ( return (
@@ -49,7 +49,10 @@ export const TableHeader = ({ showCheckbox }: { showCheckbox?: boolean }) => {
allSelected ? clearAll() : addAll(matchingLogIds || []); allSelected ? clearAll() : addAll(matchingLogIds || []);
}} }}
/> />
<Text>({selectedLogIds.size})</Text> <Text>
({selectedLogIds.size ? `${selectedLogIds.size}/` : ""}
{matchingLogIds?.length || 0})
</Text>
</HStack> </HStack>
</Th> </Th>
)} )}