浏览代码

started phone numer parsing

Tomi Cvetic 7 年之前
父节点
当前提交
18bda12d53
共有 3 个文件被更改,包括 32 次插入1 次删除
  1. 4 0
      src/player/components/player-disp.js
  2. 4 0
      src/player/components/player-list.js
  3. 24 1
      src/player/index.js

+ 4 - 0
src/player/components/player-disp.js

@@ -15,6 +15,10 @@ class PlayerDisp extends React.Component {
         <td>{player.BezahltAm ? `${date2s(player.BezahltAm)} ${time2s(player.BezahltAm)}` : 'Unbekannt'}</td>
         <td>{player.isJunior ? 'Junior' : ''}</td>
         <td>{player.isJuniorDP ? 'DP Junior' : ''}</td>
+        <td>{player.TelP}</td>
+        <td>{player.TelG}</td>
+        <td>{player.Mobile}</td>
+        <td>{null}</td>
       </tr>
     )
   }

+ 4 - 0
src/player/components/player-list.js

@@ -20,6 +20,10 @@ class PlayerList extends React.Component {
               <th>Bezahlt Am</th>
               <th>Junior</th>
               <th>DP Junior</th>
+              <th>Tel P</th>
+              <th>Tel G</th>
+              <th>Mobile</th>
+              <th>Telefon</th>
             </tr>
           </thead>
           <tbody>

+ 24 - 1
src/player/index.js

@@ -1,9 +1,29 @@
 import components from './components'
 
-function normalize (item, type) {
+function normalize (item) {
   return item ? String(item).replace(/\s+/g, ' ').trim() : null
 }
 
+function normalizePhone (item) {
+  let phone = String(item).replace(/\s|\+|\(|\)|\/|,|-|'/g, '').replace(/^0+/, '')
+  if (phone.match(/[^\d*]/)) {
+    return `FEHLER: ${phone}`
+  }
+  if (phone.length === 9) {
+    // Missing 0
+    phone = `0${phone}`
+  }
+
+  const len = phone.length
+  if (phone[len - 10] === '0') {
+    return `${phone.substring(len - 10, len - 7)} ${phone.substring(len - 7, len - 4)} ${phone.substring(len - 4, len - 2)} ${phone.substring(len - 2, len)}`
+  }
+  if (len > 10) {
+    return `FEHLER: ${phone} ${phone.substring(0, len - 7)}`
+  }
+  return `${phone}`
+}
+
 const state = {
   players: [],
   filtered: [],
@@ -27,6 +47,9 @@ class Player {
     this.Name = normalize(data[5])
     this.Vorname = normalize(data[6])
     this.Geburtsdatum = data[7]
+    this.TelP = normalizePhone(data[13])
+    this.TelG = normalizePhone(data[14])
+    this.Mobile = normalizePhone(data[15])
     this.Klassierung = normalize(data[17])
     this.LizenzDP = normalize(data[23])
     this.NameDP = normalize(data[24])