|
@@ -1,21 +1,47 @@
|
|
|
-import React, { Component } from 'react';
|
|
|
-import logo from './logo.svg';
|
|
|
-import './App.css';
|
|
|
+import React from 'react'
|
|
|
+import XLSX from 'xlsx'
|
|
|
+import PlayerList from './player/player-list'
|
|
|
+import MatchList from './match/match-list'
|
|
|
|
|
|
-class App extends Component {
|
|
|
- render() {
|
|
|
+class App extends React.Component {
|
|
|
+ constructor () {
|
|
|
+ super()
|
|
|
+ this.state = { players: [], matches: [] }
|
|
|
+ this.handleChange = this.handleChange.bind(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ handleChange (event) {
|
|
|
+ const f = event.target.files[0]
|
|
|
+ console.log(f)
|
|
|
+ const reader = new FileReader()
|
|
|
+ reader.onload = (e) => {
|
|
|
+ const data = e.target.result
|
|
|
+ const workbook = XLSX.read(data, {type: 'binary'})
|
|
|
+ const jsonWB = XLSX.utils.sheet_to_json(workbook.Sheets.Players, {header: 1})
|
|
|
+ console.log(jsonWB)
|
|
|
+ this.setState({ players: jsonWB.slice(4, jsonWB.length) })
|
|
|
+ console.log(this.state)
|
|
|
+ }
|
|
|
+ reader.readAsBinaryString(f)
|
|
|
+ }
|
|
|
+
|
|
|
+ render () {
|
|
|
return (
|
|
|
- <div className="App">
|
|
|
- <div className="App-header">
|
|
|
- <img src={logo} className="App-logo" alt="logo" />
|
|
|
- <h2>Welcome to React</h2>
|
|
|
- </div>
|
|
|
- <p className="App-intro">
|
|
|
- To get started, edit <code>src/App.js</code> and save to reload.
|
|
|
- </p>
|
|
|
+ <div className='App'>
|
|
|
+ <form>
|
|
|
+ <label for='playerList'>Swisstennis playerList.xls</label>
|
|
|
+ <input type='file' id='playerList' accept='.xls' placeholder='playerList File' onChange={this.handleChange} />
|
|
|
+ <label for='Calendar'>Swisstennis Calendar.xls</label>
|
|
|
+ <input type='file' id='Calendar' accept='.xls' placeholder='Calendar File' onChange={this.handleChange} />
|
|
|
+ <label for='Date'>Datum</label>
|
|
|
+ <input type='date' />
|
|
|
+ <button>Excel-Files generieren.</button>
|
|
|
+ </form>
|
|
|
+ <PlayerList players={this.state.players} />
|
|
|
+ <MatchList matches={this.state.matches} />
|
|
|
</div>
|
|
|
- );
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export default App;
|
|
|
+export default App
|