import type { ComponentProps } from 'react' import { useMemo } from 'react' import { Chart, ChartActions, ChartCard, ChartContent, ChartHeader, ChartLoadingState, ChartMetric, } from 'ui-patterns/Chart' import { PageSection, PageSectionContent } from 'ui-patterns/PageSection' import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader' import { EdgeFunctionChartEmptyState } from './EdgeFunctionChartEmptyState' import { EdgeFunctionInvocationsChart } from './EdgeFunctionInvocationsChart' import { formatRate, getChartEmptyStateCopy } from './EdgeFunctionOverview.utils' import type { InvocationChartDatum, InvocationUpdateAnnotation } from './EdgeFunctionOverview.utils' import { toAlertError } from './EdgeFunctionRecentErrors.utils' import { AlertError } from '@/components/ui/AlertError' interface EdgeFunctionInvocationsSectionProps { dateTimeFormat: string actions?: ComponentProps['actions'] totalInvocationCount: number totalErrorCount: number totalWarningCount: number isLoadingFunction: boolean isErrorFunction: boolean functionError?: unknown isLoadingChart: boolean isErrorChart: boolean chartErrorMessage?: string chartData: InvocationChartDatum[] onChartClick: (timestamp: string) => void updateAnnotation?: InvocationUpdateAnnotation } export const EdgeFunctionInvocationsSection = ({ dateTimeFormat, actions, totalInvocationCount, totalErrorCount, totalWarningCount, isLoadingFunction, isErrorFunction, functionError, isLoadingChart, isErrorChart, chartErrorMessage, chartData, onChartClick, updateAnnotation, }: EdgeFunctionInvocationsSectionProps) => { const emptyStateCopy = useMemo( () => getChartEmptyStateCopy('invocations', isErrorChart, chartErrorMessage), [chartErrorMessage, isErrorChart] ) return ( // No section title: invocations are the Overview's headline metric, right below the page header {isLoadingFunction && } {isErrorFunction && ( )}
} loadingState={} >
) }