 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; UI utils
-
-(defn make-dance-type-presentation [dances]
-  ;; Dances are presented as a list of the first letters of each dance
-  (clojure.string/join (map #(first (:dance/name %)) dances)))
 
 (defn- to-number [s]
   {:pre [(string? s)]}

(defn number-string? [s]
  (if s
    (re-seq #"\d+" s)))

(defn make-round-presentation [round-status round-count]
  (str

   [:input.btn.btn-primary.btn-lg {:type "file" :value "Import file"
                                   :onChange #(on-click-import-file %)}]])

(defn navigation-component []
  [:div
   [:input.btn.btn-default {:type "button" :value "Classes"
                            :on-click #(dispatch [:select-page :classes])}]
   [:input.btn.btn-default {:type "button" :value "Time Schedule"
                            :on-click #(dispatch [:select-page :events])}]])

(defn events-component []
  [:div
   [:h3 "Time Schedule"]
   [:table.table
    [:thead
     [:tr
      [:th {:with "20"} "Time"]
      [:th {:with "20"} "#"]
      [:th {:with "200"} "Dansdisciplin"]
      [:th {:with "20"} "Startande"]
      [:th {:with "20"} "Rond"]
      [:th {:with "20"} "Heats"]
      [:th {:with "20"} "Recall"]
      [:th {:with "20"} "Panel"]
      [:th {:with "20"} "Type"]]]
    [:tbody
     (doall
      (for [event (sort-by :event/position (:competition/events (:competition @app-state)))]
        ^{:key event}
        [:tr
         [:td (make-event-time-presentation (:event/time event) (:event/status event))]
         [:td (:event/position event)]
         ;; use comment if class number is zero
         [:td
          (let [t (into [] (:competition/classes (:competition @app-state)))]
            (if (= (:event/class-number event) 0)
              (:event/comment event)
              (:class/name
               (first (filter #(= (:class/position %) (:event/class-number event)) t)))
              ;(log (:class/name (first t)))
              ))]

         ;[:td (:competition/classes @app-state)]        
         
         [:td "-"]        
         [:td (make-event-round-presentation (:event/round event))]
         [:td (:event/heats event)]
         [:td "-"]
         [:td (:event/adjudicator-panel event)]
         [:td "-"]   
         ]))]]])

; :selected-page :import
(defn menu-component []
 ;[:div]
  (fn []
    [:div
     [import-component]
     [navigation-component]
     (condp = (:selected-page @app-state)
       :classes [dp-classes-component]
       :events [events-component])]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Application
