Fetch prices on page load and refresh on headline click
Remove the Refresh Prices button. Prices are fetched automatically on page load, and clicking the headline triggers a re-fetch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -100,21 +100,15 @@
|
|||||||
(price-table title prices)]]))
|
(price-table title prices)]]))
|
||||||
|
|
||||||
(defn home [query-fn request]
|
(defn home [query-fn request]
|
||||||
|
(prices/fetch-and-save! query-fn)
|
||||||
(page {:lang "en"}
|
(page {:lang "en"}
|
||||||
[:h1 {:class "text-2xl font-bold text-gray-900"}
|
[:h1 {:class "text-2xl font-bold text-gray-900 cursor-pointer hover:text-blue-600 transition-colors"
|
||||||
|
:hx-post "/prices/fetch"
|
||||||
|
:hx-target "#price-panel"
|
||||||
|
:hx-swap "innerHTML"}
|
||||||
"Electricity Prices"]
|
"Electricity Prices"]
|
||||||
[:p {:class "mt-1 text-sm text-gray-500"}
|
[:p {:class "mt-1 text-sm text-gray-500"}
|
||||||
"Day-ahead spot prices for DK1 (øre/kWh)"]
|
"Day-ahead spot prices for DK1 (øre/kWh)"]
|
||||||
[:button {:class "mt-4 rounded-lg bg-blue-600 px-4 py-2 text-white font-medium
|
|
||||||
active:bg-blue-700 transition-colors"
|
|
||||||
:hx-post "/prices/fetch"
|
|
||||||
:hx-target "#price-panel"
|
|
||||||
:hx-swap "innerHTML"
|
|
||||||
:hx-indicator "#fetch-spinner"}
|
|
||||||
"Refresh Prices"]
|
|
||||||
[:span {:id "fetch-spinner"
|
|
||||||
:class "ml-2 htmx-indicator text-sm text-gray-400"}
|
|
||||||
"Loading..."]
|
|
||||||
[:div {:id "price-panel"}
|
[:div {:id "price-panel"}
|
||||||
(price-content :today (prices/get-today-prices query-fn))]))
|
(price-content :today (prices/get-today-prices query-fn))]))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user