goodsListSearch.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import {OneGood} from "./index";
  2. import {createStore, combineReducers, applyMiddleware, bindActionCreators} from 'redux';
  3. import {getData, getGoods, actionGoods, getSearchedGoods, actionSearch} from "../reducers";
  4. import {Provider, connect} from 'react-redux';
  5. import {GoodsNotFound } from "./index";
  6. const mapStateToProps = state => ({
  7. state: state,
  8. search: getSearchedGoods(state)
  9. });
  10. const mapDispatchToProps = dispatch => bindActionCreators({
  11. getData: actionSearch
  12. }, dispatch);
  13. let image = ""
  14. const GoodsListSearch = ({search = [], className = "goods"}) => {
  15. console.log(search)
  16. if(search.length == 0) {
  17. return(
  18. <>
  19. <GoodsNotFound/>
  20. </>
  21. )
  22. }
  23. return (
  24. <div className = {className}>
  25. {search.map((good) => <OneGood key = {good._id} name = {good.name} price = {good.price} image = {good.images ? `http://shop-roles.asmer.fs.a-level.com.ua/${good.images[0].url}` : `https://images.ua.prom.st/2259265311_korobka-syurpriz-dlya.jpg`}/>)}
  26. </div>
  27. )
  28. }
  29. const CGoodsListSearch = connect(mapStateToProps, mapDispatchToProps)(GoodsListSearch);
  30. export default CGoodsListSearch;