import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { getAllCategoriesWithCounts } from "../../services/categoryService"; import CategoryCombobox from "../shared/CategoryCombobox"; import type { Category } from "../../shared/types"; export interface CategoryZoomHeaderProps { categoryId: number | null; includeSubcategories: boolean; onCategoryChange: (id: number | null) => void; onIncludeSubcategoriesChange: (flag: boolean) => void; } export default function CategoryZoomHeader({ categoryId, includeSubcategories, onCategoryChange, onIncludeSubcategoriesChange, }: CategoryZoomHeaderProps) { const { t } = useTranslation(); const [categories, setCategories] = useState([]); useEffect(() => { getAllCategoriesWithCounts() .then((rows) => setCategories( rows.map((r) => ({ id: r.id, name: r.name, parent_id: r.parent_id ?? undefined, color: r.color ?? undefined, icon: r.icon ?? undefined, type: r.type, is_active: r.is_active, is_inputable: r.is_inputable, sort_order: r.sort_order, created_at: "", })), ), ) .catch(() => setCategories([])); }, []); return (
); }