umami/src/app/(main)/reports/[reportId]/ReportDetails.tsx

29 lines
794 B
TypeScript
Raw Normal View History

2023-09-29 12:29:22 +00:00
import FunnelReport from '../funnel/FunnelReport';
import EventDataReport from '../event-data/EventDataReport';
import InsightsReport from '../insights/InsightsReport';
import RetentionReport from '../retention/RetentionReport';
import { useApi } from 'components/hooks';
const reports = {
funnel: FunnelReport,
'event-data': EventDataReport,
insights: InsightsReport,
retention: RetentionReport,
};
2023-12-03 11:07:03 +00:00
export default function ReportDetails({ reportId }: { reportId: string }) {
2023-09-29 12:29:22 +00:00
const { get, useQuery } = useApi();
2023-12-02 04:27:59 +00:00
const { data: report } = useQuery({
queryKey: ['reports', reportId],
queryFn: () => get(`/reports/${reportId}`),
});
2023-09-29 12:29:22 +00:00
if (!report) {
return null;
}
const ReportComponent = reports[report.type];
return <ReportComponent reportId={reportId} />;
}