import React from 'react';
import { connect } from 'redux-bundler-react';
import { SidebarButton } from '../../application-controls/index';
import ResourcesModal from './resources-modal'

class ResourcesButton extends React.Component {
  constructor(props){
    super(props);
    this.handleClick = this.handleClick.bind(this);
    this.openModalResources = this.openModalResources.bind(this);
  }

  openModalResources() {
    const { doModalOpen } = this.props;
    doModalOpen( {
      children: [ ResourcesModal ],
      options: {}, 
      openedBy: 'ResourcesButton'
    });
  }

  handleClick(){
    const { doGetResourceData  } = this.props;
    // this.openModalResources(); just for testing
    doGetResourceData();
  }

  render() {
    return (
      <SidebarButton
        iconClass="mdi mdi-library"
        label="Resources"
        title="Resources"
        onClick={ this.handleClick }
      />
    );
  }
}

export default connect(
  "doModalOpen",
  "doGetResourceData",
  ResourcesButton
);