(ns auto-ap.views.components.number-filter
  (:require
   [clojure.spec.alpha :as s]
   [auto-ap.entities.invoice :as invoice]
   [auto-ap.views.utils :refer [bind-field date-picker date->str local-now standard]]
   [cljs-time.core :as t]
   [re-frame.core :as re-frame]))

(defn dispatch-change [on-change-event start end]
  (fn [_]
    (re-frame/dispatch (into on-change-event [[:start] start]) )
    (re-frame/dispatch (into on-change-event [[:end] end]))))

(defn number-filter [{:keys [value on-change-event]}]
  [:div.field 
   [:div.control 
    [:div.columns 
     [:div.column 
      [bind-field 
       [:input.input {:type "number"
                      :placeholder ">="
                      :field [:amount-gte]
                      :step "0.01"
                      :event on-change-event
                      :subscription value}]]]
     [:div.column
      [bind-field
       [:input.input {:type "number"
                      :placeholder "<="
                      :field [:amount-lte]
                      :event on-change-event
                      :step "0.01"
                      :subscription value}]]]]]]
  )
