mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 22:57:12 +01:00
Added ability to delete reports.
This commit is contained in:
parent
ad710cc86a
commit
95d824542f
8 changed files with 159 additions and 40 deletions
|
|
@ -1,10 +1,23 @@
|
|||
import { useState } from 'react';
|
||||
import useApi from './useApi';
|
||||
|
||||
export function useReports(websiteId) {
|
||||
const { get, useQuery } = useApi();
|
||||
const { data, error, isLoading } = useQuery(['reports'], () => get(`/reports`, { websiteId }));
|
||||
const [modified, setModified] = useState(Date.now());
|
||||
const { get, useQuery, del, useMutation } = useApi();
|
||||
const { mutate } = useMutation(reportId => del(`/reports/${reportId}`));
|
||||
const { data, error, isLoading } = useQuery(['reports:website', { websiteId, modified }], () =>
|
||||
get(`/reports`, { websiteId }),
|
||||
);
|
||||
|
||||
return { reports: data, error, isLoading };
|
||||
const deleteReport = id => {
|
||||
mutate(id, {
|
||||
onSuccess: () => {
|
||||
setModified(Date.now());
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return { reports: data, error, isLoading, deleteReport };
|
||||
}
|
||||
|
||||
export default useReports;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue