'use client' import { useTranslations } from 'next-intl' import { motion } from 'framer-motion' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { DataListRow, DataListPrimary, DataListMeta, DataListMetaSeparator, } from '@/components/ui/data-list' import { cn, formatCurrency, formatDate } from '@/lib/utils' import { formatVoucher } from '@/lib/bookkeeping/voucher-series-resolver' import { AlertCircle, ArrowUpRight, ArrowDownRight, Landmark, Link2, Loader2 } from 'lucide-react' import type { SkattekontoMatchSuggestion, StoredSkattekontoTransaction, } from '@/types/skatteverket' /** * Skattekonto-rad in the /transactions inbox. * * Mirrors the visual rhythm of TransactionInboxCard. The Skatteverket badge is * the cue that this row is fundamentally different from a bank tx — different * counter-account (1630 vs 1930), different categorization rules. */ export default function SkattekontoInboxCard({ row, matchSuggestion, processing, onBokfor, onMatch, onAnimationComplete, }: { row: StoredSkattekontoTransaction matchSuggestion?: SkattekontoMatchSuggestion | null processing: boolean onBokfor: (row: StoredSkattekontoTransaction) => void onMatch: (row: StoredSkattekontoTransaction) => void onAnimationComplete?: (id: string) => void }) { const t = useTranslations('tx_skattekonto_card') const amount = Number(row.belopp_skatteverket) const isIncome = amount > 0 const duplicateLabel = matchSuggestion?.voucher_series && matchSuggestion?.voucher_number ? t('duplicate_title_with_voucher', { label: formatVoucher({ voucher_series: matchSuggestion.voucher_series, voucher_number: matchSuggestion.voucher_number, }), }) : t('duplicate_title_draft') return ( { if (typeof definition === 'object' && 'opacity' in definition && definition.opacity === 0) { onAnimationComplete?.(row.id) } }} > {isIncome ? ( ) : ( )} } trailing={ <>

{isIncome ? '+' : ''} {formatCurrency(amount)}

{matchSuggestion ? ( <> ) : ( <> )} } >
{row.transaktionstext}
{formatDate(row.transaktionsdatum)} {t('skv_badge')} {matchSuggestion && ( <> {duplicateLabel} )}
) }