             [markdown.core :refer [md->html]]
             [ajax.core :as ajax :refer [GET POST]])
   (:import goog.History))
+
+;; MODEL
+
+(def app-state {:teas-list (reagent/atom nil) :new-tea (reagent/atom nil) :edit-tea-id (reagent/atom nil)
+                :edit-tea (reagent/atom nil) :edit-tea-snap (reagent/atom nil) :show-edit (reagent/atom false)})
+
+;; VIEW
 
 (defn nav-link [uri title page collapsed?]
   [:li {:class (when (= page (session/get :page)) "active")}

  [:div.row
   [:div.col-md-12
    [:form {:post "/api/newtea"}
     [:input.form-control {:field :text :id :in-tea :placeholder "Name of New Tea" :value @new-tea :on-change #(reset! new-tea (-> % .-target .-value))}
      [:input.btn.btn-primary {:type "submit" :value (str "Add " @new-tea) :on-click #(post-to-teas-db @new-tea)}]]]]])


(defn tea-edit
  "The component of the form"
  []
  [:div.form-group 
   [:div.row
    [:div.col-md-12
     [:div.p (str "Preview: " (or @edit-tea-snap "*no tea selected*") " -> " (or @edit-tea "*no tea selected*"))]
     [:div.p]
     [:form 
      [:input.form-control {:field :text :id :change-tea :value @edit-tea :on-change #(reset! edit-tea (-> % .-target .-value))}]
      [:input.btn.btn-info {:type "submit" :value "Update Tea Name" :on-click #((update-tea @edit-tea-id @edit-tea)
                                                                                (reset! edit-tea nil)
                                                                                (reset! edit-tea-snap nil))}]]
     [:input.btn.btn-danger {:type "button" :value (str "Delete " @edit-tea-snap) :on-click #(delete-tea @edit-tea)}]]]])

;; this passes the value of the new tea atom into the post-to-teas-db function


          [:tr
           [:td [:li]]
           [:td (second tea)]
           [:td [:input.btn.btn-success {:type "button" :value "Edit" :on-click #(reset-app-state (first tea) (second tea))}]]])]]]]))


(defn tea-adder
