   (route/not-found "Not Found"))
 
 (def app
-  (handler/site app-routes))
+  (-> (handler/site app-routes)
+      wrap-session))

     [:button bs "3. Start voting"]
     [:button bs "4. Show voting results"]])))

(defn show-page-for-step []
  "Show the right page for the current stage: gamemaster, team registr., voting"
  (let [first-visitor? (compare-and-set! state :not-started :brainstorming)]
   (cond
     first-visitor? (page-gamemaster)  ; TODO set cookie to remember the gamemaster
     (= @state :brainstorming) (page-team-registration)
     (= @state :voting) (page-vote))))

(defroutes app-routes
  "/ - depending on the current stage, show either game master's page, team-registration page, or voting page
   /team - new team registration, idea publication
   /teams - overview of all the existing, registered teams and their ideas
  "
  (GET "/" [] (show-page-for-step))
  (context "/team" []
           (GET "/" [] (redirect (let [id (swap! team-counter inc)]  ; TODO assign picture/name of an animal
                                       (swap! teams assoc id "")

  (:require [compojure.handler :as handler]
            [compojure.route :as route]
            [hiccup.page :refer [html5]]
            [ring.util.response :refer [redirect]]
            [ring.middleware.session :refer [wrap-session]]
            [clojure.pprint]))

(def state (atom :not-started))
(def team-counter (atom 1))
