Skip to content

Commit

Permalink
joseph account filter
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Sep 8, 2023
1 parent 09efbfe commit d0cbd7e
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions app/demo/src/demo/goldly/page/joseph.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
(into #{})
(into [])))

(defn accounts [trades]
(->> trades
(map :account)
(into #{})
(into [])))

(defn on-click [args]
(let [args-clj (js->clj args)
data (get args-clj "data")
Expand Down Expand Up @@ -73,17 +79,30 @@
:pagination :false
:paginationAutoPageSize true}])

(defn filter-trades [trades symbol]
(if (= symbol "*")
(defn filter-symbol [trades symbol]
(if (or (nil? symbol) (= symbol "*"))
trades
(filter #(= symbol (:symbol %)) trades)))

(defn filter-account [trades account]
(if (or (nil? account) (= account "*"))
trades
(filter #(= account (:account %)) trades)))

(defn filter-trades [trades symbol account]
(-> trades
(filter-account account)
(filter-symbol symbol)))

(defn trade-ui [_trades]
(let [state-internal (r/atom {:symbol "*"})]
(let [state-internal (r/atom {:symbol "*"
:account "*"})]
(fn [trades]
(let [active-symbols (symbols trades)
active-symbols (concat ["*"] active-symbols)
trades-filtered (filter-trades trades (:symbol @state-internal))
active-accounts (accounts trades)
active-accounts (concat ["*"] active-accounts)
trades-filtered (filter-trades trades (:symbol @state-internal) (:account @state-internal))
]
[:div.flex.flex-col.w-full.h-full
[:div
Expand All @@ -94,9 +113,12 @@
:max-width "4cm"}}
[input/select {:nav? false
:items active-symbols}
state-internal [:symbol]]
]

state-internal [:symbol]]]
[:div {:style {:width "4cm"
:max-width "4cm"}}
[input/select {:nav? false
:items active-accounts}
state-internal [:account]]]
]

[trade-table trades-filtered]
Expand Down

0 comments on commit d0cbd7e

Please sign in to comment.