import type { VFC } from 'react'; import type { InstanceInsightsSchemaMetricsSummaryTrendsItem } from 'openapi'; import { Box, Divider, Paper, styled, Typography } from '@mui/material'; import type { TooltipState } from 'component/insights/components/LineChart/ChartTooltip/ChartTooltip'; import { ConditionallyRender } from '../../../../common/ConditionallyRender/ConditionallyRender'; const StyledTooltipItemContainer = styled(Paper)(({ theme }) => ({ padding: theme.spacing(2), })); const StyledItemHeader = styled(Box)(({ theme }) => ({ display: 'flex', justifyContent: 'space-between', gap: theme.spacing(2), alignItems: 'center', })); const InfoLine = ({ iconChar, title, color, }: { iconChar: string; title: string; color: 'info' | 'success' | 'error'; }) => ( theme.palette[color].main, }} > {iconChar} {title} ); export const InfoSummary = ({ data, }: { data: { key: string; value: string | number }[] }) => ( {data.map(({ key, value }) => (
{key}
{value}
))}
); export const MetricsSummaryTooltip: VFC<{ tooltip: TooltipState | null }> = ({ tooltip, }) => { const data = tooltip?.dataPoints.map((point) => { return { label: point.label, title: point.dataset.label, color: point.dataset.borderColor, value: point.raw as InstanceInsightsSchemaMetricsSummaryTrendsItem & { total: number; }, }; }); const limitedData = data?.slice(0, 5); return ( ({ display: 'flex', flexDirection: 'column', gap: theme.spacing(2), width: '300px', })} > {limitedData?.map((point, index) => ( {'● '} {point.title} {point.label} ({ margin: theme.spacing(1.5, 0) })} /> ({ margin: theme.spacing(1.5, 0), })} /> } /> )) || null} ); };