added suggestions
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
(ns auto-ap.config)
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(def debug?
|
||||
^boolean goog.DEBUG)
|
||||
|
||||
@@ -39,15 +39,6 @@
|
||||
[k v])))
|
||||
(into {} )))))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:new-window
|
||||
(fn [url]
|
||||
(.open js/window url)))
|
||||
|
||||
#_(re-frame/reg-fx
|
||||
:dispatch-sync
|
||||
(fn [event]
|
||||
(re-frame/dispatch-sync event)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:set-local-storage
|
||||
@@ -121,47 +112,6 @@
|
||||
(conj on-success)
|
||||
(re-frame/dispatch))))))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:https
|
||||
(fn [{:keys [requests on-success on-failure owns-state]}]
|
||||
(go
|
||||
(when (:multi owns-state)
|
||||
(re-frame/dispatch-sync [::status/loading-multi (:multi owns-state) (:which owns-state)]))
|
||||
|
||||
(when (:single owns-state)
|
||||
(re-frame/dispatch-sync [::status/loading (:single owns-state)]))
|
||||
(let [results (->>
|
||||
(for [{:keys [method body headers uri token]} requests]
|
||||
(go
|
||||
(let [headers (if token
|
||||
(assoc headers "Authorization" (str "Token " token))
|
||||
headers)
|
||||
response (<! (http/request {:method method
|
||||
:body body
|
||||
:headers headers
|
||||
:url uri}))]
|
||||
(if (>= (:status response) 400)
|
||||
:error
|
||||
:success))))
|
||||
(async/merge)
|
||||
(async/reduce conj [])
|
||||
(async/<!))]
|
||||
(println "DONE")
|
||||
(if (some #{:error} results)
|
||||
(do
|
||||
(when (:multi owns-state)
|
||||
(re-frame/dispatch [::status/error-multi (:multi owns-state) (:which owns-state) results]))
|
||||
(when (:single owns-state)
|
||||
(re-frame/dispatch [::status/error (:single owns-state) results]))
|
||||
|
||||
(re-frame/dispatch on-failure))
|
||||
(do
|
||||
(when (:multi owns-state)
|
||||
(re-frame/dispatch [::status/completed-multi (:multi owns-state) (:which owns-state)]))
|
||||
(when (:single owns-state)
|
||||
(re-frame/dispatch [::status/completed (:single owns-state)]))
|
||||
(re-frame/dispatch on-success)))))))
|
||||
|
||||
(defn kebab->snake [s]
|
||||
(str/replace s #"-" "_"))
|
||||
|
||||
|
||||
@@ -76,17 +76,6 @@
|
||||
(fn [db [_ which]]
|
||||
(update-in db [:menu which :active?] #(not %))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::logged-in
|
||||
(fn [{:keys [db]} [_ token user]]
|
||||
{:graphql {:token token
|
||||
:query-obj {:venia/queries [[:client (client-query token)]]}
|
||||
|
||||
:on-success [::received-initial]
|
||||
:on-error [::failed-initial]}
|
||||
:db (assoc db
|
||||
:user (assoc user :token token)
|
||||
:is-initial-loading? true)}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::received-initial
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[re-frame.interceptor :as i]
|
||||
[auto-ap.status :as status]
|
||||
[auto-ap.views.utils :refer [dispatch-event]]
|
||||
[malli.core :as m]))
|
||||
|
||||
|
||||
@@ -20,13 +19,6 @@
|
||||
:data
|
||||
(get-in f))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::loading-class
|
||||
(fn [db [_ x]]
|
||||
(if (#{"loading" :loading} (get-in db [::forms x :status]) )
|
||||
"is-loading"
|
||||
"")))
|
||||
|
||||
(defn start-form
|
||||
([db form data]
|
||||
(start-form db form data nil))
|
||||
@@ -131,17 +123,13 @@
|
||||
(assoc-in [::forms form :error] (or (:message (first result))
|
||||
result)))))
|
||||
|
||||
|
||||
(defn ^:deprecated side-bar-form [{:keys [form]} children]
|
||||
[:div [:a.delete.is-pulled-right {:on-click (dispatch-event [::form-closing form])}] [:div children]])
|
||||
|
||||
|
||||
;; TODO ^:deprecated
|
||||
(defn loading [db id]
|
||||
(-> db
|
||||
(assoc-in [::forms id :status] :loading)
|
||||
(assoc-in [::forms id :error] nil)))
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn settles [{:keys [event time key]}]
|
||||
(i/->interceptor
|
||||
:id :settles
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns ^:figwheel-hooks auto-ap.reload)
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn ^:after-load reload []
|
||||
(println "RELOADING")
|
||||
(@(resolve 'auto-ap.core/mount-root)))
|
||||
|
||||
@@ -13,14 +13,6 @@
|
||||
(def not-empty-string (m/schema [:re {:error/message "Required"} #"\S+"]))
|
||||
(def code-string (m/schema [:re #"[A-Z0-9\-]+"]))
|
||||
|
||||
(def positive-integer (m/schema [:int {:min 1}]))
|
||||
(def integer-code (m/schema [:int {:min 10000 :max 99999}]))
|
||||
|
||||
(def expense-account (m/schema [:map
|
||||
[:id :string]
|
||||
[:account reference]
|
||||
[:location :string]
|
||||
[:amount money]]))
|
||||
|
||||
|
||||
(def approval-status (m/schema [:enum :unapproved :requires-feedback :approved :excluded]))
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
[minisearch :as ms]))
|
||||
(set! *warn-on-infer* true)
|
||||
|
||||
#_{:clj-kondo/ignore [:unresolved-symbol]}
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var :unresolved-symbol]}
|
||||
(def MiniSearch (if ms (aget ms "default")
|
||||
nil))
|
||||
|
||||
@@ -29,15 +29,6 @@
|
||||
(fn [c]
|
||||
(map #(select-keys % [:id :name]) c)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::all-accounts
|
||||
(fn [db]
|
||||
(:accounts db)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::all-accounts-by-id
|
||||
(fn [db]
|
||||
(by :id (:accounts db))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::bank-accounts
|
||||
@@ -101,10 +92,6 @@
|
||||
(fn [db [_ id]]
|
||||
(-> db :menu (get id) :active?)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::menu
|
||||
(fn [db]
|
||||
(:menu db)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::is-initial-loading?
|
||||
@@ -175,8 +162,3 @@
|
||||
(if (= 500 (:status error))
|
||||
"System error occured. If you are stuck, please notify ben@integreatconsult.com."
|
||||
(:message error)))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::yodlee-merchants
|
||||
(fn [db]
|
||||
(:yodlee-merchants db)))
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
[auto-ap.views.utils
|
||||
:refer [dispatch-event str->int with-is-admin? with-user]]
|
||||
[malli.core :as m]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as r]))
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
;; Remaining cleanup todos:
|
||||
;; test minification
|
||||
@@ -131,11 +130,6 @@
|
||||
{:dispatch-n [[::forms/attempted-submit ::vendor-form]
|
||||
[::status/error ::vendor-form [{:message "Please fix the errors and try again."}]]]})))
|
||||
|
||||
(defn pull-left []
|
||||
(into [:div {:style {:position "relative"
|
||||
:left "-40px"}}]
|
||||
(r/children (r/current-component))))
|
||||
|
||||
(defn contact-field [{:keys [name field]}]
|
||||
[form-builder/with-scope {:scope field}
|
||||
[form-builder/vertical-control
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
(fn [db]
|
||||
(::users db)))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::params-change
|
||||
(fn [_ [_ params]]
|
||||
{:set-uri-params params}))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::page
|
||||
:<- [::params]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
(ns auto-ap.views.pages.admin.vendors.table
|
||||
(:require
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.buttons :as buttons]
|
||||
[auto-ap.views.components.grid :as grid]
|
||||
[auto-ap.views.components.vendor-dialog :as vendor-dialog]
|
||||
@@ -9,10 +8,7 @@
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
(defn vendors-table [{:keys [data-page]}]
|
||||
(let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])
|
||||
accounts @(re-frame/subscribe [::subs/all-accounts-by-id])]
|
||||
(println "DATA COUNT" (keys data))
|
||||
|
||||
(let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])]
|
||||
[grid/grid {:data-page data-page
|
||||
:column-count 4}
|
||||
[grid/controls data]
|
||||
@@ -33,7 +29,7 @@
|
||||
[:div.mx-2.tag.is-info.is-light total-usage " usages, " (count (:usage v)) " clients" ]
|
||||
[:div.mx-2.tag.is-warning.is-light "Unused"]))]
|
||||
[grid/cell {} (:email (:primary-contact v))]
|
||||
[grid/cell {} (-> v :default-account :id accounts :name)]
|
||||
[grid/cell {} (-> v :default-account :name)]
|
||||
[grid/cell {}
|
||||
[buttons/fa-icon {:event [::vendor-dialog/started v]
|
||||
:icon "fa-pencil"}]]])]]]))
|
||||
|
||||
@@ -30,12 +30,6 @@
|
||||
(fn [table-params]
|
||||
table-params))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::plaid-items
|
||||
(fn [db]
|
||||
(::plaid-items db)))
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::data-requested
|
||||
(fn [{:keys [db]} [_ params]]
|
||||
@@ -119,11 +113,6 @@
|
||||
(-> db
|
||||
(assoc-in [::link-token] (:token (:plaid-link-token link-token))))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::received
|
||||
(fn [db [_ d]]
|
||||
(assoc-in db [::plaid-items] (:plaid-item-page d))))
|
||||
|
||||
|
||||
(defn plaid-item-table []
|
||||
[table/table {:data-page ::page
|
||||
|
||||
@@ -127,9 +127,6 @@
|
||||
:filters filters
|
||||
:table-params table-params}))
|
||||
|
||||
(defn in-page-entities [which]
|
||||
(re-frame/path [::data which :data ] ))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::table-params-changed
|
||||
(fn [{:keys [db]} [_ which params]]
|
||||
|
||||
@@ -151,16 +151,6 @@
|
||||
[]]]}
|
||||
:on-success [::invalidated]}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::approve-invoices
|
||||
(fn [cofx [_ on-success]]
|
||||
{:http {:method :post
|
||||
:token (-> cofx :db :user)
|
||||
:uri (str "/api/invoices/approve"
|
||||
(when-let [client-id (:id @(re-frame/subscribe [::subs/client]))]
|
||||
(str "?client=" client-id)))
|
||||
:on-success on-success}}))
|
||||
|
||||
(defn approve-reject-button [checked]
|
||||
[:div.buttons
|
||||
[:button.button.is-primary {:on-click (dispatch-event [::approve-invoices-clicked checked])
|
||||
|
||||
@@ -18,16 +18,8 @@
|
||||
[auto-ap.events :as events]
|
||||
[vimsical.re-frame.cofx.inject :as inject]
|
||||
[auto-ap.forms.builder :as form-builder]
|
||||
[malli.core :as m]
|
||||
[auto-ap.schema :as schema]
|
||||
[auto-ap.views.components :as com]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::can-submit
|
||||
:<- [::forms/form ::form]
|
||||
(fn [{ {:keys []} :data}]
|
||||
true))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::coded
|
||||
(fn [_ [_ _ _]]
|
||||
@@ -107,15 +99,10 @@
|
||||
{::track/dispose {:id ::vendor-change}}))
|
||||
|
||||
|
||||
(def bulk-update-schema
|
||||
(m/schema
|
||||
[:map
|
||||
[:vendor schema/reference]]))
|
||||
(defn form-content [_]
|
||||
(let [{:keys [data]} @(re-frame/subscribe [::forms/form ::form])]
|
||||
[form-builder/builder {:submit-event [::code-selected]
|
||||
:change-event [::changed]
|
||||
:can-submit [::can-submit]
|
||||
:id ::form}
|
||||
|
||||
|
||||
|
||||
@@ -10,12 +10,6 @@
|
||||
[malli.core :as m]
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::can-submit
|
||||
:<- [::forms/form ::form]
|
||||
(fn [{ {:keys [data]} :data}]
|
||||
(not-empty data)))
|
||||
|
||||
(def schema
|
||||
(m/schema [:map [:data schema/not-empty-string]]))
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
|
||||
(def date-regex #"[2]{1}[0-9]{3}-[0-9]{1,2}-[0-9]{1,2}")
|
||||
(def money-regex #"\-?[0-9]+(\.[0-9]{2})?$")
|
||||
|
||||
(def nff
|
||||
(NumberFormat. Format/CURRENCY))
|
||||
@@ -54,9 +53,6 @@
|
||||
|
||||
))
|
||||
|
||||
(defn active-when= [active-page candidate]
|
||||
(when (= active-page candidate) " is-active"))
|
||||
|
||||
(defn active-when [active-page f & rest]
|
||||
|
||||
(when (apply f (into [active-page] rest)) " is-active"))
|
||||
@@ -72,12 +68,6 @@
|
||||
(re-frame/dispatch (conj event (.. e -target -value)))))
|
||||
|
||||
|
||||
(defn delayed-dispatch [e]
|
||||
(fn [_]
|
||||
(js/setTimeout #(re-frame/dispatch e) 151)
|
||||
false))
|
||||
|
||||
|
||||
(defn dispatch-event [event]
|
||||
(fn [e]
|
||||
(when (.-stopPropagation e)
|
||||
@@ -286,9 +276,6 @@
|
||||
(js/document.execCommand "copy")
|
||||
(.removeChild js/document.body el)))
|
||||
|
||||
(defn account->match-text [x]
|
||||
(str (:numeric-code x) " - " (:name x)))
|
||||
|
||||
(defn str->int [x]
|
||||
(cond
|
||||
(nil? x)
|
||||
|
||||
Reference in New Issue
Block a user