   (:require-macros [cljs.core.async.macros :refer [go]]))
 
 (def app-state {:surveys        []
-                :survey-details []
+                :survey-details {:type "FeatureCollection" :features []}
                 :rendered-map?  false})
 
 

          month (:month survey)
          url   (str "/api/survey-details?year=" year "&month=" month)
          resp  (<! (http/get url {"accept" "application/json"}))]
      (dispatch [:received-survey-deatils (:body resp)]))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Handlers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(register-handler
 :initialize-db 
 (fn [_ _]

(register-handler
 :fetch-survey-details
 (fn [app-db [_ survey]]
   (let [year            (:year survey)
         month           (:month survey)
         surveys         (:surveys app-db)
         features        (get-in app-db [:survey-details :features])
         updated-surveys (find-updated-surveys surveys year month)
         final-features  (get-final-features {:year year :month month :features features :surveys surveys})]
     (map-coords final-features)
     (-> app-db
         (assoc-in [:survey-details :features] final-features)
         (assoc :surveys updated-surveys)))))

(register-handler
 :received-survey-deatils
 (fn [app-db [_ features]]
   (let [geo-json (concat (get-in app-db [:survey-details :features]) features)]
     (map-coords geo-json)
     (assoc-in app-db 
                [:survey-details :features]  
                geo-json))))
