you can void checks now.

This commit is contained in:
Bryce Covert
2018-07-25 19:35:26 -07:00
parent 581e5e8798
commit 8bb35d70c0
3 changed files with 39 additions and 2 deletions

View File

@@ -42,6 +42,30 @@
:end]]]}
:on-success [::received]}}))
(re-frame/reg-event-fx
::void-check
(fn [{:keys [db]} [_ check]]
{:graphql
{:token (-> db :user)
:query-obj {:venia/operation {:operation/type :mutation
:operation/name "VoidCheck"}
:venia/queries [{:query/data [:void-check
{:check-id (:id check)}
[:id :status :amount :check_number :s3_url :date [:vendor [:name :id]] [:company [:name :id]]]]}]}
:on-success [::check-voided]}}))
(re-frame/reg-event-db
::check-voided
(fn [db [_ {:keys [void-check]}]]
(-> db
(update-in [::check-page :checks] (fn [checks]
(mapv (fn [c]
(if (= (:id c) (:id void-check))
(assoc void-check :class "live-removed")
c))
checks)) ))))
(re-frame/reg-event-db
::received
(fn [db [_ data]]
@@ -134,6 +158,8 @@
[:td (gstring/format "$%.2f" amount )]
[:td status]
[:td
(when (= "pending" status)
[:button.button.is-warning.is-outlined {:on-click (dispatch-event [::void-check i])} [:span [:span.icon [:i.fa.fa-undo]]]])
(if s3-url
[:a.tag {:href s3-url :target "_new"} [:i.fa.fa-money-check] [:span.icon [:i.fa.fa-money]] (str " " check-number " (" (gstring/format "$%.2f" amount ) ")")]
[:span.tag [:i.fa.fa-money-check] [:span.icon [:i.fa.fa-money]] (str " " check-number " (" (gstring/format "$%.2f" amount ) ")")])