import Dashboard from "@/components/dashboard/dashboard"; import { fetchServer } from '@/lib/api'; import { performance } from 'perf_hooks'; import { Info, GitCommit, User, Zap } from 'lucide-react'; import packageJson from '../../package.json'; import { getGitInfo, getShortGitHash } from '@/lib/utils/git'; import { Suspense } from 'react'; import dynamic from 'next/dynamic'; import { Skeleton } from '@/components/ui/skeleton'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; // Lazy load the Content component const Content = dynamic(() => import("@/components/dashboard/content"), { loading: () => }); // Loading skeleton for the dashboard content function DashboardContentSkeleton() { return (
{/* Header skeleton */}
{/* Stats cards skeleton */}
{[...Array(4)].map((_, i) => ( ))}
{/* Best selling products skeleton */}
{[...Array(5)].map((_, i) => (
))}
); } // ✅ Corrected Vendor Type interface Vendor { _id: string; username: string; storeId: string; pgpKey: string; __v: number; } interface User { vendor: Vendor; } interface OrderStats { totalOrders: number; pendingOrders: number; completedOrders: number; cancelledOrders: number; } export default async function DashboardPage() { const startTime = performance.now(); const [userResponse, orderStats] = await Promise.all([ fetchServer("/auth/me"), fetchServer("/orders/stats") ]); // Get git info using the new utility const gitInfo = getGitInfo(); const endTime = performance.now(); const generationTime = (endTime - startTime).toFixed(2); const panelVersion = packageJson.version; const commitHash = gitInfo.hash; const vendor = userResponse.vendor; return ( }>
v{panelVersion}
{vendor.username}
{commitHash}
Generated in {generationTime}ms
{process.env.NODE_ENV || 'development'}
); }