Show date on Today/Tomorrow tabs and remove table headings

Tabs now display the date (e.g. "Today 2026-02-14"). Removed redundant
"Today — DK1" / "Tomorrow — DK1" headings from the price tables.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 14:10:25 +01:00
co-authored by Claude Opus 4.6
parent 4ef693168c
commit 99780ebf60
+23 -21
View File
@@ -9,10 +9,12 @@
[reitit.ring.middleware.muuntaja :as muuntaja]
[reitit.ring.middleware.parameters :as parameters])
(:import
[java.time LocalDateTime]
[java.time LocalDateTime ZoneId]
[java.time.format DateTimeFormatter]))
(def ^:private dk-zone (ZoneId/of "Europe/Copenhagen"))
(def ^:private hour-fmt (DateTimeFormatter/ofPattern "HH:00"))
(def ^:private date-fmt (DateTimeFormatter/ofPattern "yyyy-MM-dd"))
(defn- ->ldt [time-dk]
(cond
@@ -60,9 +62,8 @@
[:span (format "%02d:%02d" hour (.getMinute (->ldt (:time_dk q))))]
[:span {:class "font-mono"} (format-ore (:price_dkk q))]])]]))
(defn- price-table [title prices]
[:div {:class "mt-6"}
[:h2 {:class "text-lg font-semibold text-gray-900 mb-2"} title]
(defn- price-table [prices]
[:div
(if (seq prices)
[:div
(for [[hour quarters] (group-by-hour prices)]
@@ -79,25 +80,26 @@
(str tab-base "border-gray-200 bg-gray-100 text-gray-500 hover:text-gray-700 cursor-pointer"))
(defn- tabs [active-tab]
[:div {:class "flex gap-1 mt-4"}
[:button {:class (if (= active-tab :today) tab-active tab-inactive)
:hx-get "/prices/today"
:hx-target "#price-panel"
:hx-swap "innerHTML"}
"Today"]
[:button {:class (if (= active-tab :tomorrow) tab-active tab-inactive)
:hx-get "/prices/tomorrow"
:hx-target "#price-panel"
:hx-swap "innerHTML"}
"Tomorrow"]])
(let [today (java.time.LocalDate/now dk-zone)
tomorrow (.plusDays today 1)]
[:div {:class "flex gap-1 mt-4"}
[:button {:class (if (= active-tab :today) tab-active tab-inactive)
:hx-get "/prices/today"
:hx-target "#price-panel"
:hx-swap "innerHTML"}
(str "Today " (.format today date-fmt))]
[:button {:class (if (= active-tab :tomorrow) tab-active tab-inactive)
:hx-get "/prices/tomorrow"
:hx-target "#price-panel"
:hx-swap "innerHTML"}
(str "Tomorrow " (.format tomorrow date-fmt))]]))
(defn- price-content [tab prices]
(let [title (if (= tab :today) "Today — DK1" "Tomorrow — DK1")]
[:div
(tabs tab)
[:div {:id "price-content"
:class "border-2 border-blue-400 rounded-b-lg rounded-tr-lg p-4 bg-white"}
(price-table title prices)]]))
[:div
(tabs tab)
[:div {:id "price-content"
:class "border-2 border-blue-400 rounded-b-lg rounded-tr-lg p-4 bg-white"}
(price-table prices)]])
(defn home [query-fn request]
(prices/fetch-and-save! query-fn)