Skip to content

Commit

Permalink
let the session-card's participate/leave change using the POST -> evt…
Browse files Browse the repository at this point in the history
… -> GET
  • Loading branch information
humorless committed Aug 1, 2024
1 parent b7c6882 commit 9157df2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/co/gaiwan/compass/html/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@
([session user]
[:<>
[:button {:hx-post (str "/sessions/" (:db/id session) "/participate")
:hx-target (str "closest ." session-card)
:hx-select (str "." session-card)
:hx-swap "outerHTML"
:on-click "event.stopPropagation()"
:hx-indicator (str ".c" (:db/id session))}
(if (session/participating? session user)
Expand Down Expand Up @@ -108,7 +105,11 @@
capacity signup-count] :as session}
user]
[:<>
{:style {--session-type-color (:session.type/color type)}
{:hx-get (str "/sessions/" (:db/id session) "/card")
:hx-trigger (str "session-" (:db/id session) "-updated from:body")
:hx-target (str "closest ." session-card)
:hx-select (str "." session-card " > *")
:style {--session-type-color (:session.type/color type)}
:cx-toggle "expanded"
:cx-target (str "." session-card)}
[:div.type (:session.type/name type)]
Expand Down
10 changes: 9 additions & 1 deletion src/co/gaiwan/compass/routes/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
(db/entity session-eid)
(:identity req)]}))

(defn GET-session-card [req]
(let [session-eid (parse-long (get-in req [:path-params :id]))]
{:html/body [h/session-card
(db/entity session-eid)
(:identity req)]}))

(defn duration-string-to-iso8601
"Convert \"03:00\" to iso8601 format \"PT3H\" "
[duration-str]
Expand Down Expand Up @@ -130,4 +136,6 @@
(new-session req)
(GET-session req)))}}]
["/:id/participate"
{:post {:handler participate-session}}]])
{:post {:handler participate-session}}]
["/:id/card"
{:get {:handler GET-session-card}}]])

0 comments on commit 9157df2

Please sign in to comment.