             [goog.history.EventType :as EventType]
             [cljsjs.react :as react]
             [gtfve.maps :as m]
-            [gtfve.data :as data])
+            [gtfve.data :as data]
+            [gtfve.components.app :as app])
   (:import goog.History))
 
 ;; -------------------------

(defonce gmap (atom nil))

;; -------------------------
;; Views

(defn home-page [data owner]
  (om/component
   (html [:div [:h2 "Home Page"]
          [:div [:a {:href "#/about"} "go to the about page"]]])))

(defn about-page [data owner]
  (om/component
   (html [:div [:h2 "About gtfve"]
          [:div [:a {:href "#/"} "go to the home page"]]])))

(defmulti page #(:current-page %))

(defmethod page nil
  [data] home-page)

(defmethod page :home
  [state] home-page)

(defmethod page :about
  [state] about-page)

(defn current-page [data owner]
  (om/component
   (om/build (page (om/value data)) data)))

;; -------------------------
;; Routes
(secretary/set-config! :prefix "#")

(secretary/defroute "/" []
  (session/swap! assoc
                 :current-page :home
                 :map {:opts m/default-map-opts}))

(secretary/defroute "/about" []
  (session/put! :current-page :about))

;; -------------------------
;; History

;; -------------------------
;; Initialize app
(defn init! []
  (om/root app/app
           (atom {})
           {:target (. js/document (getElementById "app"))}))
