Skip to content

Commit

Permalink
Merge pull request #427 from district0x/various-fixes-10
Browse files Browse the repository at this point in the history
More fixes & improvements
  • Loading branch information
madis authored May 21, 2024
2 parents 7d477f8 + 55d3d1e commit 59be0e8
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 23 deletions.
2 changes: 2 additions & 0 deletions server/src/ethlance/server/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@
:resolve-dispute (update-job-story-invoice-message conn
{:job-story/id job-story-id
:message/id (:message/id (<? (get-invoice-message conn job-story-id (:invoice/id message))))
:invoice/amount-paid (:invoice/amount-paid message)
:invoice/dispute-resolved-message-id msg-id
:invoice/status "dispute-resolved"})
:proposal (update-row! conn :JobStory (assoc message
Expand All @@ -522,6 +523,7 @@
{:job-story/id job-story-id
:message/id (:message/id (<? (get-invoice-message conn job-story-id (:invoice/id message))))
:invoice/payment-message-id msg-id
:invoice/amount-paid (:invoice/amount-paid message)
:invoice/status "paid"})
:feedback (insert-row! conn :JobStoryFeedbackMessage message))))

Expand Down
11 changes: 10 additions & 1 deletion server/src/ethlance/server/syncer.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,15 @@
(safe-go
(log/info "Handling event handle-invoice-paid")
(let [ipfs-data (<? (server-utils/get-ipfs-meta @ipfs/ipfs (shared-utils/hex->base58 (:ipfs-data args))))
invoice-message {:job-story/id (:job-story/id ipfs-data)
invoice-id (:invoice-id args)
job-story-id (:job-story/id ipfs-data)
invoice-message (<? (db/get conn {:select [:*]
:from [:JobStoryInvoiceMessage]
:where [:and
[:= :JobStoryInvoiceMessage.job-story/id job-story-id]
[:= :JobStoryInvoiceMessage.invoice/ref-id invoice-id]]}))
requested-value (:invoice/amount-requested invoice-message)
invoice-message {:job-story/id job-story-id
:invoice/id (or (:invoice/id ipfs-data) (:invoice-id ipfs-data))
:message/type :job-story-message
:job-story-message/type :payment
Expand All @@ -141,6 +149,7 @@
:invoice/hours-worked (:invoice/hours-worked ipfs-data)
:invoice/hourly-rate (:invoice/hourly-rate ipfs-data)
:invoice/date-paid (get-timestamp)
:invoice/amount-paid requested-value
:invoice/status "paid"}]

(<? (ethlance-db/add-message conn invoice-message)))))
Expand Down
8 changes: 4 additions & 4 deletions ui/resources/public/less/base/layout.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
Expand All @@ -44,7 +44,7 @@ div, li, p, span {
}

/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
Expand Down Expand Up @@ -84,7 +84,7 @@ a {

}

a:visited {
a:visited, a:link {
color: inherit;
}

Expand Down
34 changes: 25 additions & 9 deletions ui/src/ethlance/ui/page/job_contract.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@
(add-to-details ,,, (format-proposal-amount job-story)))
proposal-accepted (common-fields :proposal-accepted-message ["Accepted proposal"])
feedback-stars (fn [fb] [c-rating {:color :white :size :small :rating (:feedback/rating fb)}])
arbiter-feedback (map #(common-chat-fields current-user % :message ["Feedback for arbiter"
feedback-receiver (fn [fb] (str "Feedback for " (get-in fb [:feedback/to-user :user/name])))
arbiter-feedback (map #(common-chat-fields current-user % :message [feedback-receiver
feedback-stars])
(:job-story/arbiter-feedback job-story))
employer-feedback (map #(common-chat-fields current-user % :message ["Feedback for employer"
employer-feedback (map #(common-chat-fields current-user % :message [feedback-receiver
feedback-stars])
(:job-story/employer-feedback job-story))
candidate-feedback (map #(common-chat-fields current-user % :message ["Feedback for candidate"
candidate-feedback (map #(common-chat-fields current-user % :message [feedback-receiver
feedback-stars])
(:job-story/candidate-feedback job-story))
direct-messages (map #(common-chat-fields current-user % identity ["Direct message"])
Expand All @@ -145,8 +146,16 @@
(get-in job-story [:job-story/invoices :items]))
dispute-creation (map #(common-chat-fields current-user % identity ["Dispute was created"])
(map :dispute-raised-message (get-in job-story [:job-story/invoices :items])))
dispute-resolution (map #(common-chat-fields current-user % identity ["Dispute was resolved"])
(map :dispute-resolved-message (get-in job-story [:job-story/invoices :items])))]
payout-details (fn [invoice]
(str (get-in invoice [:dispute-raised-message :creator :user/name])
" received "
(token-info/token-info-str (get invoice :invoice/amount-paid) (get-in job-story [:job :token-details]))
" (out of "
(token-info/token-info-str (get invoice :invoice/amount-requested) (get-in job-story [:job :token-details]))
" invoiced)"))
dispute-resolution (map #(common-chat-fields current-user % :dispute-resolved-message ["Dispute was resolved"
payout-details])
(get-in job-story [:job-story/invoices :items]))]
(->> [dispute-creation dispute-resolution
invitation invitation-accepted
proposal proposal-accepted
Expand Down Expand Up @@ -186,12 +195,15 @@

[:job-story/arbiter-feedback [:message/id
:feedback/rating
[:feedback/to-user [:user/id :user/name]]
[:message message-fields]]]
[:job-story/employer-feedback [:message/id
:feedback/rating
[:feedback/to-user [:user/id :user/name]]
[:message message-fields]]]
[:job-story/candidate-feedback [:message/id
:feedback/rating
[:feedback/to-user [:user/id :user/name]]
[:message message-fields]]]
[:direct-messages (into message-fields [:message/creator :direct-message/recipient])]
[:job-story/invoices
Expand All @@ -210,7 +222,7 @@

messages-result (re/subscribe [::gql/query {:queries [messages-query]}
{:refetch-on #{:page.job-contract/refetch-messages}}])
graphql-data-ready? (and (not (:graphql/loading? @messages-result)) (not (:graphql/processing? @messages-result)))]
graphql-data-ready? (get-in @messages-result [:job-story :job-story/invoices])]
(when graphql-data-ready?
[c-chat-log (extract-chat-messages (:job-story @messages-result) active-user involved-users)])))

Expand Down Expand Up @@ -297,7 +309,8 @@
all-feedbacks-done? (and (empty? open-invoices)
(nil? feedback-receiver-role))

next-feedback-receiver (get participants feedback-receiver-role)]
next-feedback-receiver (get participants feedback-receiver-role)
button-disabled? (re/subscribe [:page.job-contract/buttons-disabled?])]
[:div.feedback-input-container
(when open-invoices?
[c-information "There are still unpaid invoices. Feedback can be given after they have been paid"])
Expand All @@ -323,6 +336,7 @@
:on-change #(re/dispatch [:page.job-contract/set-feedback-text %])}]

[c-button {:color :primary
:disabled? @button-disabled?
:on-click #(re/dispatch [:page.job-contract/send-feedback
{:job-story/id @job-story-id
:text @feedback-text
Expand All @@ -334,13 +348,15 @@
(defn c-direct-message
[]
(let [text (re/subscribe [:page.job-contract/message-text])
job-story-id (re/subscribe [:page.job-contract/job-story-id])]
job-story-id (re/subscribe [:page.job-contract/job-story-id])
button-disabled? (re/subscribe [:page.job-contract/buttons-disabled?])]
[:div.message-input-container
[:div.label "Message"]
[c-textarea-input {:placeholder ""
:value @text
:on-change #(re/dispatch [:page.job-contract/set-message-text %])}]
[c-button {:color :primary
:disabled? @button-disabled?
:on-click #(re/dispatch [:page.job-contract/send-message {:text @text
:job-story/id @job-story-id}])}
[c-button-label "Send Message"]]]))
Expand Down Expand Up @@ -702,7 +718,7 @@
:arbiter {:name (get-in job-story [:job :job/arbiter :user :user/name])
:address arbiter-id}}
job-participant-viewing? (not (nil? current-user-role))
graphql-data-ready? (and (not (:graphql/loading? result)) (not (:graphql/processing? result)))]
graphql-data-ready? (get-in result [:job-story :job])]
[c-main-layout {:container-opts {:class :job-contract-main-container :random (rand)}}
(if job-participant-viewing?
[:<>
Expand Down
18 changes: 17 additions & 1 deletion ui/src/ethlance/ui/page/job_contract/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,24 @@
:rating rating
:to to}]
{:fx [[:dispatch [::gql-events/mutation {:queries [[:leave-feedback mutation-params]]
:on-success [::graphql-mutation-success]
:on-error [::graphql-mutation-error]
:id :SendEmployerFeedbackMutation}]]
[:dispatch [::set-buttons-disabled true]]]}))


(re/reg-event-fx
::graphql-mutation-success
(fn [_cofx _event-v]
{:fx [[:dispatch [::set-buttons-disabled false]]
[:dispatch [:page.job-contract/refetch-messages]]
[:dispatch [:page.job-contract/clear-message-forms]]]}))

(re/reg-event-fx
::graphql-mutation-error
(fn [_cofx _event-v]
{:fx [[:dispatch [::set-buttons-disabled false]]
[:dispatch [:page.job-contract/refetch-messages]]]}))

(defn send-message
[{:keys [db]} [_event-name params]]
Expand All @@ -98,8 +112,10 @@
{:db (clear-forms db)
:fx [[:dispatch [::gql-events/mutation
{:queries [[:send-message mutation-params]]
:on-success [::graphql-mutation-success]
:on-error [::graphql-mutation-error]
:id :SendDirectMessageMutation}]]
[:dispatch [:page.job-contract/refetch-messages]]]}))
[:dispatch [::set-buttons-disabled true]]]}))


(defn accept-invitation
Expand Down
7 changes: 1 addition & 6 deletions ui/src/ethlance/ui/page/me.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@
(into [c-table {:headers (map :title headers)}]
(mapv (fn [row]
{:row-link (link-params (link-params-fn row))
:row-cells (mapv (fn [header]
(if (nil? link-params-fn)
[:span ((:source header) row)]
[:a (link-params (link-params-fn row))
[:span ((:source header) row)]]))
headers)})
:row-cells (mapv (fn [header] [:span ((:source header) row)]) headers)})
rows)))
[c-pagination-ends
{:total-count total-count
Expand Down
4 changes: 2 additions & 2 deletions ui/src/ethlance/ui/page/new_job.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
[c-text-input
{:placeholder "Name"
:value @*name
:maxlength 100
:max-length 100
:on-change #(re/dispatch [:page.new-job/set-title %])}]]
[:div.category-input
[c-select-input
Expand Down Expand Up @@ -154,7 +154,7 @@
[c-textarea-input
{:placeholder "Enter Description"
:value @*description
:maxlength 4000
:max-length 4000
:on-change #(re/dispatch [:page.new-job/set-description %])}]]

[:div.forms-of-payment.chip
Expand Down

0 comments on commit 59be0e8

Please sign in to comment.