 (defonce app-state
   (atom {:selected [:details]
          :rsvp-search {:name ""
-                       :results nil}
+                       :results nil
+                       :party {}}
+         :party {}
+         :selection {:party nil
+                     :guests nil}
          :response {:contact nil
                     :food-preferences ""
-                    :infos nil
+                    :infos {}
                     :sent false}}))
 
+(defn search []
+  (om/ref-cursor (:rsvp-search (om/root-cursor app-state))))
+
+(defn selection []
+  (om/ref-cursor (get-in (om/root-cursor app-state) [:selection])))
+
 (defn response []
-  (om/ref-cursor (:response (om/root-cursor app-state))))
+  (om/ref-cursor (get-in (om/root-cursor app-state) [:response])))
 
 (defonce Response (.extend (.-Object parse/Parse) "Response"))
 (defonce Info (.extend (.-Object parse/Parse) "Info"))

     [:h1 "Confirmed!"]
     [:pre (with-out-str (pp/pprint @response))]])))

(defn rsvp-search-results-view [{:keys [name results party] :as data} owner]
  (reify
    om/IRender
    (render [_]
      (let [{:keys [infos sent] :as response} (om/observe owner (response))]
        (when (and (some? party)
                   (nil? infos))
          (om/update! response :infos (mapv (fn [guest]
                                              (assoc (select-keys guest [:id :name])
                                                     :attending nil))
                                            (:guests party))))
        (cond (true? sent) (om/build rsvp-confirmation-view response)
              (some? party) (om/build rsvp-card-view party)
              (seq results) (om/build rsvp-multiple-results-view data)
              :else (html [:main
                            [:h2 (str "Oops! No results found for '" name "'")]
                            [:p "Can't find your RSVP? "
                              [:a {:href "???"} "Search again"]]]))))))

(defn rsvp-view [{:keys [results] :as data} owner]
  (reify om/IRender

              (map (fn [[key text]]
                     [:li (if (= selected [key]) {:class "selected"} {})
                      [:a {:href "#"
                           :onClick #(do (reset-all! owner)
                                         (om/update! selected 0 key))}
                       text]])
                   (partition 2 [:details       "Details"
