import type { FC, PropsWithChildren, ReactNode } from "react"; import { Alert, Group, Paper, Skeleton, Stack, Text, Title, } from "@mantine/core"; import { LoadingSkeleton } from "@wealthledger/ui"; import { useTranslation } from "react-i18next"; import type { SectionState } from "../model/section"; import classes from "./InstrumentDetails.module.css"; const CHART_SKELETON_HEIGHT_PX = 280; const SECTION_SKELETON_HEIGHT_PX = 65; type InstrumentSectionProps = PropsWithChildren<{ controls?: ReactNode; embedded?: boolean; large?: boolean; state: SectionState; title: string; }>; const InstrumentSection: FC = (props) => { const { t } = useTranslation(); const sectionClassName = props.embedded ? classes.embeddedSection : classes.section; const skeletonHeight = props.large ? CHART_SKELETON_HEIGHT_PX : SECTION_SKELETON_HEIGHT_PX; let sectionContent; if (props.state.loading) { sectionContent = ( ); } else { sectionContent = ( props.children ); } return ( {props.title} {props.controls} {!!props.state.partial && {t("investment.partial")}} {!!(props.state.error && !props.state.hasData) && ( {t("stock.sectionError")} )} {sectionContent} ); }; export { InstrumentSection };