import { CircleAlertIcon } from 'lucide-react' import { Alert, AlertDescription, AlertTitle, } from '@/components/reui/alert' import { Button } from '@evofw/ui/components/button' import { Skeleton } from '@evofw/ui/components/skeleton' interface QueryStateProps { isLoading?: boolean isError?: boolean hasData?: boolean error?: Error | null onRetry?: () => void skeleton?: React.ReactNode children: React.ReactNode } function DefaultSkeleton() { return (
) } export function QueryState({ isLoading, isError, hasData = false, error, onRetry, skeleton, children, }: QueryStateProps) { // Keep the child at the same reconciliation position when a background // request fails. Changing the wrapper would unmount uncontrolled form fields. return ( <> {isLoading ? (
{skeleton ?? }
) : isError ? ( {hasData ? 'Не удалось обновить данные — показана предыдущая версия' : 'Не удалось загрузить данные'} {error?.message ?? 'Произошла ошибка при загрузке.'} {onRetry ? ( ) : null} ) : null} {!isLoading && (!isError || hasData) ? children : null} ) }