import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { AddressNode } from './Types';

interface AddressLabelProps {
  node: AddressNode;
  checked: boolean;
  onClick: (node: AddressNode) => void;
}

export default class AddressLabel extends React.Component<
  AddressLabelProps,
  {}
> {
  static propTypes = {
    node: PropTypes.object,
    checked: PropTypes.bool,
    onClick: PropTypes.func,
  };

  constructor(props: AddressLabelProps) {
    super(props);
    this.handleClick = this.handleClick.bind(this);
  }

  handleClick() {
    this.props.onClick && this.props.onClick(this.props.node);
  }

  render() {
    return (
      <button
        className={classNames('next-cn-address-label', {
          checked: this.props.checked,
        })}
        onClick={this.handleClick}
        // href="#"
      >
        {this.props.node.nameZh}
      </button>
    );
  }
}
