mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 18:15:35 +01:00
Added report context. Removed report store.
This commit is contained in:
parent
bc37f5124e
commit
bfb52eb678
31 changed files with 372 additions and 273 deletions
|
|
@ -1,41 +1,29 @@
|
|||
import { useContext } from 'react';
|
||||
import FunnelChart from './FunnelChart';
|
||||
import FunnelTable from './FunnelTable';
|
||||
import FunnelParameters from './FunnelParameters';
|
||||
import Report from '../Report';
|
||||
import Report, { ReportContext } from '../Report';
|
||||
import ReportHeader from '../ReportHeader';
|
||||
import ReportMenu from '../ReportMenu';
|
||||
import ReportBody from '../ReportBody';
|
||||
import Funnel from 'assets/funnel.svg';
|
||||
import { useReport } from 'hooks';
|
||||
import useApi from 'hooks/useApi';
|
||||
|
||||
const defaultParameters = {
|
||||
type: 'funnel',
|
||||
parameters: { window: 60, urls: ['/', '/docs'] },
|
||||
};
|
||||
|
||||
export default function FunnelReport({ reportId }) {
|
||||
const report = useReport(reportId, { window: 60, urls: ['/', '/docs'] });
|
||||
const { post, useQuery } = useApi();
|
||||
const { data, isLoading, error } = useQuery(
|
||||
['report:funnel', report?.update],
|
||||
() => {
|
||||
const { websiteId, parameters } = report || {};
|
||||
|
||||
return post(`/reports/funnel`, {
|
||||
websiteId: websiteId,
|
||||
...parameters,
|
||||
startAt: +parameters.dateRange.startDate,
|
||||
endAt: +parameters.dateRange.endDate,
|
||||
});
|
||||
},
|
||||
{ enabled: !!report?.update },
|
||||
);
|
||||
|
||||
return (
|
||||
<Report error={error} loading={data && isLoading}>
|
||||
<ReportHeader icon={<Funnel />} report={report} />
|
||||
<Report reportId={reportId} defaultParameters={defaultParameters}>
|
||||
<ReportHeader icon={<Funnel />} />
|
||||
<ReportMenu>
|
||||
<FunnelParameters report={report} />
|
||||
<FunnelParameters />
|
||||
</ReportMenu>
|
||||
<ReportBody>
|
||||
<FunnelChart report={report} data={data} />
|
||||
<FunnelTable data={data} />
|
||||
<FunnelChart />
|
||||
<FunnelTable />
|
||||
</ReportBody>
|
||||
</Report>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue