import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; import { ArrowLeft } from "lucide-react"; import PeriodSelector from "../components/dashboard/PeriodSelector"; import CategoryZoomHeader from "../components/reports/CategoryZoomHeader"; import CategoryDonutChart from "../components/reports/CategoryDonutChart"; import CategoryEvolutionChart from "../components/reports/CategoryEvolutionChart"; import CategoryTransactionsTable from "../components/reports/CategoryTransactionsTable"; import AddKeywordDialog from "../components/categories/AddKeywordDialog"; import { useCategoryZoom } from "../hooks/useCategoryZoom"; import { useReportsPeriod } from "../hooks/useReportsPeriod"; import type { RecentTransaction } from "../shared/types"; export default function ReportsCategoryPage() { const { t, i18n } = useTranslation(); const { period, setPeriod, from, to, setCustomDates } = useReportsPeriod(); const { zoomedCategoryId, rollupChildren, data, isLoading, error, setCategory, setRollupChildren, refetch, } = useCategoryZoom(); const [pending, setPending] = useState(null); const preserveSearch = typeof window !== "undefined" ? window.location.search : ""; const centerLabel = t("reports.category.breakdown"); const centerValue = data ? new Intl.NumberFormat(i18n.language === "fr" ? "fr-CA" : "en-CA", { style: "currency", currency: "CAD", maximumFractionDigits: 0, }).format(data.rollupTotal) : "—"; return (

{t("reports.hub.categoryZoom")}

{error && (
{error}
)} {zoomedCategoryId === null ? (
{t("reports.category.selectCategory")}
) : data ? (

{t("reports.category.transactions")}

setPending(tx)} />
) : null} {pending && ( setPending(null)} onApplied={() => { setPending(null); refetch(); }} /> )}
); }