Guest User

Untitled

a guest
Dec 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux'
  3. import { Link } from 'react-router-dom'
  4. class Cart extends Component{
  5.  
  6. render(){
  7.  
  8. let addedItems = this.props.items.length ?
  9. (
  10. this.props.items.map(item=>{
  11. return(
  12.  
  13. <li className="collection-item avatar" key={item.id}>
  14. <div className="item-img">
  15. <img src={item.img} alt={item.img} className=""/>
  16. </div>
  17.  
  18. <div className="item-desc">
  19. <span className="title">{item.title}</span>
  20. <p>{item.desc}</p>
  21. <p><b>Price: {item.price}$</b></p>
  22. <p>
  23. <b>Quantity: {item.quantity}</b>
  24. </p>
  25. <div className="add-remove">
  26. <Link to="/cart"><i className="material-icons">arrow_drop_up</i></Link>
  27. <Link to="/cart"><i className="material-icons">arrow_drop_down</i></Link>
  28. </div>
  29. <button className="waves-effect waves-light btn pink remove">Remove</button>
  30. </div>
  31.  
  32. </li>
  33. )
  34. })
  35. ):
  36.  
  37. (
  38. <p>Nothing.</p>
  39. )
  40. return(
  41. <div className="container">
  42. <div className="cart">
  43. <h5>You have ordered:</h5>
  44. <ul className="collection">
  45. {addedItems}
  46. </ul>
  47. </div>
  48. </div>
  49. )
  50. }
  51. }
  52.  
  53. const mapStateToProps = (state)=>{
  54. return{
  55. items: state.addedItems
  56. }
  57. }
  58.  
  59. export default connect(mapStateToProps)(Cart)
Add Comment
Please, Sign In to add comment