mirror of
https://github.com/diced/zipline.git
synced 2025-05-11 18:36:02 +02:00
fix: metrics not loading
This commit is contained in:
parent
49269f77fb
commit
61d48a83f0
2 changed files with 9 additions and 9 deletions
|
@ -3,11 +3,13 @@ import { DatePicker } from '@mantine/dates';
|
|||
import { IconCalendarSearch, IconCalendarTime } from '@tabler/icons-react';
|
||||
import { useState } from 'react';
|
||||
import FilesUrlsCountGraph from './parts/FilesUrlsCountGraph';
|
||||
import StatsCards from './parts/StatsCards';
|
||||
import StatsTables from './parts/StatsTables';
|
||||
import StorageGraph from './parts/StorageGraph';
|
||||
import ViewsGraph from './parts/ViewsGraph';
|
||||
import { useApiStats } from './useStats';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
const StatsCards = dynamic(() => import('./parts/StatsCards'));
|
||||
const StatsTables = dynamic(() => import('./parts/StatsTables'));
|
||||
const StorageGraph = dynamic(() => import('./parts/StorageGraph'));
|
||||
const ViewsGraph = dynamic(() => import('./parts/ViewsGraph'));
|
||||
|
||||
export default function DashboardMetrics() {
|
||||
const [dateRange, setDateRange] = useState<[Date | null, Date | null]>([
|
||||
|
|
|
@ -7,13 +7,13 @@ type ApiStatsOptions = {
|
|||
all?: boolean;
|
||||
};
|
||||
|
||||
const fetcher = async ({ options }: { options: ApiStatsOptions } = { options: {} }) => {
|
||||
const fetcher = async ([url, options]: [string, ApiStatsOptions]) => {
|
||||
const searchParams = new URLSearchParams();
|
||||
if (options.from) searchParams.append('from', options.from);
|
||||
if (options.to) searchParams.append('to', options.to);
|
||||
if (options.all) searchParams.append('all', 'true');
|
||||
|
||||
const res = await fetch(`/api/stats${searchParams.toString() ? `?${searchParams.toString()}` : ''}`);
|
||||
const res = await fetch(`${url}${searchParams.toString() ? `?${searchParams.toString()}` : ''}`);
|
||||
|
||||
if (!res.ok) {
|
||||
const json = await res.json();
|
||||
|
@ -28,9 +28,7 @@ export function useApiStats(options: ApiStatsOptions = {}) {
|
|||
if (!options.from && !options.to)
|
||||
return { data: undefined, error: undefined, isLoading: false, mutate: () => {} };
|
||||
|
||||
const { data, error, isLoading, mutate } = useSWR<Response['/api/stats']>({
|
||||
key: '/api/stats',
|
||||
options,
|
||||
const { data, error, isLoading, mutate } = useSWR<Response['/api/stats']>(['/api/stats', options], {
|
||||
fetcher,
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue