Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import Loading from '../components/Loading'
  3. import Button from 'react-bootstrap/Button';
  4. import ListGroup from 'react-bootstrap/ListGroup'
  5. import { connect } from 'react-redux'
  6. import { fetchBills } from '../redux/actions/billsActions'
  7. import { Bills } from '../components/Bills'
  8. import { Link } from 'react-router-dom'
  9.  
  10.  
  11. class BillsContainer extends Component {
  12.  
  13.  
  14. componentDidMount() {
  15. this.props.fetchBills()
  16. }
  17.  
  18. render() {
  19. if (this.props.bills.length === 0 ) {
  20. return <Loading />
  21. }
  22. return (
  23. <div>
  24. <ListGroup>
  25.  
  26. {this.props.bills.map((b) =>
  27. <ListGroup.Item key={b.id}><Link to={`/bills/${b.id}`} ><Bills name={b.name}/></Link></ListGroup.Item> )}
  28. </ListGroup>
  29. <Button variant="outline-dark">
  30. <Link to="/bills/new/bill">Add Bill</Link>
  31. </Button>
  32. </div>
  33. )
  34. }
  35. }
  36.  
  37. const mapStateToProps = state => {
  38. return {
  39. bills: state.bills.bills
  40. }
  41. }
  42.  
  43.  
  44. export default connect(mapStateToProps, { fetchBills })(BillsContainer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement