import { useTranslation } from "react-i18next"; import { AlertTriangle, CheckCircle, FileWarning } from "lucide-react"; import type { DuplicateCheckResult } from "../../shared/types"; interface DuplicateCheckPanelProps { result: DuplicateCheckResult; excludedIndices: Set; onToggleRow: (index: number) => void; onSkipAll: () => void; onIncludeAll: () => void; } export default function DuplicateCheckPanel({ result, excludedIndices, onToggleRow, onSkipAll, onIncludeAll, }: DuplicateCheckPanelProps) { const { t } = useTranslation(); const allExcluded = result.duplicateRows.length > 0 && result.duplicateRows.every((d) => excludedIndices.has(d.rowIndex)); const noneExcluded = result.duplicateRows.every((d) => !excludedIndices.has(d.rowIndex)); return (

{t("import.duplicates.title")}

{/* File-level duplicate */} {result.fileAlreadyImported && (

{t("import.duplicates.fileAlreadyImported")}

{t("import.duplicates.fileAlreadyImportedDesc")}

)} {/* Row-level duplicates */} {result.duplicateRows.length > 0 ? (

{t("import.duplicates.rowsFound", { count: result.duplicateRows.length, })}

{t("import.duplicates.rowsFoundDesc")}

{/* Bulk actions */}
{/* Duplicate table */}
{result.duplicateRows.map((row) => { const included = !excludedIndices.has(row.rowIndex); const isBatch = row.existingTransactionId === -1; return ( ); })}
noneExcluded ? onSkipAll() : onIncludeAll()} className="accent-[var(--primary)]" /> # {t("import.preview.date")} {t("import.preview.description")} {t("import.preview.amount")} {t("import.source")}
onToggleRow(row.rowIndex)} className="accent-[var(--primary)]" /> {row.rowIndex + 1} {row.date} {row.description} {row.amount.toFixed(2)} {isBatch ? t("import.duplicates.sourceBatch") : t("import.duplicates.sourceDb")}
) : ( !result.fileAlreadyImported && (

{t("import.duplicates.noneFound")}

) )} {/* Summary */}

{t("import.duplicates.summary", { total: result.newRows.length + result.duplicateRows.length, new: result.newRows.length, duplicates: result.duplicateRows.length, })} {excludedIndices.size > 0 && ( {" "}— {excludedIndices.size} {t("import.duplicates.skip").toLowerCase()} )}

); }