import { type ReactNode } from 'react'; import { View } from 'react-native'; import { Spinner } from '../../atoms/Spinner'; import { Text } from '../../atoms/Text'; import { cn } from '../../lib/cn'; import { EmptyState } from '../../molecules/EmptyState'; interface QueryStateProps { isLoading: boolean; error: Error | null; isEmpty: boolean; loadingText?: string; emptyText?: string; errorText?: string; emptyDescription?: string; errorDescription?: string; children: ReactNode; className?: string; } /** * Patrón visual para listas remotas: * - loading -> spinner centrado * - error -> EmptyState rojo * - vacío -> EmptyState neutro * - data -> children */ export function QueryState({ isLoading, error, isEmpty, loadingText = 'Cargando…', emptyText = 'No hay resultados', errorText = 'Ocurrió un error', emptyDescription, errorDescription, children, className, }: QueryStateProps) { if (isLoading) { return ( {loadingText} ); } if (error) { return ( ); } if (isEmpty) { return ( ); } return <>{children}; }