goodCardCharacteristic.js 821 B

12345678910111213141516171819202122
  1. import { Card, Image, Button } from 'antd';
  2. import { connect } from 'react-redux';
  3. import { actionCartAdd } from '../action';
  4. const backendURL = 'http://shop-roles.asmer.fs.a-level.com.ua';
  5. const Good = ({good: {name, images, description, price, _id}, onAdd}) => { console.log(name)
  6. return (
  7. <Card title={name} style={{ width: 350 }} hoverable>
  8. {images && images[0] && images[0].url && <Image width={300} src={backendURL + '/' + images[0].url} />}
  9. <p>{description}</p>
  10. <p>{price} грн</p>
  11. <Button onClick={() => onAdd({_id, name, price, images})}>Купить</Button>
  12. </Card>
  13. )
  14. }
  15. const mapStateToProps = state => ({good: state.promise.goodById?.payload || {}})
  16. const GoodCardCharacteristic = connect(mapStateToProps, {onAdd: actionCartAdd})(Good);
  17. export default GoodCardCharacteristic;