import React from 'react';
import {BaseComponent} from 'frill-core';

/**
 * Error Page component - handles error with status code
 * @extends {FrillCore.BaseComponent}
 * @example <caption>Usage in React-Router</caption>
 * <NotFoundRoute name="Error" handler={C.Error}/>
 */
class ErrorPage extends BaseComponent {
  /**
   * Constructor
   * @param {any} props
   */
  constructor(props) {
    super(props);

    /**
     * Name of component
     */
    this.name = 'Error';
  }

  /**
   * render
   * @return {React DOM}
   * @see https://facebook.github.io/react/docs/component-specs.html#render
   */
  render() {
    const status = this.props.status;
    return (
      <div className="Error">
        <div className="Error-link">
          <a href="/">Back to top</a>
        </div>
        <div>CODE: {status.statusCode}</div>
        <div>ERROR: {status.error}</div>
        <div>MESSAGE: {status.message}</div>
      </div>
    );
  }
}

/**
 * Exports ErrorPage
 */
export default ErrorPage;
