mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 07:03:25 +00:00
feat: add links count
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Category } from "types";
|
||||
import CategoryItem from "./CategoryItem";
|
||||
|
||||
import { useMemo } from "react";
|
||||
import styles from "./categories.module.scss";
|
||||
|
||||
interface CategoriesProps {
|
||||
@@ -13,9 +14,13 @@ export default function Categories({
|
||||
categoryActive,
|
||||
handleSelectCategory,
|
||||
}: CategoriesProps) {
|
||||
const linksCount = useMemo(
|
||||
() => categories.reduce((acc, current) => (acc += current.links.length), 0),
|
||||
[categories]
|
||||
);
|
||||
return (
|
||||
<div className={styles["categories"]}>
|
||||
<h4>Catégories</h4>
|
||||
<h4>Catégories • {linksCount}</h4>
|
||||
<ul className={styles["items"]}>
|
||||
{categories.map((category, key) => (
|
||||
<CategoryItem
|
||||
|
||||
Reference in New Issue
Block a user