'use client' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table' import { ArrowLeft, ArrowRight, AlertTriangle, Calendar, TrendingUp, TrendingDown, FileText, } from 'lucide-react' import { formatCurrency } from '@/lib/utils' import type { BankFileParseResult } from '@/lib/import/bank-file/types' interface BankFilePreviewStepProps { parseResult: BankFileParseResult onContinue: () => void onBack: () => void } export default function BankFilePreviewStep({ parseResult, onContinue, onBack, }: BankFilePreviewStepProps) { const { transactions, stats, issues, date_from, date_to } = parseResult const hasIssues = issues.filter((i) => i.severity === 'error').length > 0 const warnings = issues.filter((i) => i.severity === 'warning') return (
{/* Summary cards */}
Transaktioner

{stats.parsed_rows}

{stats.skipped_rows > 0 && (

{stats.skipped_rows} rader hoppades över

)}
Period

{date_from || '–'} till {date_to || '–'}

Inkomster

{formatCurrency(stats.total_income)}

Utgifter

{formatCurrency(stats.total_expenses)}

{/* Warnings */} {warnings.length > 0 && ( {warnings.length} varning{warnings.length !== 1 ? 'ar' : ''}
{warnings.slice(0, 10).map((issue, i) => (

Rad {issue.row}: {issue.message}

))} {warnings.length > 10 && (

...och {warnings.length - 10} till

)}
)} {/* Transaction preview table */} Transaktioner Förhandsgranskning av de {Math.min(transactions.length, 50)} första transaktionerna
Datum Beskrivning Belopp {transactions.some((t) => t.balance != null) && ( Saldo )} {transactions.some((t) => t.reference) && ( Referens )} {transactions.slice(0, 50).map((tx, i) => ( {tx.date} {tx.description} {formatCurrency(tx.amount)} {transactions.some((t) => t.balance != null) && ( {tx.balance != null ? formatCurrency(tx.balance) : '–'} )} {transactions.some((t) => t.reference) && ( {tx.reference ? ( {tx.reference} ) : ( '–' )} )} ))}
{transactions.length > 50 && (

Visar 50 av {transactions.length} transaktioner

)}
{/* Error blocking continuation */} {hasIssues && (

Filen innehåller fel som förhindrar import

Kontrollera felet ovan och försök ladda upp en korrigerad fil.

)} {/* Navigation */}
) }