import type { ComponentProps } from 'react' import { useMemo } from 'react' import { Skeleton } from 'ui' import { Chart, ChartActions, ChartCard, ChartContent, ChartHeader, ChartLoadingState, ChartMetric, } from 'ui-patterns/Chart' import { PageSection, PageSectionAside, PageSectionContent, PageSectionMeta, PageSectionSummary, PageSectionTitle, } 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' import type { ChartIntervals } from '@/types' interface EdgeFunctionInvocationsSectionProps { selectedInterval: ChartIntervals actions?: ComponentProps['actions'] totalInvocationCount: number totalErrorCount: number totalWarningCount: number isLoadingFunction: boolean isErrorFunction: boolean functionError?: unknown isLoadingChart: boolean isErrorChart: boolean chartErrorMessage?: string chartData: InvocationChartDatum[] onChartClick: () => void updateAnnotation?: InvocationUpdateAnnotation } export const EdgeFunctionInvocationsSection = ({ selectedInterval, actions, totalInvocationCount, totalErrorCount, totalWarningCount, isLoadingFunction, isErrorFunction, functionError, isLoadingChart, isErrorChart, chartErrorMessage, chartData, onChartClick, updateAnnotation, }: EdgeFunctionInvocationsSectionProps) => { const dateTimeFormat = selectedInterval.format ?? 'MMM D, h:mma' const emptyStateCopy = useMemo( () => getChartEmptyStateCopy('invocations', isErrorChart, chartErrorMessage), [chartErrorMessage, isErrorChart] ) return ( {isLoadingFunction || isLoadingChart ? ( <> {' '} Total Invocations ) : ( <> {totalInvocationCount.toLocaleString('en-US')}{' '} Total Invocations )} {actions && actions.length > 0 ? ( ) : null} {isLoadingFunction ? ( ) : isErrorFunction ? ( ) : (
} loadingState={} >
)}
) }