Commit 56d8a255 authored by A.M.R.Y Bandara 's avatar A.M.R.Y Bandara

Games leaderboard js file

parent b71b4751
import React, { Component } from 'react';
//import '../../../node_modules/bootstrap/dist/css/bootstrap.min.css';
import Itemcard from "./itemCard";
import data from "./dietData";
import { CartProvider } from "react-use-cart";
import Cart from './Cart';
import '../home-components/App.css';
import axios from "axios";
import Navbar from '../global-components/navbar';
import Footer from '../global-components/footer';
import {Form, Col,Card,Table, Overlay,Modal, Dropdown} from 'react-bootstrap';
class studentMarks extends Component {
constructor(props){
super(props)
this.state={
member: false,
memberID: null,
bmrVal : null,
level1: [],
level2: [],
show: false
}
}
componentDidMount(){
let currentComponent = this;
axios.get('http://127.0.0.1:5000/getData', {
params: {
type: "Addition"
}
}).then(function(response){
console.log(response.data);
if(response.data != null){
currentComponent.setState({level1:response.data["level1"]})
currentComponent.setState({level2:response.data["level2"]})
currentComponent.setState({show:true})
}
}).catch(function(error){
console.log(error);
});
}
// handleInput = (event) => {
// this.setState({memberID:event.target.value})
// }
view = (e) => {
let currentComponent = this;
axios.get('http://127.0.0.1:5000/getData', {
params: {
type: e
}
}).then(function(response){
console.log(response.data);
if(response.data != null){
currentComponent.setState({level1:response.data["level1"]})
currentComponent.setState({level2:response.data["level2"]})
currentComponent.setState({show:true})
}
}).catch(function(error){
console.log(error);
});
}
// console.log(member)
render () {
const rows = this.state.level1;
const rows2 = this.state.level2;
return (
<>
<Navbar/>
<div className="nav2">
<button onClick={() => this.view("Addition")} className="nav_link2">Addition</button>
<button onClick={() => this.view("Substraction")} className="nav_link2">Substraction</button>
<button onClick={() => this.view("Division")} className="nav_link2">Division</button>
<button onClick={() => this.view("Multiplication")} className="nav_link2">Multiplication</button>
</div>
{
this.state.show == true?
<div className="container">
<br/>
<div className="row">
<div className="col-lg-9 col-md-8 col-sm-10 offset-lg-2 offset-md-2 offset-sm-1">
<div className="section-title text-center mb60">
<h2>Level 01</h2>
<hr className="lines"/>
</div>
</div>
</div>
<div className="row align-items-center">
<table id="question">
<thead>
<tr>
<th> </th>
<th>Username</th>
<th>Score</th>
</tr>
</thead>
<tbody>
{
rows.map((q,i) =>(
<tr>
<td>{i+1}</td>
<td>{q[0]}</td>
<td>{q[1]}</td>
</tr>
))
}
</tbody>
</table>
<br/>
<br/>
<br/>
</div>
<br/>
<br/>
<br/>
<div className="row">
<div className="col-lg-9 col-md-8 col-sm-10 offset-lg-2 offset-md-2 offset-sm-1">
<div className="section-title text-center mb60">
<h2>Level 02</h2>
<hr className="lines"/>
</div>
</div>
</div>
<div className="row align-items-center">
<table id="question">
<thead>
<tr>
<th> </th>
<th>Username</th>
<th>Score</th>
</tr>
</thead>
<tbody>
{
rows2.map((q,i) =>(
<tr>
<td>{i+1}</td>
<td>{q[0]}</td>
<td>{q[1]}</td>
</tr>
))
}
</tbody>
</table>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</div>
</div>
:null
}
<Footer/>
</>
);
}
}
export default studentMarks
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment