Cristiano Pires 2 years ago
parent 035663f1bb
commit 245afbd6f1

@ -9,8 +9,8 @@ class LeagueTable extends React.Component
constructor() constructor()
{ {
super() super()
// this.league = this.props.league; // this.League = this.props.League;
this.league = {//Leagues[0] this.League = {//Leagues[0]
"name":"Legendary League", "name":"Legendary League",
"players": "players":
[ [
@ -48,7 +48,7 @@ class LeagueTable extends React.Component
} }
rows() rows()
{ {
return this.league.players.map(({ name, points, playedMatches }) => { return this.League.players.map(({ name, points, playedMatches }) => {
return <tr key={name} > return <tr key={name} >
<td>{name}</td> <td>{name}</td>
<td>{points}</td> <td>{points}</td>
@ -60,12 +60,10 @@ class LeagueTable extends React.Component
{ {
return ( return (
<div className='tableContainer' > <div className='tableContainer' >
<h3>{this.league.name}</h3> <h3>{this.League.name}</h3>
<table> <table>
{this.tableHeaders()} {this.tableHeaders()}
<tbody> {this.rows()}
{this.rows()}
</tbody>
</table> </table>
</div> </div>
) )

@ -0,0 +1,74 @@
import './LeagueTable.css'
import React from 'react'
class LeaguesTable extends React.Component
{
constructor(props)
{
super(props);
console.log('constructor', props);
// this.leagues = this.props.leagues;
this.Leagues =[{//Leagues[0]
"name":"Legendary League",
"players":
[
{
"name":"hc12",
"points":10,
"playedMatches":10
},
{
"name":"DashPT5",
"points":10,
"playedMatches":10
}
],
"games":
[
{
"_id":"String"
},
{
"_id": "String"
}
]
},
{ ",name":"League0"},
{"name":"League1"}
]
}
headers()
{
return(
<tr>
<th>Leagues</th>
</tr>
)
}
rows()
{
return this.Leagues.map(({name}) => {
return <tr key={name} >
<td onClick={this.goToLeague}>{name}</td>
</tr>
})
}
goToLeague = (event)=>
{
console.log(this.props)
this.props.GoTo(event.target.innerHTML);
}
render()
{
return(
<table>
{this.headers()}
{this.rows()}
</table>
)
}
}
export default LeaguesTable

@ -18,6 +18,7 @@ class Navigation extends React.Component
</div> </div>
<Routes> <Routes>
<Route exact path="/" element={<Leagues/>}/>
<Route exact path="/Leagues" element={<Leagues/>}/> <Route exact path="/Leagues" element={<Leagues/>}/>
<Route exact path="/Games" element={<Games/>}/> <Route exact path="/Games" element={<Games/>}/>
</Routes> </Routes>

@ -1,18 +1,36 @@
import React from 'react'; import React from 'react';
import Table from '../Components/LeagueTable' import LTable from '../Components/LeagueTable'
import Table from '../Components/LeaguesTable'
var page = null;
function goTo (where)
{
return page = where;
}
function getLeague() function getLeague()
{ {
//TODO
} }
function getAllLeagues()
{
//TODO
}
function Leagues() { function Leagues() {
return (
return (
<div> <div>
<br></br> <br></br>
<br></br> <br></br>
<br></br> <br></br>
<br></br> <br></br>
<Table league={getLeague}/> {page?
(
<LTable League={getLeague} test="test" GoTo={goTo}/>
):
(
<Table Leagues={getAllLeagues}/>
)}
</div> </div>
) )
} }

Loading…
Cancel
Save