import React from 'react';
import { View, Text } from '@tarojs/components';
import './index.scss';

interface ErrorStateProps {
  text?: string;
  onRetry?: () => void;
}

export default React.memo(function ErrorState({
  text = '加载失败，请稍后重试',
  onRetry,
}: ErrorStateProps) {
  return (
    <View className='error-state'>
      <Text className='error-state-icon'>⚠️</Text>
      <Text className='error-state-text'>{text}</Text>
      {onRetry && (
        <View className='error-state-retry' onClick={onRetry}>
          <Text className='error-state-retry-text'>重新加载</Text>
        </View>
      )}
    </View>
  );
});
