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

@@ -13,7 +13,8 @@
[goog.string :as gstring]
[re-frame.core :as re-frame]
[auto-ap.views.components.grid :as grid]
[auto-ap.views.components.buttons :as buttons]))
[auto-ap.views.components.buttons :as buttons]
[auto-ap.status :as status]))
(re-frame/reg-sub
::specific-table-params
@@ -33,9 +34,29 @@
(fn [{table-params :db} [_ params :as z]]
{:db (merge table-params params)}))
(re-frame/reg-event-fx
::void-check
(fn [{:keys [db]} [_ payment]]
{:graphql
{:token (-> db :user)
:owns-state {:multi ::void
:which (:id payment)}
: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))
(defn row [{check :check
selected-client :selected-client
void-event :void-event
states :states
}]
(let [{:keys [client s3-url bank-account payments type check-number date amount id vendor status invoices] :as check} check]
[grid/row {:class (:class check)}
@@ -77,11 +98,12 @@
(when (or (= :pending status)
(and (#{":cash" :cash ":debit" :debit} type)
(not= :voided status)))
[buttons/sl-icon {:event (conj void-event check) :icon :icon-bin-2}])]]]))
[buttons/sl-icon {:event [::void-check check] :icon :icon-bin-2
:class (status/class-for (get states (:id check)))}])]]]))
(defn table [{:keys [id payment-page status void-event]}]
(defn table [{:keys [id payment-page status]}]
(let [selected-client @(re-frame/subscribe [::subs/client])
percentage-size (if selected-client "50%" "33%")]
states @(re-frame/subscribe [::status/multi ::void])]
[grid/grid {:on-params-change (fn [e]
(re-frame/dispatch [::params-changed e]))
:params @(re-frame/subscribe [::table-params])
@@ -105,4 +127,4 @@
^{:key (:id check)}
[row {:check check
:selected-client selected-client
:void-event void-event}])]]]))
:states states}])]]]))