Files
integreat/src/clj/auto_ap/ssr/indicators.clj
Bryce ba87805d4c Add vendor pre-population for bulk code and individual edit forms
- Add vendor-changed HTMX handlers for both bulk code and individual edit
- Pre-populate default account at 100% when vendor is selected and no accounts exist
- Fix render-accounts-section to render from step-params correctly
- Change bulk code vendor-changed from hx-get to hx-post to include form data
- Add routes for vendor-changed endpoints
- Update e2e tests to cover vendor pre-population
- Run lein cljfmt fix across codebase
2026-05-21 14:45:19 -07:00

36 lines
1.4 KiB
Clojure

(ns auto-ap.ssr.indicators
(:require [auto-ap.routes.indicators :as route]
[auto-ap.ssr.components :as com]
[auto-ap.ssr.utils :refer [clj-date-schema html-response
wrap-schema-enforce]]
[clj-time.coerce :as c]
[clj-time.core :as t]))
(defn days-ago* [date]
(if date
(let [start (c/to-date-time date)
today (t/now)]
(if (t/before? start today)
(let [days (t/in-days (t/interval start today))]
(com/pill {:color (cond (< days 30)
:primary
(< days 60)
:secondary
(< days 90)
:yellow
:else
:red)}
(str days " days ago")))
(com/pill {:color :primary}
(str (inc (t/in-days (t/interval today start))) " days from now"))))
[:div]))
(defn days-ago [request]
(html-response (days-ago* (:date (:query-params request)))))
(def key->handler
{::route/days-ago (wrap-schema-enforce days-ago
:query-schema
[:map [:date {:optional false}
clj-date-schema]])})