import React from "react"; import PropTypes from "prop-types"; import { Map } from "immutable"; import { connect } from "react-redux"; import { selectShow, showWishlistToggle, getShowDetails, updateFilter } from "../../actions/shows"; import { isWishlisted } from "../../utils"; import ListDetails from "../list/details"; import ListPosters from "../list/posters"; function mapStateToProps(state) { return { loading: state.showsStore.get("loading"), shows: state.showsStore.get("shows"), filter: state.showsStore.get("filter"), selectedImdbId: state.showsStore.get("selectedImdbId"), exploreOptions: state.showsStore.get("exploreOptions") }; } const mapDispatchToProps = { selectShow, showWishlistToggle, getShowDetails, updateFilter }; const ShowList = props => { const showDetails = imdbId => { props.history.push("/shows/details/" + imdbId); }; let selectedShow = Map(); if (props.selectedImdbId !== "") { selectedShow = props.shows.get(props.selectedImdbId); } return (
props.showWishlistToggle( isWishlisted(selectedShow), selectedShow.get("imdb_id") ) } >
); }; ShowList.propTypes = { match: PropTypes.object, history: PropTypes.object, shows: PropTypes.instanceOf(Map), exploreOptions: PropTypes.instanceOf(Map), selectedImdbId: PropTypes.string, filter: PropTypes.string, loading: PropTypes.bool, showWishlistToggle: PropTypes.func, selectShow: PropTypes.func, getShowDetails: PropTypes.func, updateFilter: PropTypes.func }; export default connect(mapStateToProps, mapDispatchToProps)(ShowList);