diff --git a/src/components/pages/dashboard/index.tsx b/src/components/pages/dashboard/index.tsx index 3b431307..ca144260 100644 --- a/src/components/pages/dashboard/index.tsx +++ b/src/components/pages/dashboard/index.tsx @@ -3,6 +3,7 @@ import Stat from '@/components/Stat'; import type { Response } from '@/lib/api/response'; import { bytes } from '@/lib/bytes'; import useLogin from '@/lib/client/hooks/useLogin'; +import { useSettingsStore } from '@/lib/client/store/settings'; import { isAdministrator } from '@/lib/role'; import { Button, Group, Paper, ScrollArea, SimpleGrid, Skeleton, Table, Text, Title } from '@mantine/core'; import { @@ -17,11 +18,12 @@ import { lazy, Suspense } from 'react'; import { Link } from 'react-router-dom'; import useSWR from 'swr'; -const DashboardFile = lazy(() => import('@/components/file/DashboardFile')); +const ActivityChart = lazy(() => import('./parts/ActivityChart')); +const Recents = lazy(() => import('./parts/Recents')); export default function DashboardHome() { const { user } = useLogin(); - const { data: recent, isLoading: recentLoading } = useSWR('/api/user/recent'); + const { homeShowActivity, homeShowRecents, homeShowTypes } = useSettingsStore((state) => state.settings); const { data: stats, isLoading: statsLoading } = useSWR('/api/user/stats'); const config = useConfig(); @@ -38,6 +40,32 @@ export default function DashboardHome() { + {homeShowRecents && ( + + + + + } + > + + Recent files + + + + + + )} + {user?.quota && (user.quota.maxBytes || user.quota.maxFiles) ? ( {user.quota.filesQuota === 'BY_BYTES' ? ( @@ -60,41 +88,9 @@ export default function DashboardHome() { ) : null} - - Recent files - - - - {recentLoading ? ( - - {[...Array(3)].map((_, i) => ( - - ))} - - ) : recent?.length !== 0 ? ( - - {recent!.map((file, i) => ( - } key={i}> - - - ))} - - ) : ( - - You have no recent files. The last three files you uploaded will appear here. - - )} - Stats + {(!config.features?.metrics?.adminOnly || isAdministrator(user?.role)) && (