deleted file.
This commit is contained in:
@@ -1,121 +0,0 @@
|
|||||||
(ns auto-ap.views.pages.checks
|
|
||||||
(:require [re-frame.core :as re-frame]
|
|
||||||
[auto-ap.entities.clients :as client]
|
|
||||||
[auto-ap.entities.vendors :as vendor]
|
|
||||||
[auto-ap.entities.invoice :as invoice]
|
|
||||||
[reagent.core :as reagent]
|
|
||||||
[goog.string :as gstring]
|
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[auto-ap.views.components.sorter :refer [sorted-column]]
|
|
||||||
[auto-ap.views.components.date-range-filter :refer [date-range-filter]]
|
|
||||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
|
||||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
|
||||||
[auto-ap.views.components.paginator :refer [paginator]]
|
|
||||||
[auto-ap.views.components.sort-by-list :refer [sort-by-list]]
|
|
||||||
[auto-ap.events :as events]
|
|
||||||
[auto-ap.views.utils :refer [dispatch-event date->str bind-field nf with-user]]
|
|
||||||
[auto-ap.utils :refer [by]]
|
|
||||||
[auto-ap.views.pages.payments.side-bar :as side-bar]
|
|
||||||
[auto-ap.views.pages.payments.table :as table]
|
|
||||||
[auto-ap.views.pages.check :as check]
|
|
||||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
|
||||||
[auto-ap.subs :as subs]))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
|
||||||
::payment-page
|
|
||||||
(fn [db]
|
|
||||||
(-> db ::payment-page)))
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
|
||||||
::params
|
|
||||||
:<- [::subs/client]
|
|
||||||
:<- [::side-bar/filter-params]
|
|
||||||
:<- [::table/table-params]
|
|
||||||
(fn [[client filter-params table-params]]
|
|
||||||
(cond-> {}
|
|
||||||
client (assoc :client-id (:id client))
|
|
||||||
(seq filter-params) (merge filter-params)
|
|
||||||
(seq table-params) (merge @(re-frame/subscribe [::table/table-params])))))
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
|
||||||
::params-change
|
|
||||||
[with-user]
|
|
||||||
(fn [{:keys [user db]}[_ ]]
|
|
||||||
(let [new-params @(re-frame/subscribe [::params])]
|
|
||||||
(when (not= (::last-params db) new-params)
|
|
||||||
{:db (-> db
|
|
||||||
(assoc-in [:status :loading] true)
|
|
||||||
(assoc-in [::last-params] new-params))
|
|
||||||
:graphql {:token user
|
|
||||||
:query-obj {:venia/queries [[:payment_page
|
|
||||||
@(re-frame/subscribe [::params])
|
|
||||||
[[:payments [:id :status :amount :type :check_number :s3_url
|
|
||||||
[:bank-account [:name]]
|
|
||||||
:date [:vendor [:name :id]] [:client [:name :id]]]]
|
|
||||||
:total
|
|
||||||
:start
|
|
||||||
:end]]]}
|
|
||||||
:on-success [::received]
|
|
||||||
:on-error [::events/page-failed]}}))))
|
|
||||||
|
|
||||||
(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]]]]}]}
|
|
||||||
: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]]
|
|
||||||
(-> db
|
|
||||||
(update ::payment-page merge (first (:payment-page data)))
|
|
||||||
(assoc-in [:status :loading] false))))
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
|
||||||
::unmounted
|
|
||||||
(fn [{:keys [db]} _]
|
|
||||||
(println "HERE")
|
|
||||||
{:db (dissoc db ::last-params ::table/table-params ::side-bar/filters ::payment-page)}))
|
|
||||||
|
|
||||||
(defn content []
|
|
||||||
(with-meta
|
|
||||||
(fn []
|
|
||||||
(let [current-client @(re-frame/subscribe [::subs/client])]
|
|
||||||
[:div
|
|
||||||
[:h1.title "Payments"]
|
|
||||||
[table/table {:id :payments
|
|
||||||
:payment-page (re-frame/subscribe [::payment-page])
|
|
||||||
:status (re-frame/subscribe [::subs/status])
|
|
||||||
:void-event [::void-check]}]]))
|
|
||||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {}]) }))
|
|
||||||
|
|
||||||
|
|
||||||
(defn payments-page []
|
|
||||||
(reagent/create-class
|
|
||||||
{:display-name "payments-page"
|
|
||||||
:component-did-mount #(re-frame/dispatch [::params-change {}])
|
|
||||||
:component-will-unmount #(re-frame/dispatch [::unmounted])
|
|
||||||
:reagent-render
|
|
||||||
(fn []
|
|
||||||
[side-bar-layout {:side-bar [side-bar/side-bar]
|
|
||||||
:main [content]}])}))
|
|
||||||
Reference in New Issue
Block a user