             [ajax.core :refer [GET POST]]
             [clojure.string :as str]
             [om-bootstrap.button :as b]
+            [om-bootstrap.panel :as p]
+            
   )
   (:import goog.History)
 )

)


(defn getLeaveTypes [data]
 (.log js/console (str "token: " " " (:token  (first (:token @t5pcore/app-state)))       ))

 
  (GET "http://localhost/T5PWebAPI/api/leavetype" {:handler OnGetLeaveTypes
                                            :error-handler error-handler
                                            :headers {:content-type "application/json" :Authorization (str "Bearer "  (:token  (first (:token @t5pcore/app-state)))) }
                                            })

(def jquery (js* "$"))
(defonce app-state (atom  {:leavetypes [] :leavecode "请选择"} ))

(defn leaves-to-map [leave]
  (let [     
      newdata {(keyword (get leave "leavecode")) leave }
    ]
    newdata
  )
)

(defn leaves-to-leavecodes [leave]
  (let [     
      newdata {:leavecode (get leave "leavecode") :name (get leave "name") }
    ]
    newdata
  )
  
)

(defn OnGetLeaveTypes [response]
  ( let [ 
    newdata (map leaves-to-map response)
    leavecodes (map leaves-to-leavecodes response)
  ]
     
     
     (swap! app-state assoc :leavetypes  (into {} newdata) )
     (swap! app-state assoc :leavecodes leavecodes) 
  )
   

   ;(.log js/console (:leavetypes @app-state)) 

)

