12345678910111213141516171819202122232425262728293031323334353637 |
- import {OneGood} from "./index";
- import {createStore, combineReducers, applyMiddleware, bindActionCreators} from 'redux';
- import {getData, getGoods, actionGoods, getSearchedGoods, actionSearch} from "../reducers";
- import {Provider, connect} from 'react-redux';
- import {GoodsNotFound } from "./index";
- const mapStateToProps = state => ({
- state: state,
- search: getSearchedGoods(state)
- });
-
- const mapDispatchToProps = dispatch => bindActionCreators({
- getData: actionSearch
- }, dispatch);
-
- let image = ""
- const GoodsListSearch = ({search = [], className = "goods"}) => {
- console.log(search)
- if(search.length == 0) {
- return(
- <>
- <GoodsNotFound/>
- </>
- )
- }
- return (
- <div className = {className}>
- {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`}/>)}
- </div>
- )
- }
- const CGoodsListSearch = connect(mapStateToProps, mapDispatchToProps)(GoodsListSearch);
- export default CGoodsListSearch;
|