import type { FC } from "react"; import { Anchor, Group, Text } from "@mantine/core"; import { EntryCard } from "@wealthledger/ui"; import { useTranslation } from "react-i18next"; import { Link } from "react-router"; import { formatDecimal, formatMoney, formatSnapshotTime, instrumentLogoUrl, } from "@/shared/lib"; import type { BrokerageOperation } from "../api/useBrokerageOperations"; import { operationLabelKey, paymentPresentation } from "../model/display"; type LedgerEntryRowProps = { operation: BrokerageOperation; withDetails?: boolean; wrap?: boolean; }; const LedgerEntryRow: FC = (props) => { const { operation } = props; const { t } = useTranslation(); const instrument = operation.ticker ?? operation.instrumentType ?? t("ledger.noInstrument"); const payment = paymentPresentation(operation); const metadata = [ t("ledger.occurredAt", { date: formatSnapshotTime(operation.occurredAt) }), instrument, props.withDetails ? null : operation.account?.name, ] .filter(Boolean) .join(" ยท "); let details; if (props.withDetails) { details = ( <> {operation.quantity != undefined && ( {t("ledger.quantity", { value: formatDecimal(operation.quantity), })} )} {!!operation.price && ( {t("ledger.price", { value: formatMoney(operation.price) })} )} {!!operation.account && ( {operation.account.name} )} ); } else details = undefined; return ( ); }; export { LedgerEntryRow };