you can change statuses in bulk!

This commit is contained in:
Bryce Covert
2020-12-11 17:47:51 -08:00
parent e2ae7a6d4f
commit 9ee9855169
3 changed files with 26 additions and 19 deletions

View File

@@ -60,8 +60,8 @@
[::data-page/received ::page (:result result)])}}))
(re-frame/reg-event-fx
::unapprove-selected
(fn [cofx [_ params]]
::bulk-change-transaction-status
(fn [cofx [_ status params]]
(let [checked @(re-frame/subscribe [::data-page/checked ::page])
checked-params (get checked "header")
specific-transactions (map :id (vals (dissoc checked "header")))]
@@ -69,18 +69,18 @@
{:db (-> (:db cofx)
(assoc-in [:status :loading] true))
:graphql {:token (-> cofx :db :user)
:owns-state {:single ::unapprove-selected}
:owns-state {:single ::bulk-change-transaction-status}
:query-obj
{:venia/operation {:operation/type :mutation
:operation/name "UnapproveTransactions"}
:operation/name "BulkChangeTransactionStatus"}
:venia/queries [{:query/data
[:unapprove-transactions
[:bulk-change-transaction-status
{:filters (some-> checked-params data-params->query-params)
:status status
:ids specific-transactions}
[:message]]}]}
:on-success (fn [result]
[::params-change params]
#_[::data-page/received ::page (:result result)])}})))
[::params-change params])}})))
(re-frame/reg-event-fx
::delete-selected
@@ -136,7 +136,7 @@
checked @(re-frame/subscribe [::data-page/checked ::page])]
[:div
[:h1.title "Transactions"]
[status/status-notification {:statuses [[::status/single ::unapprove-selected]
[status/status-notification {:statuses [[::status/single ::bulk-change-transaction-status]
[::status/single ::delete-selected]
[::status/single ::manual-import]]}]
(when is-admin?
@@ -154,11 +154,16 @@
checked))
[:button.button.is-outlined.is-primary {:on-click (dispatch-event [::manual/opening])}
"Manual Yodlee Import"]
[:button.button.is-warning {:on-click (dispatch-event [::unapprove-selected params])
:class (status/class-for @(re-frame/subscribe [::status/single ::unapprove-selected]))
:disabled (or (status/disabled-for @(re-frame/subscribe [::status/single ::unapprove-selected]))
[:button.button.is-warning {:on-click (dispatch-event [::bulk-change-transaction-status :unapproved params])
:class (status/class-for @(re-frame/subscribe [::status/single ::bulk-change-transaction-status]))
:disabled (or (status/disabled-for @(re-frame/subscribe [::status/single ::bulk-change-transaction-status]))
(not (seq checked)))}
"Unapprove selected"]
[:button.button.is-warning {:on-click (dispatch-event [::bulk-change-transaction-status :requires-feedback params])
:class (status/class-for @(re-frame/subscribe [::status/single ::bulk-change-transaction-status]))
:disabled (or (status/disabled-for @(re-frame/subscribe [::status/single ::bulk-change-transaction-status]))
(not (seq checked)))}
"Client Review"]
[:button.button.is-danger {:on-click (dispatch-event [::delete-selected params])
:class (status/class-for @(re-frame/subscribe [::status/single ::delete-selected]))
:disabled (or (status/disabled-for @(re-frame/subscribe [::status/single ::delete-selected]))