            [bootstrap/glyph {:glyph :warning}] "No flatpacks found!"]
 
           [:div
-           [bootstrap/label {:on-click #(swap! show-popover not)}
+           [bootstrap/label {:on-click toggle-popover}
             package-count " flatpack" (when (< 1 package-count) "s")
-            [bootstrap/overlay {:show @show-popover
+            [bootstrap/overlay {:show @show-popover?
                                 :container (reagent/current-component)}
              [package-total-overlay packages]]]])))))
 
 (defn trolley-item
-  [{:keys [desc name image-src packages id count]} remove-fn add-another-fn]
+  [{:keys [desc name image-src packages id count]} remove-fn add-another-fn on-click-fn]
   [bootstrap/list-group-item {:key id :list-item true}
    [:div
     [:div.contents

   "This product is packaged in " (count packages) " flatpacks or boxes."])

(defn package-total-view
  [item-container packages]
  (let [show-popover (atom false)]
    (fn [_]
      (let [package-count (count packages)]
        (if (zero? package-count)

         ^{:key (:id item)}
         [trolley-item item
          (partial remove-item-from-trolley trolley-state (:id item))
          #(swap! trolley-state update-in [:items] conj item)
          #(swap! trolley-state assoc-in [::flatpack-item] (when % (:id item)))])
       (group-items (:items @trolley-state))))]])

(defn trolley-preview
  [trolley-state]
  (let [selected-flatpack-item (::flatpack-item @trolley-state)
        items (:items @trolley-state)
        packages (reduce (fn [all item]
                           (concat all (map #(assoc % :item item) (:packages item))))
                         [] items)
