moved payments to new table format.

This commit is contained in:
Bryce Covert
2020-08-08 11:54:34 -07:00
parent 32152ea924
commit 31e56a387b
2 changed files with 45 additions and 34 deletions

View File

@@ -60,30 +60,6 @@
:on-success [::received]}
:set-uri-params (dissoc params :client-id)}))
(re-frame/reg-event-fx
::void-check
(fn [{:keys [db]} [_ payment]]
{:graphql
{:token (-> db :user)
:query-obj {:venia/operation {:operation/type :mutation
:operation/name "VoidPayment"}
:venia/queries [{:query/data [:void-payment
{:payment-id (:id payment)}
[:id :status [:bank-account [:name]] :amount :check_number :s3_url :date [:vendor [:name :id]] [:client [:name :id]]
[:invoices [:invoice-id]]]]}]}
:on-success [::payment-voided]}}))
(re-frame/reg-event-db
::payment-voided
(fn [db [_ {:keys [void-payment]}]]
(-> db
(update-in [::payment-page :payments] (fn [payments]
(mapv (fn [c]
(if (= (:id c) (:id void-payment))
(assoc void-payment :class "live-removed")
c))
payments))))))
(re-frame/reg-event-db
::received
(fn [db [_ data]]
@@ -95,14 +71,28 @@
::unmounted
(fn [{:keys [db]} _]
{:db (dissoc db ::last-params ::table/table-params ::side-bar/filters ::side-bar/settled-filters ::payment-page)
::track/dispose {:id ::params} }))
::track/dispose {:id ::params}
:forward-events {:unregister ::page}}))
(re-frame/reg-event-fx
::mounted
(fn [{:keys [db]} _]
{::track/register {:id ::params
:subscription [::params]
:event-fn (fn [params] [::params-change params])}}))
:event-fn (fn [params] [::params-change params])}
:forward-events {:register ::page
:events #{::table/payment-voided}
:dispatch-to [::payment-voided]}}))
(re-frame/reg-event-db
::payment-voided
[(re-frame/path [::payment-page :payments])]
(fn [db [_ [_ {:keys [void-payment]}]]]
(mapv (fn [c]
(if (= (:id c) (:id void-payment))
(assoc void-payment :class "live-removed")
c))
db)))
(defn content []
(let [params @(re-frame/subscribe [::params])]
@@ -110,8 +100,7 @@
[:h1.title "Payments"]
[table/table {:id :payments
:payment-page @(re-frame/subscribe [::payment-page])
:status @(re-frame/subscribe [::status/single ::page])
:void-event [::void-check]}]]))
:status @(re-frame/subscribe [::status/single ::page])}]]))
(defn payments-page []
(reagent/create-class