import React, { Component } from 'react';
import PropTypes from 'prop-types';
import axios from 'axios';
export default class FirstComponent extends Component {
constructor(props) {
super(props);
this.state = {
prioMatches: this.getMatchData(),
DataIsLoaded: false,
bank: '300.0'
}
this.handleBankChange = this.handleBankChange.bind(this)
}
handleBankChange(event) {
this.setState({ bank: event.target.value })
}
render() {
const { DataIsLoaded, prioMatches } = this.state;
if (!DataIsLoaded) {
return (
LOADING ...
)
}
const element = (Test from Element
)
return ()
}
getMatchData() {
fetch('http://nordh.xyz:8666/?what=getPrioMatches')
.then((res) => res.json())
.then((json) => {
this.setState({
prioMatches: json,
DataIsLoaded: true,
})
});
}
createMatchTableHeader() {
let header = Object.keys(this.state.prioMatches[0])
const handleSortChange = (accessor) => {
// const sortOrder = accessor === sortField && order === "asc" ? "desc" : "asc";
// setSortField(accessor);
// setOrder(sortOrder);
// handleSorting(accessor, sortOrder);
};
return header.map((key, index) => {
return {key.toUpperCase()} |
})
}
createMatchTable() {
return this.state.prioMatches.map((match, index) => {
const { id, date, league, country, homeTeam, awayTeam, odds1, oddsX, odds2, analysisValue } = match
return (
| {id} |
{date} |
{country} |
{league} |
{homeTeam} |
{awayTeam} |
{odds1} |
{oddsX} |
{odds2} |
{analysisValue} |
)
})
}
}
FirstComponent.propTypes = {
displaytext: PropTypes.string.isRequired
};