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
|
|
@ -9,6 +9,7 @@ export * from './useLanguageNames';
|
|||
export * from './useLocale';
|
||||
export * from './useMessages';
|
||||
export * from './usePageQuery';
|
||||
export * from './useReport';
|
||||
export * from './useRequireLogin';
|
||||
export * from './useShareToken';
|
||||
export * from './useSticky';
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ export function useDateRange(websiteId) {
|
|||
const globalConfig = appStore(state => state.dateRange);
|
||||
const dateRange = parseDateRange(websiteConfig || globalConfig || defaultConfig, locale);
|
||||
|
||||
function saveDateRange(value) {
|
||||
const saveDateRange = value => {
|
||||
if (websiteId) {
|
||||
setWebsiteDateRange(websiteId, value);
|
||||
} else {
|
||||
setItem(DATE_RANGE_CONFIG, value);
|
||||
setDateRange(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return [dateRange, saveDateRange];
|
||||
}
|
||||
|
|
|
|||
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