import { useTranslation } from "react-i18next"; import { AlertCircle, ArrowDownLeft, ArrowUpRight, RefreshCw } from "lucide-react"; import type { ParsedRow } from "../../shared/types"; import { isRowErrorKey, summarizeParsedRows } from "../../utils/importFormat"; import RepairPathNotice from "./RepairPathNotice"; /** Rows rendered in the table. The recap above it always covers the whole file. */ const DISPLAYED_ROWS = 20; interface FilePreviewTableProps { /** ALL parsed rows — the recap is meaningless on a truncated sample. */ rows: ParsedRow[]; onFlipSigns?: () => void; isFlipping?: boolean; } export default function FilePreviewTable({ rows, onFlipSigns, isFlipping = false, }: FilePreviewTableProps) { const { t, i18n } = useTranslation(); if (rows.length === 0) { return (
{currency.format(totals.outflowTotal)}
{currency.format(totals.inflowTotal)}
0 ? "text-[var(--negative)]" : "text-[var(--muted-foreground)]" }`} > {totals.errorCount}
{t("import.preview.flipSignsHint")}
| # | {t("import.preview.date")} | {t("import.preview.description")} | {t("import.preview.amount")} | {t("import.preview.raw")} |
|---|---|---|---|---|
| {row.rowIndex + 1} | {row.parsed?.date || ( {row.error ? errorText(row.error) : "—"} )} | {row.parsed?.description || "—"} | {row.parsed?.amount != null ? row.parsed.amount.toFixed(2) : "—"} | {row.raw.map((cell, i) => ( {i > 0 && {'·'}} {cell} ))} |
{t("import.preview.moreRows", { count: rows.length - displayedRows.length, })}
)}