'use client'; import { api } from '@/trpc/client'; import type { IChartInput } from '@openpanel/validation'; import { AspectContainer } from '../aspect-container'; import { ReportChartEmpty } from '../common/empty'; import { ReportChartError } from '../common/error'; import { ReportChartLoading } from '../common/loading'; import { useReportChartContext } from '../context'; import { Chart } from './chart'; export function ReportFunnelChart() { const { report: { events, range, projectId, funnelWindow, funnelGroup, startDate, endDate, previous, }, isLazyLoading, } = useReportChartContext(); const input: IChartInput = { events, range, projectId, interval: 'day', chartType: 'funnel', breakdowns: [], funnelWindow, funnelGroup, previous, metric: 'sum', startDate, endDate, }; const res = api.chart.funnel.useQuery(input, { keepPreviousData: true, enabled: !isLazyLoading, }); if (isLazyLoading || res.isLoading) { return ; } if (res.isError) { return ; } if (res.data.current.steps.length === 0) { return ; } return ; } function Loading() { return ( ); } function Error() { return ( ); } function Empty() { return ( ); }