Metrics components refactoring. New event data page.
This commit is contained in:
@@ -18,3 +18,4 @@ export * from './useSticky';
|
||||
export * from './useTheme';
|
||||
export * from './useTimezone';
|
||||
export * from './useUser';
|
||||
export * from './useWebsite';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import useApi from './useApi';
|
||||
|
||||
export function useReports() {
|
||||
export function useReports(websiteId) {
|
||||
const { get, useQuery } = useApi();
|
||||
const { data, error, isLoading } = useQuery(['reports'], () => get(`/reports`));
|
||||
const { data, error, isLoading } = useQuery(['reports'], () => get(`/reports`, { websiteId }));
|
||||
|
||||
return { reports: data, error, isLoading };
|
||||
}
|
||||
|
||||
10
hooks/useWebsite.js
Normal file
10
hooks/useWebsite.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import useApi from './useApi';
|
||||
|
||||
export function useWebsite(websiteId) {
|
||||
const { get, useQuery } = useApi();
|
||||
return useQuery(['websites', websiteId], () => get(`/websites/${websiteId}`), {
|
||||
enabled: !!websiteId,
|
||||
});
|
||||
}
|
||||
|
||||
export default useWebsite;
|
||||
Reference in New Issue
Block a user