mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 21:57:16 +01:00
Report updates.
This commit is contained in:
parent
40f53e8856
commit
0fb93ff00b
147 changed files with 1095 additions and 628 deletions
22
hooks/useReport.js
Normal file
22
hooks/useReport.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import useStore, { createReport } from 'store/reports';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useForceUpdate } from 'hooks';
|
||||
|
||||
export function useReport(reportId) {
|
||||
const [id, setId] = useState(reportId);
|
||||
|
||||
const selector = useCallback(state => state[id], [id]);
|
||||
const report = useStore(selector);
|
||||
|
||||
useEffect(() => {
|
||||
if (!report) {
|
||||
setId(createReport().id);
|
||||
}
|
||||
}, []);
|
||||
|
||||
console.log('USE REPORT', report);
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
export default useReport;
|
||||
Loading…
Add table
Add a link
Reference in a new issue