import type { FC } from "react"; import { AreaChart } from "@mantine/charts"; import { Accordion, Badge, ScrollArea, SegmentedControl, Table, Text, } from "@mantine/core"; import { formatChartValue, formatMoney } from "@/shared/lib"; import type { InstrumentChartProps } from "../../model/types"; import classes from "../InstrumentDetails.module.css"; import { InstrumentSection } from "../InstrumentSection.view"; import { useInstrumentChartVm } from "./InstrumentChart.vm"; const InstrumentChart: FC = (props) => { const { chartData, chartLabel, hasIncompleteCandle, periodOptions, priceRows, referenceLines, t, vm, } = useInstrumentChartVm(props); let chartContent; if (vm.candles) { if (chartData.length > 0) { chartContent = ( <> {t( props.priceUnit === "percent" ? "bond.chartNote" : "stock.chartNote", )} {!!hasIncompleteCandle && ( {t("stock.incomplete")} )} {referenceLines.length > 0 && ( {t("stock.averageLine")}:{" "} {formatMoney(vm.position?.averagePurchasePrice)} )} {t("stock.priceTable")} {t("stock.priceTableHint", { count: chartData.length })} {t("stock.date")} {t("stock.price")} {t("stock.candle")} {priceRows.map((candle) => { const displayColor = candle.isComplete ? "gray" : "blue"; return ( {candle.date} {candle.price} {t( candle.isComplete ? "stock.complete" : "stock.forming", )} ); })}
); } else { chartContent = ( {t( vm.candlesState.partial ? "investment.partial" : "stock.noCandles", )} ); } } return ( )} large state={vm.candlesState} title={t("stock.chart")} > {chartContent} ); }; export { InstrumentChart };