 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-; TODO - Separate concerns : cards values and their id (for better association)
+; TODO - Separate concerns:
+; - cards values and their id, and the order in which they appear
+; - tasks values and their id
 
 (def card-list (r/atom []))
 
 (defn add-task-to!
-  "Add a new task in the card-list"
+  "Add a new task in the card"
   [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! %)))
+
+(defn remove-task-from!
+  "Remove a task from a card"
+  [card-id task-id]
+  (defn remove-if! [card]
+    (if (= card-id (:card-id card))
+      (update-in card [:tasks]
+        (fn [tasks]
+          (filterv #(not= (:task-id %) task-id) tasks)))
+      card))
+  (swap! card-list #(mapv remove-if! %)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 

(defn render-app
  []
  (let [search-text (r/atom "")
        on-search-enter (fn [e] (reset! search-text (.. e -target -value)))]
    (fn []
      [:div
       [:input.search-input

       (when @show-details
         [:div.card__details
          (:description card)
          [render-tasks (:card-id card) (:tasks card)]
          [render-add-list (:card-id card)]
         ])
       ])
