Skip to content

Commit

Permalink
Integration with Menu's item - Profile & Settings
Browse files Browse the repository at this point in the history
partial result of profile form
  • Loading branch information
humorless committed Aug 6, 2024
1 parent 0b80d4b commit 637f7fa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/co/gaiwan/compass/html/navigation.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@
[:p "Welcome, " name]
[:a {:href "/logout"} "Sign out"]]
[:a {:href (oauth/flow-init-url)} "Sign-in with Discord"])]
(when user
[:li [:a {:href (str "/profiles/" (:db/id user))} "My Profile"]])
[:li [:a {:href "/"} "Sessions & Activities"]]
[:li [a-auth {:href "/attendees"} "Attendees"]]
[:li [a-auth {:href "/profile"} "Profile & Settings"]]
[:li [a-auth {:href (str "/profiles")
:user user} "Profile & Settings"]]
[:li [a-auth {:href "/sessions/new"
:user user} "Create Activity"]]]]))

Expand Down
5 changes: 2 additions & 3 deletions src/co/gaiwan/compass/html/profiles.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@
(o/defstyled profile-detail :div
[image-frame :w-100px]
([{:discord/keys [access-token id refresh-token expires-at]
:user/keys [email handle name uuid image] :as profile}
user]
:user/keys [email handle name uuid image] :as user}]
[:<>
[image-frame {:profile/image
(if image
(str "url(" image ")")
(str "var(--gradient-" (inc (rand-int 7)) ")"))} user]
[:div.details
(pr-str profile)]]))
(pr-str user)]]))
23 changes: 16 additions & 7 deletions src/co/gaiwan/compass/routes/profiles.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@
[java-time.api :as time]))

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

(defn GET-profile-form [req]
{:html/body [h/profile-detail
(:identity req)]})

(defn save-profile [req]
{:html/body [h/profile-detail
(:identity req)]})

(defn routes []
["/profiles"
["/:id"
{:get {:handler (fn [req]
(GET-profile req))}}]])
[""
{:get {:handler GET-profile}}]
["/edit"
{:get {:handler GET-profile-form}}]
["/save"
{:post {:handler save-profile}}]])

0 comments on commit 637f7fa

Please sign in to comment.