commit bfcf271a64c33a60f61f511cec2198d9c8a9c51a Author: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Wed Nov 26 12:32:40 2025 +0100 wip commit8cd3b89fa3Author: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Tue Nov 25 22:33:58 2025 +0100 funnel commit95af86dc44Author: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Tue Nov 25 22:23:25 2025 +0100 wip commit727a218e6bAuthor: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Tue Nov 25 10:18:26 2025 +0100 conversion wip commit958ba535d6Author: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Tue Nov 25 10:18:20 2025 +0100 wip commit3bbeb927ccAuthor: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Tue Nov 25 09:18:48 2025 +0100 wip commitd99335e2f4Author: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Mon Nov 24 18:08:10 2025 +0100 wip commit1fa61b1ae9Author: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Mon Nov 24 15:50:28 2025 +0100 ts commit548747d826Author: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Mon Nov 24 13:17:01 2025 +0100 fix typecheck events -> series commit7b18544085Author: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Mon Nov 24 13:06:46 2025 +0100 fix report table commit57697a5a39Author: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Sat Nov 22 00:05:13 2025 +0100 wip commit06fb6c4f3cAuthor: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Fri Nov 21 11:21:17 2025 +0100 wip commitdd71fd4e11Author: Carl-Gerhard Lindesvärd <lindesvard@gmail.com> Date: Thu Nov 20 13:56:58 2025 +0100 formulas
104 lines
2.1 KiB
TypeScript
104 lines
2.1 KiB
TypeScript
import { useTRPC } from '@/integrations/trpc/react';
|
|
import type { RouterOutputs } from '@/trpc/client';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
|
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, Summary, Tables } from './chart';
|
|
|
|
export function ReportFunnelChart() {
|
|
const {
|
|
report: {
|
|
series,
|
|
range,
|
|
projectId,
|
|
funnelWindow,
|
|
funnelGroup,
|
|
startDate,
|
|
endDate,
|
|
previous,
|
|
breakdowns,
|
|
},
|
|
isLazyLoading,
|
|
} = useReportChartContext();
|
|
|
|
const input: IChartInput = {
|
|
series,
|
|
range,
|
|
projectId,
|
|
interval: 'day',
|
|
chartType: 'funnel',
|
|
breakdowns,
|
|
funnelWindow,
|
|
funnelGroup,
|
|
previous,
|
|
metric: 'sum',
|
|
startDate,
|
|
endDate,
|
|
limit: 20,
|
|
};
|
|
const trpc = useTRPC();
|
|
const res = useQuery(
|
|
trpc.chart.funnel.queryOptions(input, {
|
|
enabled: !isLazyLoading && input.series.length > 0,
|
|
}),
|
|
);
|
|
|
|
if (isLazyLoading || res.isLoading) {
|
|
return <Loading />;
|
|
}
|
|
|
|
if (res.isError) {
|
|
return <Error />;
|
|
}
|
|
|
|
if (!res.data || res.data.current.length === 0) {
|
|
return <Empty />;
|
|
}
|
|
|
|
return (
|
|
<div className="col gap-4">
|
|
{res.data.current.length > 1 && <Summary data={res.data} />}
|
|
<Chart data={res.data} />
|
|
{res.data.current.map((item, index) => (
|
|
<Tables
|
|
key={item.id}
|
|
data={{
|
|
current: item,
|
|
previous: res.data.previous?.[index] ?? null,
|
|
}}
|
|
/>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function Loading() {
|
|
return (
|
|
<AspectContainer>
|
|
<ReportChartLoading />
|
|
</AspectContainer>
|
|
);
|
|
}
|
|
|
|
function Error() {
|
|
return (
|
|
<AspectContainer>
|
|
<ReportChartError />
|
|
</AspectContainer>
|
|
);
|
|
}
|
|
|
|
function Empty() {
|
|
return (
|
|
<AspectContainer>
|
|
<ReportChartEmpty />
|
|
</AspectContainer>
|
|
);
|
|
}
|