simplify getLabelCount function logic

This commit is contained in:
Adarsh Tiwari
2025-05-24 01:10:50 +05:30
parent b1ed2c8825
commit 46e0bd3a67

View File

@@ -172,13 +172,9 @@ export function NavMain({ items }: NavMainProps) {
[pathname, category, searchParams, isValidInternalUrl],
);
const getLabelCount = React.useMemo(() => {
if (!stats) return () => 0;
return (labelName: string | undefined) => {
if (!labelName) return 0;
return stats.find((stat) => stat.label?.toLowerCase() === labelName.toLowerCase())?.count ?? 0;
};
const getLabelCount = useCallback((labelName: string | undefined): number => {
if (!stats || !labelName) return 0;
return stats.find((stat) => stat.label?.toLowerCase() === labelName.toLowerCase())?.count ?? 0;
}, [stats]);
const activeAccount = React.useMemo(() => {