"use client"; import Link from "next/link"; import { ArrowLeftIcon } from "lucide-react"; import type { BankAccount, LedgerEntry } from "@/payload-types"; import { Item, ItemContent, ItemHeader, ItemTitle } from "@/components/ui/item"; import type { CurrencyConfig } from "@/lib/banking/format"; import { CurrencyAmount } from "@/components/frontend/banking/CurrencyAmount"; import { type AccountStatus, accountStatusBase, accountStatusClass } from "@/lib/banking/ui"; import { accountTypeInfo } from "@/components/frontend/banking/AccountCard"; import { BankTransactionDialog } from "@/components/frontend/banking/BankTransactionDialog"; import { LedgerTable } from "@/components/frontend/banking/LedgerTable"; interface AccountDetailProps { account: BankAccount; ledger: LedgerEntry[]; otherAccounts: { id: number; name: string }[]; canTransact: boolean; currencyConfig: CurrencyConfig; } export function AccountDetail({ account, ledger, otherAccounts, canTransact, currencyConfig, }: AccountDetailProps) { const meta = accountTypeInfo(account.accountType); const Icon = meta.icon; const currency = typeof account.currency === "object" ? account.currency : null; const statusKey = (account.status ?? "open") as AccountStatus; const owner = account.accountType === "personal" ? typeof account.ownerUser === "object" && account.ownerUser ? (account.ownerUser.displayName ?? account.ownerUser.username) : null : account.accountType === "faction" && typeof account.ownerFaction === "object" ? account.ownerFaction?.name : null; return (
Back to Banking

{account.name}

{statusKey} {meta.label} {owner ? ` ยท ${owner}` : ""}

Balance

{canTransact && ( )} Ledger {ledger.length} entr{ledger.length !== 1 ? "ies" : "y"}
); }