import { Alert, Avatar, Badge, Button, Group, Paper, Skeleton, Stack, Text, Title, } from "@mantine/core"; import { LoadingSkeleton } from "@wealthledger/ui"; import type { FC } from "react"; import { useTranslation } from "react-i18next"; import { InstrumentChart as StockChart, InstrumentEvents as StockEvents, InstrumentPosition as StockPosition, InstrumentSection as StockSection, } from "@/features/instrument-details"; import { formatDate, formatDecimal, formatMoney, formatSnapshotTime, } from "@/shared/lib"; import { StockDividends } from "./components/StockEvents.view"; import classes from "./StockPage.module.css"; import type { StockPageVm } from "./StockPage.vm"; type StockPageViewProps = { vm: StockPageVm }; const StockPageView: FC = (props) => { const { vm } = props; const { t } = useTranslation(); const stock = vm.stock; if (!stock) return null; return (
{stock.name[0]}
{stock.name} {stock.ticker} ·{" "} {t(`stock.shareTypes.${stock.shareType}`, { defaultValue: t("stock.share"), })}
{vm.company?.description ? ( {vm.company.description} ) : null} {vm.stockState.error || vm.quoteState.error ? ( {t(vm.quote ? "accounts.refreshError" : "stock.sectionError")} ) : null} {vm.quoteState.loading ? ( ) : (
{formatMoney(vm.quote?.price ?? null)} {vm.quote?.change ? ( {vm.quote.change.value.startsWith("-") ? "" : "+"} {formatMoney(vm.quote.change)} {vm.quote.changePercent !== null ? ` (${formatDecimal(vm.quote.changePercent)} %)` : ""} ) : null} {vm.quote?.previousCloseDate ? ( {t("stock.changeBase", { date: formatDate(vm.quote.previousCloseDate), })} ) : ( {t("stock.noComparison")} )} {t(`stock.trading.${vm.quote?.tradingStatus}`, { defaultValue: t("stock.trading.unknown"), })} {vm.quote?.priceAt ? ( {t("stock.priceAt", { date: formatSnapshotTime(vm.quote.priceAt), })} ) : null} {vm.quote?.unavailable.length ? ( {t("stock.partialQuote")} ) : null} {vm.quoteState.refreshing ? ( {t("accounts.refreshing")} ) : null}
)} {stock.sector ? ( {t("stock.sector")}:{" "} {t(`stock.sectors.${stock.sector}`, { defaultValue: stock.sector, })} ) : null} {stock.lot !== null ? ( {t("stock.lot", { value: stock.lot })} ) : null} {vm.company ? ( {vm.company.unavailable.length ? ( {t("stock.partialCompany")} ) : null} {vm.company.metrics.length ? (
{vm.company.metrics.map((metric) => (
{t(`stock.metrics.${metric.key}`)} {metric.period ? ` · ${metric.period}` : ""} {new Intl.NumberFormat("ru-RU", { maximumFractionDigits: 2, notation: metric.unit === "money" ? "compact" : "standard", }).format(metric.value)}{" "} {metric.unit === "money" ? new Intl.NumberFormat("ru-RU", { style: "currency", currency: metric.currency ?? "RUB", currencyDisplay: "narrowSymbol", }) .formatToParts(0) .find((part) => part.type === "currency")?.value : metric.unit === "percent" ? "%" : "×"}
))}
) : ( {t("stock.noFundamentals")} )} {t("stock.periodNote")}
) : null}
); }; export { StockPageView };