(ns auto-ap.views.components.sort-by-list
  (:require [re-frame.core :as re-frame]
            [auto-ap.subs :as subs]
            [auto-ap.views.utils :refer [date->str]]
            [reagent.core :as reagent]
            [clojure.string :as str]
            [cljs-time.format :as format]))

(defn sort-by-list [{:keys [sort on-change]}]
  [:div.field.is-grouped.is-grouped-multiline
   (for [{:keys [sort-key sort-name asc]} sort]
     ^{:key sort-key}
     [:div.control
      [:div.tags.has-addons
       [:div.tag.is-medium [:span.icon (if asc
                                         [:i.fa.fa-sort-up]
                                         [:i.fa.fa-sort-down])]
        [:span sort-name] ]
       [:a.tag.is-medium.is-delete {:on-click (fn []
                                                (on-change {:sort (filter #(not= sort-key (:sort-key %)) sort)}))}]]])])

