Skip to content
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

Allow pay invoice for employer only #444

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions server/src/ethlance/server/syncer/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
:decimals 18}]
(when (not (<? (ethlance-db/get-token conn token-address)))
(if (= :eth token-type)
(ethlance-db/store-token-details conn eth-token-details)
(ethlance-db/store-token-details conn (<! (token-utils/get-token-details token-type token-address))))))))
(<! (ethlance-db/store-token-details conn eth-token-details))
(<! (ethlance-db/store-token-details conn (<! (token-utils/get-token-details token-type token-address)))))))))

(defn handle-job-created
[conn _ {:keys [args] :as event}]
Expand Down Expand Up @@ -291,7 +291,7 @@
{:job-funding/amount (movement-sign-fn (:token-amount tv))
:token-detail/id (:token-address tv)}))
funds-map)]
(doseq [[token-type token-address] tokens-info] (ensure-db-token-details token-type token-address conn))
(doseq [[token-type token-address] tokens-info] (<! (ensure-db-token-details token-type token-address conn)))
(doseq [funding funding-updates]
(<? (ethlance-db/insert-row! conn :JobFunding funding :ignore-conflict-on [:tx]))))))

Expand Down
6 changes: 0 additions & 6 deletions ui/resources/public/less/component/button.less
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@
&.disabled {
#mixin.box-shadow.none();
opacity: 0.7;
color: #color[purple];
background-color: rgba(0,0,0,0.0);

> .button-label {
color: #color[purple];
}

&:hover {
color: white;
Expand Down
6 changes: 4 additions & 2 deletions ui/src/ethlance/ui/component/select_input.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"Component has both controlled `selection` and uncontrolled `default-selection` attributes set.")
(let [value-fn (or value-fn identity)
label-fn (or label-fn identity)
current-selection (if (contains? opts :default-selection) @*current-default-selection selection)
opts (dissoc opts
:label :selections
:on-select :default-selection
Expand All @@ -75,8 +76,9 @@
:default-search-text
:size
:value-fn
:label-fn)
current-selection (if (contains? opts :default-selection) @*current-default-selection selection)]
:label-fn)]
(when (nil? @*current-default-selection)
(reset! *current-default-selection (or default-selection selection)))
[:div.ethlance-select-input (merge {:class [color-class size-class]} opts)
[:div.main
{:title (or (label-fn current-selection) label)
Expand Down
17 changes: 11 additions & 6 deletions ui/src/ethlance/ui/page/invoices.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[clojure.string]
[district.ui.component.page :refer [page]]
[district.ui.graphql.subs :as gql]
[ethlance.shared.utils :refer [ilike=]]
[ethlance.ui.component.icon :refer [c-icon]]
[ethlance.ui.component.main-layout :refer [c-main-layout]]
[ethlance.ui.component.profile-image :refer [c-profile-image]]
Expand Down Expand Up @@ -90,6 +91,9 @@
:payer (:user/id employer)
:receiver (:user/id candidate)}

employer-id (get-in job [:job/employer :user/id])
current-user-id (:user/id @(re/subscribe [:ethlance.ui.subscriptions/active-session]))
viewed-by-employer? (ilike= current-user-id employer-id)
invoice-payable? (not= "paid" (get invoice :invoice/status))
info-panel [["Invoiced Amount" (when-not (:graphql/loading? result)
[c-token-info (:invoice/amount-requested invoice)
Expand All @@ -112,9 +116,10 @@
[:div.ethlance-table
[:table (into [:tbody] (map (fn [[label content]] [:tr [:th label] [:td content]]) info-panel))]]]

(if invoice-payable?
[:div.button {:on-click #(re/dispatch [:page.invoices/pay invoice-to-pay])}
[:span "Pay Invoice"]
[c-icon {:name :ic-arrow-right :size :small :color :white}]]
[:div.button {:style {:background-color :gray}}
[:span "Invoice Paid"]])])))
(when viewed-by-employer?
(if invoice-payable?
[:div.button {:on-click #(re/dispatch [:page.invoices/pay invoice-to-pay])}
[:span "Pay Invoice"]
[c-icon {:name :ic-arrow-right :size :small :color :white}]]
[:div.button {:style {:background-color :gray}}
[:span "Invoice Paid"]]))])))
5 changes: 4 additions & 1 deletion ui/src/ethlance/ui/page/job_detail.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@
candidate-role? (and
(get-in result [:user :user/is-registered-candidate])
(not (ilike= active-user *employer-address))
(not (some #(ilike= active-user (:user/id %)) (get-in result [:job :arbitrations :items]))))]
(not (some #(ilike= active-user (:user/id %)) (get-in result [:job :arbitrations :items]))))
proposal-ready? (and (< 0 (get @*proposal-token-amount :token-amount))
(not (empty? @*proposal-text)))]
[:div.proposal-listing
[:div.label "Proposals"]
[c-scrollable
Expand Down Expand Up @@ -193,6 +195,7 @@
[c-button-label "Remove"]])
(when (not my-proposal?)
[c-button {:style (when (not can-send-proposals?) {:background :gray})
:disabled? (not proposal-ready?)
:on-click (fn []
(when can-send-proposals?
(>evt [:page.job-proposal/send contract-address *job-token-type])))
Expand Down
2 changes: 1 addition & 1 deletion ui/src/ethlance/ui/page/sign_up.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
:error? (not (:candidate/rate form-validation))
:on-change #(>evt [:page.sign-up/set-candidate-rate (js/parseInt %)])}]]
[c-user-country-input
{:form-values form-values}]]
{:form-values (select-keys form-values [:user/country])}]]
[:div.second-forms
[c-user-languages-input
{:form-values form-values}]
Expand Down
Loading