import type { FC } from "react"; import { Paper, SimpleGrid, Text, VisuallyHidden } from "@mantine/core"; import { useTranslation } from "react-i18next"; import type { Portfolio } from "@/entities/portfolio"; import { formatDecimal } from "@/shared/lib"; import classes from "../../AccountPage.module.css"; const SIGN_PREFIX_LENGTH = 2; type CurrencyCardsProps = { amounts: Portfolio["totalsByCurrency"]; }; const CurrencyCards: FC = (props) => { const { t } = useTranslation(); const { amounts } = props; const currencies: Record = { EUR: { name: t("portfolio.currencies.EUR"), symbol: "€" }, RUB: { name: t("portfolio.currencies.RUB"), symbol: "₽" }, USD: { name: t("portfolio.currencies.USD"), symbol: "$" }, }; return ( {amounts.map((money) => { const amount = formatDecimal(money.value); return ( {currencies[money.currency]?.name ?? money.currency} {amount.startsWith("-") ? ( <> {amount.slice(0, SIGN_PREFIX_LENGTH)} {amount.slice(SIGN_PREFIX_LENGTH)} ) : ( amount )}{" "} {currencies[money.currency]?.symbol ?? money.currency} ); })} ); }; export { CurrencyCards };