import styles from '../../styles/home/categories.module.scss';
import { Category } from '../../types';
interface CategoriesProps {
categories: Category[];
categoryActive: Category;
handleSelectCategory: (category: Category) => void;
}
export default function Categories({ categories, categoryActive, handleSelectCategory }: CategoriesProps) {
return (
Catégories
{categories.map((category, key) => (
))}
)
}
interface CategoryItemProps {
category: Category;
categoryActive: Category;
handleSelectCategory: (category: Category) => void;
}
function CategoryItem({ category, categoryActive, handleSelectCategory }: CategoryItemProps): JSX.Element {
const className = `${styles['item']} ${category.id === categoryActive.id ? styles['active'] : ''}`;
const onClick = () => handleSelectCategory(category);
return (
{category.name} — {category.links.length}
)
}