'use client' import { Suspense, lazy, ComponentType } from 'react' import { Skeleton } from '@/components/ui/skeleton' interface LazyComponentProps { fallback?: React.ReactNode className?: string } // Generic lazy loading wrapper export function createLazyComponent>( importFunction: () => Promise<{ default: T }>, fallback?: React.ReactNode ) { const LazyComponent = lazy(importFunction) return function LazyWrapper(props: React.ComponentProps & LazyComponentProps) { const { fallback: customFallback, className, ...componentProps } = props const defaultFallback = (
) return ( )} /> ) } } // Product Grid Skeleton export function ProductGridSkeleton({ count = 8 }: { count?: number }) { return (
{Array.from({ length: count }).map((_, i) => (
))}
) } // Chart Skeleton export function ChartSkeleton({ className }: { className?: string }) { return (
) } // Dashboard Stats Skeleton export function DashboardStatsSkeleton() { return (
{Array.from({ length: 4 }).map((_, i) => (
))}
) } // Table Skeleton export function TableSkeleton({ rows = 5, cols = 4 }: { rows?: number, cols?: number }) { return (
{/* Header */}
{Array.from({ length: cols }).map((_, i) => ( ))}
{/* Rows */} {Array.from({ length: rows }).map((_, rowIndex) => (
{Array.from({ length: cols }).map((_, colIndex) => ( ))}
))}
) } // Form Skeleton export function FormSkeleton() { return (
) }