import { useNavigate } from 'react-router-dom';

interface ErrorComponentProps {
  error: string;
}

const ErrorComponent: React.FC<ErrorComponentProps> = ({ error }) => {
  const navigate = useNavigate();

  const handleTryAgain = () => {
    navigate('/home');
  };

  return (
    <div className="result-page error">
      <div className="error-content">
        <div className="error-container">
          <div className="error-text">处理失败</div>
          <div className="error-message">{error}</div>
        </div>
        <div className="error-actions">
          <div className="try-again-btn" onClick={handleTryAgain}>
            再来一张
          </div>
          <div className="back-btn" onClick={() => navigate(-1)}>
            返回
          </div>
        </div>
      </div>
    </div>
  );
};

export default ErrorComponent;
