import type { ChangeEvent, FC, ReactNode } from "react"; import { Alert, Anchor, Skeleton, Stack, Text, TextInput, 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 InstrumentSearchProps = { children: ReactNode[]; kind: "bond" | "stock"; vm: { canSearch: boolean; code?: string; error: boolean; loading: boolean; onQueryChange: (event: ChangeEvent) => void; partial: boolean; query: string; ready: boolean; }; }; const InstrumentSearchResults: FC = (props) => { const { children, kind, vm } = props; const { t } = useTranslation(); if (vm.loading) return ( ); if (!vm.ready) return; if (children.length > 0) return ( {t(`${kind}.searchVariants`)} {children} ); return ( {t(vm.partial ? "investment.partial" : `${kind}.noSearchResults`)} ); }; const InstrumentSearch: FC = (props) => { const { kind, vm } = props; const { t } = useTranslation(); return (
{t(`${kind}.searchTitle`)} {t(`${kind}.searchSubtitle`)}
{!!vm.partial && {t("investment.partial")}} {!vm.canSearch && {t("stock.searchHint")}} {!!vm.error && ( {t( isApiErrorCode(vm.code, ApiErrorCode.TbankNotConnected) || isApiErrorCode(vm.code, ApiErrorCode.InvalidTbankToken) ? `${kind}.connect` : "stock.sectionError", )} {t("accounts.openSettings")} )}
); }; export { InstrumentSearch };