Kaynağa Gözat

requested changes.

Tomi Cvetic 7 yıl önce
ebeveyn
işleme
f02fda5013

+ 1 - 0
package.json

@@ -19,6 +19,7 @@
   "scripts": {
     "start": "react-scripts start",
     "build": "react-scripts build",
+    "inline": "node node_modules/html-inline/bin/cmd.js build/index.html -o build/index_inline.html",
     "test": "react-scripts test --env=jsdom",
     "eject": "react-scripts eject"
   }

+ 32 - 4
src/App.js

@@ -253,20 +253,24 @@ class App extends React.Component {
     const worksheets = {}
 
     let placeArray = this.state.match.places
-    if (placeArray.length > 1) {
+    /* if (placeArray.length > 1) {
       placeArray = placeArray.concat([FILTER_OFF])
-    }
+    } */
     const date = Object.keys(this.state.match.dates).find((key) =>
       String(this.state.match.dates[key]) === this.matchDate.value
     )
 
     placeArray.forEach((place) => {
       let header = [
-        [`Zahlliste für den ${date} (${place})`],
+        ['Stadtzürcher Tennismeisterschaft'],
+        [`Nenngelder für ${date}`],
+        [],
+        [`${place}`, null, '50.- oder 30.- (Junioren Jg. 1999 oder jünger)'],
         [],
-        ['bereits bez.', 'Kategorie', 'Zeit', 'Name', 'Betrag bez.', 'Quittung abgeben']
+        ['bereits bez.', 'Kat.', 'Name', 'Betrag bez.', 'Quittung abgeben']
       ]
 
+      // Per place
       let payListPerPlace = []
       this.state.match.filtered.forEach((match) => {
         [match.Spieler1, match.Spieler2].forEach((matchPlayer) => {
@@ -294,6 +298,7 @@ class App extends React.Component {
 
       let footer = [
         [],
+        ['Datum'],
         ['Turnierleiter', null, null, 'Kassierer'],
         ['Betrag von Spielern erhalten', null, null, 'Betrag von Turnierleiter erhalten']
       ]
@@ -302,6 +307,29 @@ class App extends React.Component {
       paylist.SheetNames.push(place)
       paylist.Sheets[place] = worksheets[place]
     })
+
+    let payListPerPlace = []
+    this.state.match.filtered.forEach((match) => {
+      [match.Spieler1, match.Spieler2].forEach((matchPlayer) => {
+        if (matchPlayer) {
+          const player = this.state.player.players.find((player) =>
+            (player.Konkurrenz === match.Konkurrenz) & (player.name === matchPlayer)
+          )
+          let price
+          if (player.isDoubles) {
+            price = (player.isJunior ? 15 : 25) + (player.isJuniorDP ? 15 : 25)
+          } else {
+            price = player.isJunior ? 30 : 50
+          }
+          payListPerPlace.push([ match.Ort, match.Konkurrenz, `${matchPlayer} (${price}.-)` ])
+        }
+      })
+    })
+    console.log(`Generated pay list for "Alle":`, payListPerPlace)
+    worksheets[FILTER_OFF] = Excel.SheetFromArray(payListPerPlace)
+    paylist.SheetNames.push(FILTER_OFF)
+    paylist.Sheets[FILTER_OFF] = worksheets[FILTER_OFF]
+
     Excel.saveAs(paylist, 'Zahlliste.xlsx')
   }
 

+ 20 - 0
src/calendar/components/MatchDisp.js

@@ -0,0 +1,20 @@
+import React from 'react'
+import { date2s, time2s } from '../../helpers.js'
+
+class MatchDisp extends React.Component {
+  render () {
+    const match = this.props.match
+    return (
+      <tr>
+        <td>{match.Ort || <strong>Kein Platz zugeteilt</strong>}</td>
+        <td>{match.Datum ? date2s(match.Datum) : <strong>Kein Datum zugeteilt</strong>}</td>
+        <td>{match.Datum ? time2s(match.Datum) : <strong>Keine Zeit zugeteilt</strong>}</td>
+        <td>{match.Konkurrenz}</td>
+        <td>{match.Spieler1}</td>
+        <td>{match.Spieler2}</td>
+      </tr>
+    )
+  }
+}
+
+export default MatchDisp

+ 34 - 0
src/calendar/components/MatchList.js

@@ -0,0 +1,34 @@
+import React from 'react'
+import MatchDisp from './MatchDisp'
+
+class MatchList extends React.Component {
+  render () {
+    const matches = this.props.match.matches
+    const filtered = this.props.match.filtered
+
+    return (
+      <div>
+        <h2>Matches ({filtered.length}/{matches.length})</h2>
+        <table className='table table-bordered table-striped'>
+          <thead>
+            <tr>
+              <th>Ort</th>
+              <th>Datum</th>
+              <th>Zeit</th>
+              <th>Konkurrenz</th>
+              <th>Spieler 1</th>
+              <th>Spieler 2</th>
+            </tr>
+          </thead>
+          <tbody>
+            {filtered.map((match, key) =>
+              <MatchDisp key={key} match={match} />
+            )}
+          </tbody>
+        </table>
+      </div>
+    )
+  }
+}
+
+export default MatchList

+ 4 - 0
src/calendar/components/index.js

@@ -0,0 +1,4 @@
+import MatchDisp from './MatchDisp'
+import MatchList from './MatchList'
+
+export default { MatchDisp, MatchList }

+ 31 - 0
src/calendar/index.js

@@ -0,0 +1,31 @@
+import { actions, reducer, state } from './state'
+import components from './components'
+import { normalize } from '../helpers.js'
+
+const filters = {
+  all: players => players
+}
+
+const selectors = {}
+
+/** Class representing a player */
+class MatchClass {
+  /**
+   * Create a player
+   * A player data item in the Swisstennis PlayerList.xlsx file has the following columns
+   * Ort | Datum | Zeit | Konkurrenz | Spieler 1 | Spieler 1 Klassierung | Spieler 2 |
+   * Spieler 2 Klassierung | [Resultat]
+   */
+  constructor (data) {
+    this.Ort = normalize(data[0])
+    this.Datum = data[1]
+    this.Konkurrenz = normalize(data[3])
+    this.Spieler1 = normalize(data[4])
+    this.Spieler1Klassierung = normalize(data[5])
+    this.Spieler2 = normalize(data[6])
+    this.Spieler2Klassierung = normalize(data[7])
+    this.isDoubles = this.Konkurrenz.match(/DM.*|[MW]D.*/)
+  }
+}
+
+export default { MatchClass, actions, components, filters, selectors, reducer, state }

+ 29 - 0
src/calendar/state.js

@@ -0,0 +1,29 @@
+/** @module match/state */
+
+/**
+ * state.js
+ *
+ * Collection of everything which has to do with state changes.
+ **/
+
+/** actionTypes define what actions are handeled by the reducer. */
+export const actions = {
+  setState: matches => {
+    type: 'SET_MATCHES',
+    matches
+  }
+}
+console.log('State actions', actions)
+
+/** state definition */
+export const state = {}
+console.log('State state', state)
+
+/** reducer is called by the redux dispatcher and handles all component actions */
+export function reducer (state = [], action) {
+  let nextState = state
+  return nextState
+}
+
+/** sagas are asynchronous workers (JS generators) to handle the state. */
+export function * saga () {}

+ 23 - 0
src/playerList/components/PlayerDisp.js

@@ -0,0 +1,23 @@
+import React from 'react'
+import { date2s, time2s } from '../../helpers'
+
+class PlayerDisp extends React.Component {
+  render () {
+    const player = this.props.player
+    return (
+      <tr>
+        <td><i>{player.Konkurrenz}</i></td>
+        <td><b>{player.Name}</b></td>
+        <td>{player.Vorname}</td>
+        <td><b>{player.NameDP}</b></td>
+        <td>{player.VornameDP}</td>
+        <td>{player.Bezahlt ? 'Ja' : 'Nein'}</td>
+        <td>{player.BezahltAm ? `${date2s(player.BezahltAm)} ${time2s(player.BezahltAm)}` : 'Unbekannt'}</td>
+        <td>{player.isJunior ? 'Junior' : ''}</td>
+        <td>{player.isJuniorDP ? 'DP Junior' : ''}</td>
+      </tr>
+    )
+  }
+}
+
+export default PlayerDisp

+ 36 - 0
src/playerList/components/PlayerList.js

@@ -0,0 +1,36 @@
+import React from 'react'
+import PlayerDisp from './PlayerDisp'
+
+class PlayerList extends React.Component {
+  render () {
+    const filtered = this.props.player.filtered
+
+    return (
+      <div>
+        <h2>Spielerliste ({filtered.length})</h2>
+        <table className='table table-bordered table-striped'>
+          <thead>
+            <tr>
+              <th><i>Konkurrenz</i></th>
+              <th><b>Name</b></th>
+              <th>Vorname</th>
+              <th><b>Name DP</b></th>
+              <th>Vorname DP</th>
+              <th>Bezahlt</th>
+              <th>Bezahlt Am</th>
+              <th>Junior</th>
+              <th>DP Junior</th>
+            </tr>
+          </thead>
+          <tbody>
+            {filtered.map((player, key) =>
+              <PlayerDisp key={key} player={player} />
+            )}
+          </tbody>
+        </table>
+      </div>
+    )
+  }
+}
+
+export default PlayerList

+ 4 - 0
src/playerList/components/index.js

@@ -0,0 +1,4 @@
+import PlayerDisp from './PlayerDisp'
+import PlayerList from './PlayerList'
+
+export default { PlayerDisp, PlayerList }

+ 44 - 0
src/playerList/index.js

@@ -0,0 +1,44 @@
+import { actions, reducer, state } from './state'
+import components from './components'
+import { normalize } from '../helpers.js'
+
+const filters = {
+  all: players => players,
+}
+
+const selectors = {}
+
+/** Class representing a player */
+class Player {
+  /**
+   * Create a player
+   * A player data item in the Swisstennis PlayerList.xlsx file has the following columns
+   * Konkurrenz | Anmeldedatum | Lizenznummer | Klub | Klub Name | Name | Vorname | Geburtsdatum | Adresse | c/o | PLZ | Ort |
+   * Land | Tel P | Tel G | Mobile | Email | Klassierung | Klass. Wert | Gesetzte | Kommentar | Einschränkungen | Kommentar |
+   * Lizenz Nr.Doppelpartner | Name Doppelpartner | Vorname Doppelpartner | Geburtsdatum Doppelpartner | Klassierung Doppelpartner |
+   * Klass. Wert Doppelpartner | bestätigt | On-line Anmeldung | bezahlt
+   */
+  constructor (data) {
+    this.Konkurrenz = normalize(data[0])
+    this.Lizenz = normalize(data[2])
+    this.Name = normalize(data[5])
+    this.Vorname = normalize(data[6])
+    this.Geburtsdatum = data[7]
+    this.Klassierung = normalize(data[17])
+    this.LizenzDP = normalize(data[23])
+    this.NameDP = normalize(data[24])
+    this.VornameDP = normalize(data[25])
+    this.GeburtsdatumDP = data[26]
+    this.KlassierungDP = normalize(data[27])
+    this.Bestaetigt = data[29]
+    this.Bezahlt = data[31]
+    this.BezahltAm = null
+    this.Matches = []
+    this.isDoubles = this.Konkurrenz.match(/DM.*|[MW]D.*/)
+    this.isJunior = (this.Geburtsdatum) ? this.Geburtsdatum.getTime() >= (new Date((new Date()).getFullYear() - 18, 11, 31, 23, 59, 59, 999)).getTime() : false
+    this.isJuniorDP = (this.isDoubles & !!this.GeburtsdatumDP) ? this.GeburtsdatumDP.getTime() >= (new Date((new Date()).getFullYear() - 18, 11, 31, 23, 59, 59, 999)).getTime() : false
+    this.name = this.isDoubles ? `${this.Name} ${this.Vorname} / ${this.NameDP} ${this.VornameDP}` : `${this.Name} ${this.Vorname}`
+  }
+}
+
+export default { Player, actions, components, filters, selectors, reducer, state }

+ 30 - 0
src/playerList/state.js

@@ -0,0 +1,30 @@
+/** @module player/state */
+
+/**
+ * state.js
+ *
+ * Collection of everything which has to do with state changes.
+ **/
+
+
+/** actionTypes define what actions are handeled by the reducer. */
+export const actions = {
+  setState: players => {
+    type: 'SET_PLAYERS',
+    players
+  }
+}
+console.log('State actions', actions)
+
+/** state definition */
+export const state = {}
+console.log('State state', state)
+
+/** reducer is called by the redux dispatcher and handles all component actions */
+export function reducer (state = [], action) {
+  let nextState = state
+  return nextState
+}
+
+/** sagas are asynchronous workers (JS generators) to handle the state. */
+export function * saga () {}