{"size": 993, "ext": "js", "max_stars_repo_path": "src/routes/schoolPrograms/programCard/container.js", "max_stars_repo_name": "CodeforAustralia/cese-snippet", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/routes/schoolPrograms/programCard/container.js", "max_issues_repo_name": "CodeforAustralia/cese-snippet", "max_issues_repo_issues_event_min_datetime": "2018-02-12T08:50:45.000Z", "max_issues_repo_issues_event_max_datetime": "2018-08-09T06:04:31.000Z", "max_forks_repo_path": "src/routes/schoolPrograms/programCard/container.js", "max_forks_repo_name": "CodeforAustralia/cese-snippet", "max_forks_repo_forks_event_min_datetime": "2018-04-03T01:59:41.000Z", "max_forks_repo_forks_event_max_datetime": "2018-04-04T06:40:18.000Z"}
{"max_stars_count": null, "max_issues_count": 63, "max_forks_count": 2, "avg_line_length": 28.3714285714, "max_line_length": 91, "alphanum_fraction": 0.7411883182}
import { connect } from 'react-redux';
import { fetchByFilter as fetchSnippetsByFilter } from "store/snippets/actionCreators";
import {
  selectSnippetsByFilter,
  selectIsFetchingByFilter as selectIsFetchingSnippetsByFilter,
} from "store/snippets/selectors";

const mapStateToProps = (state, ownProps) => {
  const { program, school } = ownProps;
  const filterProps = {
    schoolCode: school.code,
    year: program.year,
    programId: program.id,
  };

  const snippets = selectSnippetsByFilter(state, filterProps); // todo - fetch only first 2
  const isFetchingSnippetsByFilter = selectIsFetchingSnippetsByFilter(state, filterProps);

  return {
    program,
    school,
    filterProps,
    snippets, //: sortByDateCreated(snippets), todo
    isFetchingSnippetsByFilter,
  }
};

const mapDispatchToProps = (dispatch) => {
  return {
    fetchSnippets: (filterProps) => dispatch(fetchSnippetsByFilter(filterProps)),
  }
};

export default connect(mapStateToProps, mapDispatchToProps);
