import { Button, Card, Empty, Skeleton } from "antd";
import type { ReactNode } from "react";
function errorMessage(error: unknown, fallback: string) {
return error instanceof Error ? error.message : fallback;
}
export function QueryState({
loading,
error,
onRetry,
children,
}: {
loading?: boolean;
error?: unknown;
onRetry?: () => void;
children?: ReactNode;
}) {
if (loading) return ;
if (error) return ;
return <>{children}>;
}
export function LoadingStack({ rows = 3 }: { rows?: number }) {
return (
{Array.from({ length: rows }).map((_, index) => (
))}
);
}
export function ErrorNote({
error,
onRetry,
}: {
error?: unknown;
onRetry?: (() => void) | undefined;
}) {
if (!error) return null;
return (
{errorMessage(error, "操作失败,请重试")}
{onRetry ? (
) : null}
);
}
export function MutationError({ error }: { error?: unknown }) {
return ;
}
export function EmptyState({ description }: { description: string }) {
return ;
}