Skip to content

Commit

Permalink
Merge pull request #403 from district0x/various-fixes-6
Browse files Browse the repository at this point in the history
More fixes
  • Loading branch information
madis authored Apr 29, 2024
2 parents c5a9a86 + c2f0f35 commit e55e0ad
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 44 deletions.
31 changes: 17 additions & 14 deletions ui/src/ethlance/ui/component/table.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
:row-cells [[:span \"First cell\" \"Second cell\" etc]]}
]
"
[{:keys [headers]} & rows]
[{:keys [headers empty-message] :or {empty-message "No data yet to show"}} & rows]
[:div.ethlance-table
[:table
[:tbody
Expand All @@ -50,18 +50,21 @@
(for [[i header] (map-indexed vector headers)]
^{:key (str "header-" i)}
[:th header]))]
(doall
(for [[i row] (map-indexed vector rows)]
(if (map? row)
(if (empty? rows)
[:tr
[:td {:style {:text-align "center"} :col-span (count headers)} empty-message]]
(doall
(for [[i row] (map-indexed vector rows)]
(if (map? row)

^{:key (str "row-" i)}
[:tr.clickable (:row-link row)
(for [[i elem] (map-indexed vector (:row-cells row))]
^{:key (str "elem-" i)}
[:td elem])]
^{:key (str "row-" i)}
[:tr.clickable (:row-link row)
(for [[i elem] (map-indexed vector (:row-cells row))]
^{:key (str "elem-" i)}
[:td elem])]

^{:key (str "row-" i)}
[:tr
(for [[i elem] (map-indexed vector row)]
^{:key (str "elem-" i)}
[:td elem])])))]]])
^{:key (str "row-" i)}
[:tr
(for [[i elem] (map-indexed vector row)]
^{:key (str "elem-" i)}
[:td elem])]))))]]])
2 changes: 1 addition & 1 deletion ui/src/ethlance/ui/component/token_amount_input.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"Returns original value if the val is zero expressing string (e.g. 0 or 0.0)
When it becomes non-zero (e.g. 0.01) then returns the result (transform-fn val)"
[val transform-fn]
(if (non-zero-fraction? val)
(if (non-zero-fraction? (str val))
(transform-fn val)
val))

Expand Down
2 changes: 1 addition & 1 deletion ui/src/ethlance/ui/component/token_info.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
(clojure.string/upper-case (name (or token-type ""))))
address (:token-detail/id token-detail)
short-address (str (subs address 0 5) "...")
token-link-parts (if show-address?
token-link-parts (if (and show-address? (not (= :eth token-type)))
[display-type short-address]
[display-type])]
[:div (str display-amount " " token-symbol)
Expand Down
15 changes: 13 additions & 2 deletions ui/src/ethlance/ui/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:require
[akiroz.re-frame.storage]
[day8.re-frame.forward-events-fx]
[district.ui.web3-accounts.events]
[district.ui.web3-accounts.events :as accounts-events]
[ethlance.ui.page.arbiters.events]
[ethlance.ui.page.candidates.events]
[ethlance.ui.page.home.events]
Expand All @@ -19,6 +19,16 @@
[re-frame.core :as re]))


(re/reg-event-fx
::accounts-changed
(fn [_cofx [_event-name [new-active-account]]]
{:fx [[:dispatch [::accounts-events/set-active-account new-active-account]]]}))

(re/reg-event-fx
::listen-account-changes
(fn [_cofx _event]
{:fx [[:district.ui.web3-accounts.effects/watch-accounts {:on-change [::accounts-changed]}]]}))

(re/reg-event-fx
:ethlance/initialize
[(re/inject-cofx :store)]
Expand All @@ -40,4 +50,5 @@
[:page.job-detail/initialize-page]
[:page.new-job/initialize-page]
[:page.invoices/initialize-page]
[:page.new-invoice/initialize-page]]})))
[:page.new-invoice/initialize-page]]
:dispatch-later [{:ms 1000 :dispatch [::listen-account-changes]}]})))
8 changes: 4 additions & 4 deletions ui/src/ethlance/ui/page/job_detail.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,13 @@
arbiter-fields]]]
search-result @(re/subscribe [::gql/query {:queries [arbiters-query job-query]}
{:refetch-on #{:page.job-detail/arbitrations-updated}}])

employer-address (get-in search-result [:job :job/employer-address])
all-arbiters (get-in search-result [:arbiter-search :items])
not-employer (fn [arbiter] (ilike!= employer-address (get-in arbiter [:user :user/id])))
arbiters-without-current-employer (filter not-employer all-arbiters)
already-added (map #(get % :arbiter) (get-in search-result [:job :arbitrations :items]))
uninvited-arbiters (clojure.set/difference (set all-arbiters) (set already-added))
uninvited-arbiters (clojure.set/difference (set arbiters-without-current-employer) (set already-added))

employer-address (get-in search-result [:job :job/employer-address])
nothing-added? (empty? @selected-arbiters)
arbiter-info-fn (fn [arbiter]
(clojure.string/join
Expand Down Expand Up @@ -327,7 +328,6 @@
invited? (= "invited" (:arbitration/status arbitration-by-current-user))
job-address (get arbitration-by-current-user :job/id)
active-user (get-in arbitration-by-current-user [:arbiter :user/id])]
(println ">>> c-set-arbiter-quote token-amount" @token-amount)
(if invited?
[:div.proposal-form
[:div.label "Set quote to be arbiter"]
Expand Down
45 changes: 23 additions & 22 deletions ui/src/ethlance/ui/page/profile.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -179,28 +179,29 @@
invitation-text (re/subscribe [:page.profile/invitation-text])
preselected-job (or @job-for-invitation (first jobs))
job-story-exists? (:job-story-exists? preselected-job)]
[:div.job-listing
[:div.title "Invite to a job"]
[c-select-input
{:selections jobs
:value-fn :job/id
:label-fn #(str (:job/title %) (:comment %))
:selection preselected-job
:on-select #(re/dispatch [:page.profile/set-job-for-invitation %])}]
[c-textarea-input {:value @invitation-text
:disabled job-story-exists?
:placeholder "Briefly describe to what and why you're inviting the candidate"
:on-change #(re/dispatch [:page.profile/set-invitation-text %])}]
[c-button {:color :primary
:disabled? job-story-exists?
:on-click (fn []
(when-not job-story-exists?
(re/dispatch [:page.profile/invite-candidate
{:candidate candidate-address
:text @invitation-text
:job preselected-job
:employer active-user}])))}
[c-button-label "Invite"]]]))
(when (seq jobs)
[:div.job-listing
[:div.title "Invite to a job"]
[c-select-input
{:selections jobs
:value-fn :job/id
:label-fn #(str (:job/title %) (:comment %))
:selection preselected-job
:on-select #(re/dispatch [:page.profile/set-job-for-invitation %])}]
[c-textarea-input {:value @invitation-text
:disabled job-story-exists?
:placeholder "Briefly describe to what and why you're inviting the candidate"
:on-change #(re/dispatch [:page.profile/set-invitation-text %])}]
[c-button {:color :primary
:disabled? job-story-exists?
:on-click (fn []
(when-not job-story-exists?
(re/dispatch [:page.profile/invite-candidate
{:candidate candidate-address
:text @invitation-text
:job preselected-job
:employer active-user}])))}
[c-button-label "Invite"]]])))


(defn c-rating-box
Expand Down

0 comments on commit e55e0ad

Please sign in to comment.