umami/components/pages/reports/funnel/FunnelPage.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-05-15 06:38:03 +02:00
import { useMutation } from '@tanstack/react-query';
2023-05-12 01:42:58 +02:00
import Page from 'components/layout/Page';
2023-05-15 06:38:03 +02:00
import PageHeader from 'components/layout/PageHeader';
2023-05-18 20:17:35 +02:00
import ReportsLayout from 'components/layout/ReportsLayout';
2023-05-15 06:38:03 +02:00
import useApi from 'hooks/useApi';
import { useState } from 'react';
2023-05-12 01:42:58 +02:00
import FunnelChart from './FunnelChart';
2023-05-15 06:38:03 +02:00
import FunnelTable from './FunnelTable';
2023-05-12 01:42:58 +02:00
import FunnelForm from './FunnelForm';
2023-05-18 20:17:35 +02:00
2023-05-15 06:38:03 +02:00
import styles from './FunnelPage.module.css';
2023-05-12 01:42:58 +02:00
export default function FunnelPage() {
2023-05-15 06:38:03 +02:00
const { post } = useApi();
const { mutate, error, isLoading } = useMutation(data => post('/reports/funnel', data));
2023-05-18 20:17:35 +02:00
const [data, setData] = useState([{}]);
2023-05-15 23:03:42 +02:00
const [formData, setFormData] = useState();
2023-05-15 06:38:03 +02:00
function handleOnSearch(data) {
2023-05-15 23:03:42 +02:00
setFormData(data);
2023-05-15 06:38:03 +02:00
mutate(data, {
onSuccess: async data => {
setData(data);
},
});
2023-05-12 01:42:58 +02:00
}
return (
2023-05-18 20:17:35 +02:00
<ReportsLayout filter={<FunnelForm onSearch={handleOnSearch} />} header={'test'}>
<Page>
<PageHeader title="Funnel Report"></PageHeader>
<FunnelChart data={data} />
<FunnelTable data={data} />
</Page>
</ReportsLayout>
2023-05-12 01:42:58 +02:00
);
}