import { Card, CardContent } from '@/components/ui/card';
import { Skeleton } from '@/components/ui/skeleton';
import type { AssetDetailConfig } from '@/lib/config/assets';
import { getQueryClient, queryKeys } from '@/lib/react-query';
import { cn } from '@/lib/utils';
import { HydrationBoundary, dehydrate } from '@tanstack/react-query';
import { type PropsWithChildren, Suspense } from 'react';
import type { Address } from 'viem';
function AssetDetailGridSkeleton({ className }: { className?: string }) {
return (
{Array.from({ length: 8 }).map((_, index) => (
))}
);
}
export interface AssetDetailGridProps> {
asset: Address;
assetConfig: AssetDetailConfig;
/** Function to fetch the asset data */
dataAction: (asset: Address) => Promise;
className?: string;
}
/**
* Grid component for displaying asset details.
* Note: Child components should implement their own Suspense boundaries for optimal loading states.
*/
export async function AssetDetailGrid>({
asset,
assetConfig,
dataAction,
children,
className,
}: PropsWithChildren>) {
const queryClient = getQueryClient();
const queryKey = queryKeys.asset.detail({ type: assetConfig.queryKey, address: asset });
await queryClient.prefetchQuery({
queryKey,
queryFn: () => dataAction(asset),
});
return (
}>
{children}
);
}