index.js 2.0 KB

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