Adds little indicator on bank account form

This commit is contained in:
2024-03-08 19:19:22 -08:00
parent 9dc9078a0d
commit 7b622b945a
8 changed files with 149 additions and 33 deletions

View File

@@ -7,6 +7,8 @@
[auto-ap.logging :as alog]
[auto-ap.routes.admin.clients :as route]
[auto-ap.routes.queries :as q]
[auto-ap.routes.indicators :as indicators]
[auto-ap.ssr.indicators :as i]
[auto-ap.routes.utils
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
[auto-ap.solr :as solr]
@@ -797,23 +799,33 @@
:value (fc/field-value)})]))
(fc/with-field :bank-account/start-date
(com/validated-field {:errors (fc/field-errors)
:label "Start Date"}
[:div {:class "w-[7em]"}
(com/date-input {:name (fc/field-name)
:error? (fc/error?)
:placeholder "12/01/2023"
:class "w-[5em]"
:value (some-> (fc/field-value)
[:div.flex.space-x-2.items-center
(com/validated-field {:errors (fc/field-errors)
:label "Start Date"}
[:div {:class "w-[7em]"}
(com/date-input {:name (fc/field-name)
:error? (fc/error?)
:placeholder "12/01/2023"
:hx-get (bidi/path-for ssr-routes/only-routes
::indicators/days-ago)
:hx-trigger "change"
:hx-target "#days-indicator"
:hx-vals "js:{date: event.target.value}"
:hx-swap "innerHTML"
:class "w-[5em]"
:value (some-> (fc/field-value)
(clj-time.coerce/to-date-time)
;; todo do date coercion in the input
(atime/unparse-local atime/normal-date))})])
[:div#days-indicator
(i/days-ago* (some-> (fc/field-value)))]])
(clj-time.coerce/to-date-time)
(atime/unparse-local atime/normal-date))})]))
(fc/with-field :bank-account/include-in-reports
(com/checkbox {:name (fc/field-name)
:value (boolean (fc/field-value))
:checked (fc/field-value)}
"Include in reports"))
[:div
[:div
(fc/with-field :bank-account/visible
(com/checkbox {:name (fc/field-name)
:value (boolean (fc/field-value))
@@ -938,17 +950,27 @@
:value (fc/field-value)})]))
(fc/with-field :bank-account/start-date
(com/validated-field {:errors (fc/field-errors)
:label "Start Date"}
[:div {:class "w-[7em]"}
(com/date-input {:name (fc/field-name)
:error? (fc/error?)
:placeholder "12/01/2023"
:class "w-[5em]"
:value (some-> (fc/field-value)
(clj-time.coerce/to-date-time)
[:div.flex.space-x-2.items-center
(com/validated-field {:errors (fc/field-errors)
:label "Start Date"}
[:div {:class "w-[7em]"}
(com/date-input {:name (fc/field-name)
:error? (fc/error?)
:placeholder "12/01/2023"
:hx-get (bidi/path-for ssr-routes/only-routes
::indicators/days-ago)
:hx-trigger "change"
:hx-target "#days-indicator"
:hx-vals "js:{date: event.target.value}"
:hx-swap "innerHTML"
:class "w-[5em]"
:value (some-> (fc/field-value)
(clj-time.coerce/to-date-time)
;; todo do date coercion in the input
(atime/unparse-local atime/normal-date))})]))
(atime/unparse-local atime/normal-date))})])
[:div#days-indicator
(i/days-ago* (some-> (fc/field-value))) ]])
(fc/with-field :bank-account/include-in-reports
(com/checkbox {:name (fc/field-name)
@@ -956,7 +978,7 @@
:checked (fc/field-value)}
"Include in reports"))
[:div
[:div
(fc/with-field :bank-account/visible
(com/checkbox {:name (fc/field-name)
:value (boolean (fc/field-value))
@@ -1038,17 +1060,26 @@
:value (fc/field-value)})]))
(fc/with-field :bank-account/start-date
(com/validated-field {:errors (fc/field-errors)
:label "Start Date"}
[:div {:class "w-[7em]"}
(com/date-input {:name (fc/field-name)
:error? (fc/error?)
:placeholder "12/01/2023"
:class "w-[5em]"
:value (some-> (fc/field-value)
(clj-time.coerce/to-date-time)
[:div.flex.space-x-2.items-center
(com/validated-field {:errors (fc/field-errors)
:label "Start Date"}
[:div {:class "w-[7em]"}
(com/date-input {:name (fc/field-name)
:error? (fc/error?)
:placeholder "12/01/2023"
:hx-get (bidi/path-for ssr-routes/only-routes
::indicators/days-ago)
:hx-trigger "change"
:hx-target "#days-indicator"
:hx-vals "js:{date: event.target.value}"
:hx-swap "innerHTML"
:class "w-[5em]"
:value (some-> (fc/field-value)
(clj-time.coerce/to-date-time)
;; todo do date coercion in the input
(atime/unparse-local atime/normal-date))})]))
(atime/unparse-local atime/normal-date))})])
[:div#days-indicator
(i/days-ago* (some-> (fc/field-value))) ]])
(fc/with-field :bank-account/include-in-reports
(com/checkbox {:name (fc/field-name)