import type React from "react";
import { EmptyState } from "./EmptyState";
import { ErrorState } from "./ErrorState";
import { Skeleton } from "./Skeleton";
export interface AsyncBoundaryProps {
loading: boolean;
error: Error | null;
data: unknown | null;
empty?: boolean;
emptyText?: string;
fallback?: React.ReactNode;
onRetry?: () => void;
children: React.ReactNode;
}
export function AsyncBoundary({
loading,
error,
data,
empty = false,
emptyText = "No data available",
fallback,
onRetry,
children,
}: AsyncBoundaryProps) {
// If there's an error and no stale data, render ErrorState
if (error && data === null) {
return