 
 (def card-list (r/atom []))
 
+(defn add-task-to!
+  [card-id task]
+  (defn add-if! [card]
+    (if (= card-id (:card-id card))
+      (update-in card [:tasks] conj (create-task! task false))
+      card))
+  (swap! card-list #(mapv add-if! %)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (def init-card-list
   "Fake card list returned by the server"
-  [(create-card
+  [(create-card!
      "1st card"
      "This is my first description"
      :bug-fix
      :backlog
-     (create-task "Done some stuff" true))
-   (create-card
+     (create-task! "Done some stuff" true))
+   (create-card!
      "2nd card"
      "This is my second description"
      :enhancement
      :under-dev
-     (create-task "Done some stuff" true)
-     (create-task "Done some more stuff" false))
-   (create-card
+     (create-task! "Done some stuff" true)
+     (create-task! "Done some more stuff" false))
+   (create-card!
      "3rd card"
      "This is my third description"
      :bug-fix
      :under-dev)
-   (create-card
+   (create-card!
      "4th card"
      "This is my fourth description"
      :enhancement

        title-style #(if % :div.card__title--is-open :div.card__title)
        add-task (fn [card-id e]
                   (when (= "Enter" (.-key e))
                     (js/alert "Find the task and add one task to it")                 
                     (set! (.. e -target -value) "")
                   ))
        ]

   :name name
   :done done})

(defn create-card!
  "Create a card to display in the dash-board"
  [title description category status & tasks]
  (swap! next-card-id inc)
