cGoodCard.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { Card, Image, Space } from 'antd';
  2. import { connect } from 'react-redux';
  3. import { Button, Radio } from 'antd';
  4. import { actionCartAdd } from '../action';
  5. import { Link } from 'react-router-dom';
  6. const { Meta } = Card;
  7. const backendURL = "http://shop-roles.asmer.fs.a-level.com.ua" ;
  8. const GoodCard = ({good:{_id, name, price, images}, onAdd}) =>
  9. <Card
  10. hoverable
  11. style={{ width: 240 }}
  12. // cover={images && images[0] && images[0].url &&<Link to={`/good/${_id}`}> <img src={backendURL + '/' + images[0].url} /></Link>}
  13. >
  14. <Meta title={name} />
  15. <Space direction="vertical">
  16. {images && images[0] && images[0].url &&<Link to={`/good/${_id}`}> <Image width={200} height={200} style={{objectFit: 'cover'}} src={backendURL + '/' + images[0].url} /></Link>}
  17. <strong>{price} грн.</strong>
  18. <Button size="middle" onClick={() => onAdd({_id, name, price, images})}>Купить</Button>
  19. </Space>
  20. </Card>
  21. {/* <li className='GoodCard'>
  22. <Link to={`/good/${_id}`}>
  23. <h2>{name}</h2>
  24. {images && images[0] && images[0].url && <img src={backendURL + '/' + images[0].url} />}
  25. </Link>
  26. <strong>{price}</strong>
  27. <button onClick={() => onAdd({_id, name, price, images})}>+</button>
  28. </li> */}
  29. const CGoodCard = connect(null, {onAdd: actionCartAdd})(GoodCard)
  30. export default CGoodCard;