Skip to content

Commit

Permalink
Disable feedback until last invoice gets paid
Browse files Browse the repository at this point in the history
  • Loading branch information
madis committed Jan 16, 2025
1 parent c41a7e7 commit 5bb23f4
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions ui/src/ethlance/ui/page/job_contract.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -408,18 +408,39 @@

(defn c-employer-options
[message-params]
[c-tabular-layout
{:key "employer-tabular-layout"
:default-tab 1}
(let [*active-page-params (re/subscribe [::router.subs/active-page-params])
job-story-id (-> @*active-page-params :job-story-id parse-int)

invoice-query [:job-story {:job-story/id job-story-id}
[[:job-story/invoices
[:total-count
[:items
[:id
:job/id
:job-story/id
:invoice/status
:invoice/id
:invoice/date-paid
:invoice/amount-requested
:invoice/amount-paid]]]]]]
invoice-result (re/subscribe [::gql/query {:queries [invoice-query]} {:refetch-on #{:page.job-contract/refetch-messages}}])
invoices (get-in @invoice-result [:job-story :job-story/invoices :items])
all-paid? (and (< 0 (count invoices))
(every? (fn [invoice] (= (get invoice :invoice/status) "paid")) invoices))]
[c-tabular-layout
{:key "employer-tabular-layout"
:default-tab 1}

{:label "Send Message"}
[c-direct-message]
{:label "Send Message"}
[c-direct-message]

{:label "Accept Proposal"}
[c-accept-proposal-message message-params]
{:label "Accept Proposal"}
[c-accept-proposal-message message-params]

{:label "Leave Feedback"}
[c-feedback-panel :employer]])
{:label "Leave Feedback"}
(if all-paid?
[c-feedback-panel :employer]
[c-information "Feedback can be sent after last invoice has been paid"])]))


(defn c-candidate-options
Expand Down Expand Up @@ -468,10 +489,13 @@
(not (nil? invitation-message))
(nil? invitation-accepted-message))
invoices (get-in @invoice-result [:job-story :job-story/invoices :items])
all-paid? (and (< 0 (count invoices))
(every? (fn [invoice] (= (get invoice :invoice/status) "paid")) invoices))
latest-unpaid-invoice (->> invoices
(filter #(= "created" (:invoice/status %)) ,,,)
(sort-by #(get-in % [:creation-message :message/date-created]) > ,,,)
first)

token-symbol (get-in @invoice-result [:job-story :job :token-details :token-detail/symbol])
token-type (keyword (get-in @invoice-result [:job-story :job :job/token-type]))
decimals (get-in @invoice-result [:job-story :job :token-details :token-detail/decimals])
Expand Down Expand Up @@ -535,7 +559,9 @@
[c-information dispute-unavailable-message])

{:label "Leave Feedback"}
[c-feedback-panel :candidate]]))
(if all-paid?
[c-feedback-panel :candidate]
[c-information "Feedback can be sent after last invoice has been paid"])]))


(defn c-arbiter-options
Expand Down

0 comments on commit 5bb23f4

Please sign in to comment.