Skip to content

organize prizes page a bit nicer #8176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/cljs/nr/prizes.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,23 @@

(defn assign-card-backs []
[:section
[:h4 "Card Backs"]
[:h3 "Card Backs"]
[:p "These are card backs that the player can select in the settings menu. Players can opt to see the card backs other players use, only the ones they select, or only ffg/nsg backs for their opponents."]
[:br]
(doall
(for [[k {:keys [name description]}] (card-backs/just-prizes)]
^{:key k}
[:div
[:label [:input {:type "checkbox"
:checked (get-in @selected-user [:prizes :card-backs k] false)
:on-change #(swap! selected-user assoc-in [:prizes :card-backs k] (.. % -target -checked))}]
(str name " - " description)]]))])
(let [backs (card-backs/just-prizes)]
(doall
(for [group (->> backs vals (map :group) distinct sort)]
^{:key group}
[:section
[:h3 group]
(doall
(for [[k {:keys [description side file] :as prize}] (into {} (filter (fn [[_ v]] (= (:group v) group)) backs))]
^{:key k}
[:div
[:label [:input {:type "checkbox"
:checked (get-in @selected-user [:prizes :card-backs k] false)
:on-change #(swap! selected-user assoc-in [:prizes :card-backs k] (.. % -target -checked))}]
(str (:name prize) " - " description)]]))])))])

(defn- load-user-fn [username]
(ws/ws-send! [:prizes/load-user {:username username}]))
Expand Down
Loading