import type { FC } from "react"; import { Badge, Group, Skeleton, Stack, Text, } from "@mantine/core"; import { LoadingSkeleton } from "@wealthledger/ui"; import { useTranslation } from "react-i18next"; import { InstrumentChart, InstrumentEvents, InstrumentHeader, InstrumentMetric, InstrumentMetrics, InstrumentPage, InstrumentPosition, InstrumentPrice, InstrumentQuoteStatus, InstrumentTerms, } from "@/features/instrument-details"; import { formatDate, formatDecimal, formatMoney, } from "@/shared/lib"; import type { BondPageVm } from "./BondPage.vm"; import { BondCoupons } from "./components/BondCoupons.view"; import { BondMetrics } from "./components/BondMetrics.view"; type BondPageViewProps = { vm: BondPageVm }; const BondPageView: FC = (props) => { const { vm } = props; const { t } = useTranslation(); const bond = vm.bond; if (!bond) return; const subtitle = `${bond.ticker ?? ""} ยท ${bond.isin ?? ""}`; const maturity = bond.maturityDate ? formatDate(bond.maturityDate) : t("bond.unknown"); const maturityDate = bond.perpetual ? t("bond.perpetual") : maturity; const callDate = bond.callDate ? formatDate(bond.callDate) : t("bond.unknown"); const couponFrequency = bond.couponQuantityPerYear == undefined ? t("bond.unknown") : String(bond.couponQuantityPerYear); const lotSize = bond.lot == undefined ? t("bond.unknown") : String(bond.lot); let quoteContent; if (vm.quoteState.loading) { quoteContent = ( ); } else { quoteContent = ( {t("bond.percentOfNominal")} {vm.quote?.pricePercent == undefined ? t("bond.unknown") : `${formatDecimal(vm.quote.pricePercent)} %`} {vm.quote?.changePercentagePoints != undefined && ( {formatDecimal(vm.quote.changePercentagePoints)}{" "} {t("bond.percentagePoints")} )} {vm.quote?.previousCloseDate ? t("stock.changeBase", { date: formatDate(vm.quote.previousCloseDate), }) : t("stock.noComparison")} {t("bond.indicativePrice")} {!!vm.quote?.unavailable.length && ( {t("stock.partialQuote")} )} ); } return ( {!!bond.floatingCoupon && {t("bond.floatingCoupon")}} {!!bond.amortization && {t("bond.amortization")}} {!!bond.perpetual && {t("bond.perpetual")}} {!!bond.subordinated && ( {t("bond.subordinated")} )} {quoteContent} ); }; export { BondPageView };