import { useState } from "react"; import { ArrowLeftRight, CalendarSearch, Pencil, SquareDivide, StickyNote, Trash2 } from "lucide-react"; import { Dialog } from "@/components/ui/Dialog"; import { getCategoryIcon } from "@/lib/icons"; import { formatCurrency, formatTransactionDate } from "@/lib/format"; import { useTranslation } from "@/lib/i18n"; import { categoryPath, translateCategoryName } from "@/lib/categoryLabels"; import { useCategories } from "@/hooks/useCategories"; import type { Transaction } from "@/types"; interface TransactionsTableProps { items: Transaction[]; onEdit: (transaction: Transaction) => void; onDelete: (transaction: Transaction) => void; /** Present only while showing search results, which span every month — * lets a row's date carry the year and offers a way to jump back to * browsing that transaction's month instead of just listing it flat. */ onJumpToMonth?: (transaction: Transaction) => void; } export function TransactionsTable({ items, onEdit, onDelete, onJumpToMonth }: TransactionsTableProps) { const { t } = useTranslation(); const { data: categories } = useCategories(); const [noteTransaction, setNoteTransaction] = useState(null); if (items.length === 0) { return (

{onJumpToMonth ? t("transactions.searchNoneFound") : t("transactions.noneFound")}

); } return ( <> setNoteTransaction(null)} title={t("transactions.noteDialogTitle")} >

{noteTransaction?.notes}

); }