import type { FC } from "react"; import { Anchor, Skeleton, Stack, Text, Title } from "@mantine/core"; import { LoadingSkeleton } from "@wealthledger/ui"; import { useTranslation } from "react-i18next"; import { Link } from "react-router"; import { ApiErrorCode, isApiErrorCode } from "@/shared/api"; type InstrumentPageStateProps = { code?: string; kind: "bond" | "stock"; loading: boolean; }; const InstrumentPageState: FC = (props) => { const { code, kind, loading } = props; const { t } = useTranslation(); if (loading) return ( ); const ambiguousCode = kind === "stock" ? ApiErrorCode.StockTickerAmbiguous : ApiErrorCode.BondTickerAmbiguous; let message = t(`${kind}.unavailableText`); if (isApiErrorCode(code, ambiguousCode)) message = t(`${kind}.ambiguousTicker`); if ( isApiErrorCode(code, ApiErrorCode.TbankNotConnected) || isApiErrorCode(code, ApiErrorCode.InvalidTbankToken) ) message = t(`${kind}.connect`); return ( {t(`${kind}.unavailable`)} {message} {t(`${kind}.backToSearch`)} {t("accounts.openSettings")} ); }; export { InstrumentPageState };