|
@@ -5,39 +5,22 @@ import {actionPromise} from "./index"
|
|
|
import {gql, actionGoods} from "../reducers/index";
|
|
|
import { useEffect } from 'react';
|
|
|
|
|
|
+ // const Goods = ({className = "goods", goods = [], getData, id}) => {
|
|
|
+ // useEffect(() => getData(id), [id])
|
|
|
|
|
|
-
|
|
|
-const OneGood = ({className = "oneGood", image, name, price}) => {
|
|
|
- return (
|
|
|
- <>
|
|
|
- <div className = {className}>
|
|
|
- <h5>{name}</h5>
|
|
|
-
|
|
|
- <img width = "120px" src = {`http://shop-roles.asmer.fs.a-level.com.ua/${image}`}/>
|
|
|
- <span>{price}грн</span>
|
|
|
- </div>
|
|
|
- </>
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- const Goods = ({className = "goods", state, goods = [], getData, id}) => {
|
|
|
- useEffect(() => getData(id), [id])
|
|
|
- console.log(goods)
|
|
|
- return(
|
|
|
- <>
|
|
|
- <div className = "goodsWrapper">
|
|
|
- <h4>Товары</h4>
|
|
|
- <div className = {className}>
|
|
|
- {goods.map(good => <OneGood name = {good.name} price = {good.price} image = {good.images[0].url}/>)}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </>
|
|
|
- )
|
|
|
- }
|
|
|
+ // return(
|
|
|
+ // <>
|
|
|
+ // <div className = "goodsWrapper">
|
|
|
+ // <h4>Товары</h4>
|
|
|
+ // <div className = {className}>
|
|
|
+ // {goods.map(good => <OneGood key = {good._id} name = {good.name} price = {good.price} image = {good.images[0].url}/>)}
|
|
|
+ // </div>
|
|
|
+ // </div>
|
|
|
+ // </>
|
|
|
+ // )
|
|
|
+ // }
|
|
|
|
|
|
const getGoods = state => {
|
|
|
- console.log(state);
|
|
|
|
|
|
if(state.promiseRed.goods && state.promiseRed.goods.payload) {
|
|
|
return state.promiseRed.goods.payload.data.GoodFind
|
|
@@ -45,6 +28,9 @@ const OneGood = ({className = "oneGood", image, name, price}) => {
|
|
|
|
|
|
return [];
|
|
|
};
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
state: state,
|
|
@@ -55,4 +41,44 @@ const OneGood = ({className = "oneGood", image, name, price}) => {
|
|
|
getData: actionGoods
|
|
|
}, dispatch);
|
|
|
|
|
|
- export default connect(mapStateToProps, mapDispatchToProps)(Goods);
|
|
|
+
|
|
|
+
|
|
|
+const OneGood = ({className = "oneGood", image, name, price}) => {
|
|
|
+
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <div className = {className}>
|
|
|
+ <h5>{name}</h5>
|
|
|
+
|
|
|
+ <img width = "120px" src = {`http://shop-roles.asmer.fs.a-level.com.ua/${image}`}/>
|
|
|
+ <span>{price}грн</span>
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+const GoodsCategory = ({goods = [], id, tittle = "Товари", getData = actionGoods}) => {
|
|
|
+ useEffect(() => getData(id), [id])
|
|
|
+ return(
|
|
|
+ <>
|
|
|
+ <div className = "goodsWrapper">
|
|
|
+ <GoodsList goodsArr = {goods} className = "goods" fn = {console.log("pratsuu")}/>
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+const CGoodsCategory = connect(mapStateToProps, mapDispatchToProps)(GoodsCategory);
|
|
|
+
|
|
|
+const GoodsList = ({goodsArr, className = "goods"}) => {
|
|
|
+ return (
|
|
|
+ <div className = {className}>
|
|
|
+ {goodsArr.map((good) => <OneGood key = {good._id} name = {good.name} price = {good.price} image = {good.images[0].url}/>)}
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+ export default CGoodsCategory;
|