import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Plus, RotateCcw, List, AlertTriangle } from "lucide-react"; import { PageHelp } from "../components/shared/PageHelp"; import { useCategories } from "../hooks/useCategories"; import CategoryTree from "../components/categories/CategoryTree"; import CategoryDetailPanel from "../components/categories/CategoryDetailPanel"; import AllKeywordsPanel from "../components/categories/AllKeywordsPanel"; export default function CategoriesPage() { const { t } = useTranslation(); const [showAllKeywords, setShowAllKeywords] = useState(false); const [showReinitConfirm, setShowReinitConfirm] = useState(false); const { state, selectCategory, startCreating, startEditing, cancelEditing, saveCategory, deleteCategory, addKeyword, editKeyword, removeKeyword, reinitializeCategories, moveCategory, } = useCategories(); const handleReinitialize = async () => { setShowReinitConfirm(false); await reinitializeCategories(); }; const selectedCategory = state.selectedCategoryId !== null ? state.categories.find((c) => c.id === state.selectedCategoryId) ?? null : null; return (

{t("categories.title")}

{state.error && (
{state.error}
)} {state.isLoading ? (

{t("common.loading")}

) : showAllKeywords ? ( { setShowAllKeywords(false); selectCategory(id); }} onRemove={removeKeyword} /> ) : (
)} {/* Reinitialize confirmation modal */} {showReinitConfirm && (

{t("categories.reinitialize")}

{t("categories.reinitializeConfirm")}

)}
); }