 
 (defn handle-player-update [report-match path player]
   (debug "handle update" path player)
-  (om/update! report-match path player))
+  (om/update! @report-match path player))
 
-(defn report-match-component [{:keys [players report-match] :as app} owner]
+(defn report-match-component [{:keys [active-players report-match] :as app} owner]
   (reify
     om/IInitState
     (init-state [_]


    om/IRenderState
    (render-state [_ {:keys [team1 team2]}]
      (let [active-players (filterv :active players)
            _  (debug (map (fn [p]  (str "'" (:name p) "'")) (selected-players report-match)))
            __ (debug (map (fn [kw] (get-in report-match [kw :score])) [:team1 :team2]))
            render-team (partial render-team-controls report-match active-players)]
        (html
         [:div
          [:h1 "Report Match Result"]

                                           :placeholder "0"
                                           :input-props {:type "number"}}})]]))))

(defn team-player-component [{:keys [active-players player-num] :as team} owner {:keys [change-ch]}]
  (reify
    om/IRender
    (render [_]
      (html
       (let [player-selector (keyword (str "player" player-num))]
         [:div.form-group
          [:label.control-label.col-lg-4 (str "Player " player-num)]
          [:div.controls.col-lg-8
           (render-players-select team active-players [player-selector] change-ch)]])))))

(defn team-selector [team-num]
  (keyword (str "team" team-num)))

(defn- render-team-controls [{:keys [report-match active-players] :as app}
                             team-num
                             {:keys [score player1 player2] :as chans}]
  (let [team          ((team-selector team-num) report-match)
        render-player (fn [num change-ch]
                        (om/build team-player-component team
                                  {:opts      {:change-ch change-ch}
                                   :react-key (str team-selector "-" num)
                                   :fn        (fn [t] (merge t {:active-players active-players
                                                               :player-num num}))}))]
    (debug "render team" team)
    [:div.col-lg-5.well.well-lg
     [:h2 (str "Team " team-num ":")]
