import { AreaChart } from "@mantine/charts"; import { Accordion, Badge, ScrollArea, SegmentedControl, Table, Text, } from "@mantine/core"; import type { FC } from "react"; import { useTranslation } from "react-i18next"; import { formatDecimal, formatMoney } from "@/shared/lib"; import type { InstrumentChartVm } from "../model/types"; import classes from "./InstrumentDetails.module.css"; import { InstrumentSection } from "./InstrumentSection.view"; type InstrumentChartProps = { vm: InstrumentChartVm; priceUnit?: "percent" }; const InstrumentChart: FC = (props) => { const { vm } = props; const { t } = useTranslation(); return ( ({ value, label: t(`stock.periods.${value}`), }))} /> } > {vm.candles ? ( vm.chartData.length ? ( <> new Intl.NumberFormat("ru-RU", { maximumFractionDigits: 4, }).format(value) } aria-label={t( props.priceUnit === "percent" ? "bond.chartLabel" : "stock.chartLabel", { currency: props.priceUnit === "percent" ? t("bond.percentOfNominal") : (vm.candles.currency ?? ""), }, )} /> {t( props.priceUnit === "percent" ? "bond.chartNote" : "stock.chartNote", )} {vm.hasIncompleteCandle ? ( {t("stock.incomplete")} ) : null} {vm.averageLine !== null ? ( {t("stock.averageLine")}:{" "} {formatMoney(vm.position?.averagePurchasePrice ?? null)} ) : null} {t("stock.priceTable")} {t("stock.priceTableHint", { count: vm.chartData.length })} {t("stock.date")} {t("stock.price")} {t("stock.candle")} {vm.priceRows.map((candle) => ( {candle.date} {props.priceUnit === "percent" ? `${formatDecimal(candle.close)} %` : formatMoney( vm.candles?.currency ? { value: candle.close, currency: vm.candles.currency, } : null, )} {t( candle.isComplete ? "stock.complete" : "stock.forming", )} ))}
) : ( {t("stock.noCandles")} ) ) : null}
); }; export { InstrumentChart };