import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { push, alertAction } from "../../actions";
import { getSampleList } from "../../actions/SampleActions";
import style from "./ListContainer.module.css";
import SampleList from "../../components/Sample/SampleList";

class ListContainer extends Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    const { getSampleList } = this.props;
    getSampleList().then(res => {});
  }
  render() {
    const { samples = [] } = this.props;
    return (
      <div className={style.container}>
        <SampleList samples={samples} />
      </div>
    );
  }
}

ListContainer.propTypes = {
  push: PropTypes.func,
  getSampleList: PropTypes.func,
  samples: PropTypes.array.isRequired
};

const mapStateToProps = (state, ownProps) => {
  const { samples = [] } = state;
  return { samples };
};

export default connect(
  mapStateToProps,
  { push, getSampleList }
)(ListContainer);
