MatchTable.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React from 'react'
  2. import { date2s, time2s } from '../../helpers.js'
  3. class MatchRow extends React.Component {
  4. render () {
  5. const match = this.props.match
  6. return (
  7. <tr>
  8. <td>{match.Ort || <strong>Kein Platz zugeteilt</strong>}</td>
  9. <td>{match.Datum ? date2s(match.Datum) : <strong>Kein Datum zugeteilt</strong>}</td>
  10. <td>{match.Datum ? time2s(match.Datum) : <strong>Keine Zeit zugeteilt</strong>}</td>
  11. <td>{match.Konkurrenz}</td>
  12. <td>{match.Spieler1}</td>
  13. <td>{match.Spieler2}</td>
  14. </tr>
  15. )
  16. }
  17. }
  18. class MatchTable extends React.Component {
  19. render () {
  20. console.log(this.props)
  21. const matches = this.props.match.allMatches
  22. const filtered = this.props.match.filteredMatches
  23. return (
  24. <div>
  25. <h2>Matches ({filtered.length}/{matches.length})</h2>
  26. <table className='table table-bordered table-striped'>
  27. <thead>
  28. <tr>
  29. <th>Ort</th>
  30. <th>Datum</th>
  31. <th>Zeit</th>
  32. <th>Konkurrenz</th>
  33. <th>Spieler 1</th>
  34. <th>Spieler 2</th>
  35. </tr>
  36. </thead>
  37. <tbody>
  38. {filtered.map((match, key) =>
  39. <MatchRow key={key} match={match} />
  40. )}
  41. </tbody>
  42. </table>
  43. </div>
  44. )
  45. }
  46. }
  47. export default MatchTable