import { useSelector } from "react-redux" ; import { selectors as categoriesSelectors } from '../slices/categories' ; import { RootState } from ".." ; import { Category , CategoryId } from "../../api" ; export function useCategories ( ids ? ) { if ( ids ) { return useSelector ( ( state ) => categoriesSelectors . selectAll ( state . categories ) . filter ( category => ids . includes ( category . id ) ) ) ; } else { return useSelector ( ( state ) => categoriesSelectors . selectAll ( state . categories ) ) ; } } export function useCategory ( id ) { return useSelector ( ( state ) => categoriesSelectors . selectById ( state . categories , id ) ) ; }