import { Avatar, Paper, Stack, Text } from "@mantine/core"; import type { FC } from "react"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { formatSnapshotTime, instrumentLogoUrl } from "@/shared/lib"; import type { BrokerageOperation } from "../api/useBrokerageOperations"; import { paymentPresentation } from "../model/display"; import classes from "./LedgerEntryRow.module.css"; type LedgerEntryRowProps = { operation: BrokerageOperation; }; const LedgerEntryRow: FC = (props) => { const { operation } = props; const { t } = useTranslation(); const [imageFailed, setImageFailed] = useState(false); const instrument = operation.ticker ?? operation.instrumentType ?? t("ledger.noInstrument"); const logoSrc = imageFailed ? null : instrumentLogoUrl(operation.logoName); const payment = paymentPresentation(operation); const metadata = [formatSnapshotTime(operation.occurredAt), instrument].join( " ยท ", ); return ( {operation.description || operation.type} {metadata} {payment.amount} {t(payment.label)} ); }; export { LedgerEntryRow };