import { Link2, Link2Off, Loader2, RefreshCw } from 'lucide-react'; import { cn, fmtDate } from '@/lib/utils'; import { Button } from '@/components/ui/button'; import BillMerchantRules from '@/components/BillMerchantRules'; import { transactionTitle, transactionDate, fmtTransactionAmount } from '@/components/bill-modal/transactionDisplay'; // Bank-matching rules (with a Sync-now action) + the list of transactions // confirmed as matched to this bill (each with an Unmatch action). Presentational // — the parent owns the sync/rules-changed handlers and the unmatch state. export default function LinkedTransactionsSection({ isNew, billId, billName, localHasRules, syncingPayments, onSync, onRulesChanged, linkedTransactions, linkedTransactionsLoading, transactionBusyId, onUnmatch, }) { return ( <> {/* Bank Matching Rules */} {!isNew && (

Bank matching rules

Transactions whose description contains these patterns are automatically imported as payments.

{localHasRules && ( )}
)}

Linked transactions

{linkedTransactions.length} confirmed matches

0 ? 'border-primary/20 bg-primary/5 text-primary' : 'border-border/60 bg-muted/30 text-muted-foreground', )}> {linkedTransactions.length}
{linkedTransactionsLoading ? (
Loading linked transactions...
) : linkedTransactions.length === 0 ? (
No transactions linked to this bill yet.
) : (
{linkedTransactions.map(transaction => (

{transactionTitle(transaction)}

{transaction.source_label || transaction.source_type_label || 'Transaction'}

{transactionDate(transaction) ? fmtDate(transactionDate(transaction)) : 'No date'} · {transaction.description || transaction.memo || 'No description'}

{transaction.account_name && (

{transaction.account_name}

)}

{fmtTransactionAmount(transaction.amount, transaction.currency)}

))}
)}
); }