progress towards sales.
This commit is contained in:
@@ -14,40 +14,65 @@
|
||||
;; TODO refunds
|
||||
;; TODO expected deposits
|
||||
;; TODO loading screen
|
||||
;; TODO default date range
|
||||
;; always should be fast
|
||||
;; make params parsing composable
|
||||
|
||||
(defn filters [params]
|
||||
[:form {"hx-trigger" "change delay:1000ms"
|
||||
"hx-get" (bidi/path-for ssr-routes/only-routes
|
||||
:pos-sales-table)
|
||||
"hx-target" "#sales-table"}
|
||||
[:div.space-y-6
|
||||
[:div
|
||||
(com/field {:label "Starting"}
|
||||
(defn date-range-field* [params]
|
||||
[:div#date-range {}
|
||||
(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
|
||||
(com/date-input {:name "start-date"
|
||||
:value (:start-date (:parsed-query-params params))
|
||||
:placeholder "Date"}))]
|
||||
[:div
|
||||
(com/field {:label "Ending"}
|
||||
:placeholder "Date"
|
||||
:size :small})
|
||||
|
||||
(com/date-input {:name "end-date"
|
||||
:value (:end-date (:parsed-query-params params))
|
||||
:placeholder "Date"}))]
|
||||
:placeholder "Date"
|
||||
:size :small})]]
|
||||
)])
|
||||
(defn filters [params]
|
||||
[:form {"hx-trigger" "change delay:500ms, keyup from:.hot-filter delay:1000ms"
|
||||
"hx-get" (bidi/path-for ssr-routes/only-routes
|
||||
:pos-sales-table)
|
||||
"hx-target" "#sales-table"
|
||||
"hx-indicator" "#sales-table"
|
||||
#_#_:hx-disabled-elt "find fieldset"}
|
||||
|
||||
[:fieldset.space-y-6
|
||||
(date-range-field* params)
|
||||
[:div
|
||||
(com/field {:label "Total"}
|
||||
[:div.flex.space-x-4.items-baseline
|
||||
(com/money-input {:name "total-gte"
|
||||
:id "total-gte"
|
||||
:hx-preserve "true"
|
||||
:class "hot-filter"
|
||||
:value (:total-gte (:parsed-query-params params))
|
||||
:placeholder "0.01"})
|
||||
:placeholder "0.01"
|
||||
:size :small})
|
||||
[:div.align-baseline
|
||||
"to"]
|
||||
(com/money-input {:name "total-lte"
|
||||
:hx-preserve "true"
|
||||
:id "total-lte"
|
||||
:class "hot-filter"
|
||||
:value (:total-lte (:parsed-query-params params))
|
||||
:placeholder "9999.34"})])]
|
||||
:placeholder "9999.34"
|
||||
:size :small})])]
|
||||
[:div
|
||||
(com/field {:label "Payment Method"}
|
||||
(com/radio {:name "payment-method"
|
||||
:options [{:value "all"
|
||||
(com/radio {:size :small
|
||||
:name "payment-method"
|
||||
:options [{:value "all"
|
||||
:content "All"}
|
||||
{:value "cash"
|
||||
:content "Cash"}
|
||||
@@ -61,7 +86,8 @@
|
||||
[:div
|
||||
|
||||
(com/field {:label "Processor"}
|
||||
(com/radio {:name "processor"
|
||||
(com/radio {:size :small
|
||||
:name "processor"
|
||||
:options [{:value ""
|
||||
:content "All"}
|
||||
{:value "square"
|
||||
@@ -81,10 +107,14 @@
|
||||
]}))]
|
||||
|
||||
[:div
|
||||
(com/field {:label "Total"}
|
||||
(com/field {:label "Category"}
|
||||
(com/text-input {:name "category"
|
||||
:class "hot-filter"
|
||||
:id "category"
|
||||
:hx-preserve "true"
|
||||
:value (:category (:parsed-query-params params))
|
||||
:placeholder "Fries"}))]]])
|
||||
:placeholder "Fries"
|
||||
:size :small}))]]])
|
||||
|
||||
(defn args->graphql-params [args]
|
||||
{:clients (:clients args)
|
||||
@@ -93,12 +123,12 @@
|
||||
:per-page (:per-page (:parsed-query-params args))
|
||||
:category (not-empty (:category (:parsed-query-params args)))
|
||||
:date-range {:start (some-> args
|
||||
:raw-query-params
|
||||
(get "start-date")
|
||||
:parsed-query-params
|
||||
:start-date
|
||||
(atime/parse atime/iso-date))
|
||||
:end (some-> args
|
||||
:raw-query-params
|
||||
(get "end-date")
|
||||
:parsed-query-params
|
||||
:end-date
|
||||
(atime/parse atime/iso-date))}
|
||||
:total-gte (some-> args :raw-query-params (get "total-gte") not-empty (#(if (string? %) (Double/parseDouble %) (double %))))
|
||||
:total-lte (some-> args :raw-query-params (get "total-lte") not-empty (#(if (string? %) (Double/parseDouble %) (double %))))
|
||||
@@ -118,8 +148,10 @@
|
||||
:id-fn :db/id
|
||||
:fetch-page (fn [user args]
|
||||
(d-sales/get-graphql
|
||||
(args->graphql-params args)
|
||||
))
|
||||
(args->graphql-params args)))
|
||||
:oob-render
|
||||
(fn [user params]
|
||||
[(assoc-in (date-range-field* params) [1 :hx-swap-oob] true)])
|
||||
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
|
||||
:company)}
|
||||
"POS"]
|
||||
@@ -183,7 +215,6 @@
|
||||
{:key "Payment methods"
|
||||
:name "Payment Methods"
|
||||
:render (fn [sales-order]
|
||||
(println )
|
||||
(for [method (->> sales-order :sales-order/charges (map :charge/type-name) set)]
|
||||
(com/pill {:color :primary }
|
||||
method)))}]})
|
||||
|
||||
Reference in New Issue
Block a user