40 lines
2.1 KiB
Clojure
40 lines
2.1 KiB
Clojure
(ns auto-ap.ssr.components.date-range
|
|
(:require [auto-ap.ssr.components :as com]
|
|
[auto-ap.ssr.components.buttons :as but]
|
|
[auto-ap.ssr.svg :as svg]
|
|
[auto-ap.time :as atime]
|
|
[clj-time.coerce :as c]
|
|
[clj-time.core :as t]
|
|
[clj-time.periodic :as per]))
|
|
|
|
(defn date-range-field [{:keys [value id apply-button?]}]
|
|
[:div {:id id}
|
|
(com/field {:label "Date Range"}
|
|
[:div.space-y-4
|
|
[:div
|
|
(com/button-group {:name "date-range"}
|
|
(com/button-group-button {:size :small :value "all" :hx-trigger "click"} "All")
|
|
(com/button-group-button {:size :small :value "week" :hx-trigger "click"} "Week")
|
|
(com/button-group-button {:size :small :value "month" :hx-trigger "click"} "Month")
|
|
(com/button-group-button {:size :small :value "year" :hx-trigger "click"} "Year"))]
|
|
[:div.flex.space-x-1.items-baseline.w-full.justify-start
|
|
(com/date-input {:name "start-date"
|
|
:value (some-> (:start value)
|
|
(atime/unparse-local atime/normal-date))
|
|
:placeholder "Date"
|
|
:size :small
|
|
:class "shrink date-filter-input"})
|
|
|
|
(com/date-input {:name "end-date"
|
|
:value (some-> (:end value)
|
|
(atime/unparse-local atime/normal-date))
|
|
:placeholder "Date"
|
|
:size :small
|
|
:class "shrink date-filter-input"})
|
|
(when apply-button?
|
|
(but/button- {:color :secondary
|
|
:size :small
|
|
:type "button"
|
|
"x-on:click" "$dispatch('datesApplied')"}
|
|
"Apply"))]])])
|