mirror of
https://github.com/BradNut/umami
synced 2025-09-08 17:40:29 +00:00
29 lines
831 B
TypeScript
29 lines
831 B
TypeScript
'use client';
|
|
import useApi from './useApi';
|
|
import useFilterQuery from './useFilterQuery';
|
|
import useCache from 'store/cache';
|
|
|
|
export function useReports({ websiteId, teamId }: { websiteId?: string; teamId?: string }) {
|
|
const modified = useCache((state: any) => state?.reports);
|
|
const { get, del, useMutation } = useApi();
|
|
const queryResult = useFilterQuery({
|
|
queryKey: ['reports', { websiteId, teamId, modified }],
|
|
queryFn: (params: any) => {
|
|
return get('/reports', { websiteId, teamId, ...params });
|
|
},
|
|
});
|
|
const { mutate } = useMutation({ mutationFn: (reportId: string) => del(`/reports/${reportId}`) });
|
|
|
|
const deleteReport = (reportId: any) => {
|
|
mutate(reportId, {
|
|
onSuccess: () => {},
|
|
});
|
|
};
|
|
|
|
return {
|
|
...queryResult,
|
|
deleteReport,
|
|
};
|
|
}
|
|
|
|
export default useReports;
|