import * as React from 'react';
import {RouteComponentProps} from 'react-router'; //eslint-disable-line no-unused-vars
import {Link} from 'react-router-dom';

//import {Pokemon} from '../../../api';

interface Pokemon {
  id: number;
  nickname: string;
}

interface PassedRouteProps {
  id?: string;
}

interface State {
  pokemon: Pokemon;
}

class PokemonShow extends React.Component<RouteComponentProps<PassedRouteProps>, State> {
  public state = {
    pokemon: {
      id: null,
      nickname: null,
    },
  };

  public componentDidMount(): void {
    try {
      //const data = await Pokemon.get(this.props.match.params.id);
      //this.setState({pokemon: data.data});
      this.setState({pokemon: {id: 1, nickname: 'Bulbasaur'}});
    } catch (err) {
      // eslint-disable-next-line no-console
      console.log(JSON.stringify(err, null, 2));
    }
  }

  public render(): JSX.Element {
    return (
      <>
        {this.state.pokemon.id}: {this.state.pokemon.nickname}
        <p>
          <Link to={`${this.props.match.url}/404`}>404 page</Link>
        </p>
      </>
    );
  }
}

export default PokemonShow;
