Minor cleanup tweaks
This commit is contained in:
@@ -99,7 +99,7 @@
|
||||
client-word-match (->> clients
|
||||
(map
|
||||
(fn [{:keys [:db/id :client/matches :client/name] :as client :or {matches []}}]
|
||||
(let [client-words (-> #{}
|
||||
(let [client-words (-> #{}
|
||||
(into
|
||||
(mapcat
|
||||
(fn [match] (str/split (.toLowerCase match) #"\s" ))
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
(ns auto-ap.routes.yodlee2
|
||||
(:require
|
||||
[auto-ap.graphql :as graphql]
|
||||
[clj-http.client :as http]
|
||||
|
||||
[auto-ap.yodlee.core2 :as yodlee]
|
||||
[auto-ap.graphql.utils :refer [->graphql assert-admin]]
|
||||
[auto-ap.routes.utils :refer [wrap-secure]]
|
||||
[clj-time.coerce :refer [to-date]]
|
||||
[ring.middleware.json :refer [wrap-json-response]]
|
||||
[compojure.core :refer [GET POST context defroutes wrap-routes]]
|
||||
[clojure.string :as str]
|
||||
[config.core :refer [env]]
|
||||
|
||||
[clojure.tools.logging :as log]
|
||||
[auto-ap.datomic.clients :as d-clients]))
|
||||
|
||||
(defroutes routes
|
||||
(wrap-routes
|
||||
(context "/yodlee2" []
|
||||
(GET "/fastlink" {:keys [query-params identity] :as request}
|
||||
(assert-admin identity)
|
||||
(let [token (yodlee/get-access-token (get query-params "client"))]
|
||||
{:status 200
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:body (pr-str {:token token
|
||||
:url (:yodlee2-fastlink env)}) }))
|
||||
(GET "/accounts" {:keys [query-params identity] :as request}
|
||||
(assert-admin identity)
|
||||
(let [[session token] (yodlee/get-access-token)]
|
||||
{:status 200
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:body (pr-str (yodlee/get-accounts)) }))
|
||||
|
||||
(POST "/reauthenticate/:id" {:keys [query-params identity] {:keys [id]} :route-params
|
||||
data :edn-params
|
||||
:as request}
|
||||
(assert-admin identity)
|
||||
(try
|
||||
(let [[session token] (yodlee/get-access-token)]
|
||||
{:status 200
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:body (pr-str (yodlee/reauthenticate (Long/parseLong id) data)) })
|
||||
(catch Exception e
|
||||
(log/error e)
|
||||
{:status 500
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:body (pr-str {:message (.getMessage e)
|
||||
:error (.toString e)})})))
|
||||
(POST "/provider-accounts/refresh/" {:keys [query-params identity edn-params]
|
||||
{:keys [id]} :route-params
|
||||
:as request}
|
||||
(assert-admin identity)
|
||||
(log/info "refreshing " edn-params)
|
||||
(try
|
||||
(yodlee/refresh-provider-account (-> (:client-id edn-params)
|
||||
Long/parseLong
|
||||
d-clients/get-by-id
|
||||
:client/code)
|
||||
(:provider-account-id edn-params))
|
||||
{:status 200
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:body "{}" }
|
||||
(catch Exception e
|
||||
(log/error e)
|
||||
{:status 400
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:body (pr-str {:message (.getMessage e)
|
||||
:error (.toString e)})})))
|
||||
(POST "/provider-accounts/delete/" {:keys [query-params edn-params identity] {:keys [id]} :route-params :as request}
|
||||
(assert-admin identity)
|
||||
(try
|
||||
(yodlee/delete-provider-account (-> (:client-id edn-params)
|
||||
Long/parseLong
|
||||
d-clients/get-by-id
|
||||
:client/code)
|
||||
(:provider-account-id edn-params))
|
||||
{:status 200
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:body (pr-str {}) }
|
||||
(catch Exception e
|
||||
(log/error e)
|
||||
{:status 400
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:body (pr-str {:message (.getMessage e)
|
||||
:error (.toString e)})})))
|
||||
(POST "/provider-accounts/:id" {:keys [query-params identity] {:keys [id]} :route-params :as request}
|
||||
(assert-admin identity)
|
||||
(try
|
||||
(let [[session token] (yodlee/get-access-token)]
|
||||
{:status 200
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:body (pr-str (yodlee/update-yodlee (Long/parseLong id))) })
|
||||
(catch Exception e
|
||||
{:status 400
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:body (pr-str e)}))))
|
||||
wrap-secure))
|
||||
@@ -1,12 +1,11 @@
|
||||
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||
(ns auto-ap.core
|
||||
(:require [reagent.core :as reagent]
|
||||
[reagent.dom :as rdom]
|
||||
[re-frame.core :as re-frame]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.views.main :refer [page active-page] ]
|
||||
[auto-ap.views.main :refer [active-page] ]
|
||||
[auto-ap.reload :as reload]
|
||||
[auto-ap.events :as events]
|
||||
|
||||
[auto-ap.config :as config]
|
||||
[auto-ap.effects :as effects]
|
||||
[pushy.core :as pushy]
|
||||
@@ -32,8 +31,7 @@
|
||||
(do
|
||||
(.setItem js/localStorage "jwt" jwt)
|
||||
(re-frame/dispatch-sync [::events/initialize-db jwt]))
|
||||
(do
|
||||
(re-frame/dispatch-sync [::events/initialize-db (.getItem js/localStorage "jwt")])))
|
||||
(re-frame/dispatch-sync [::events/initialize-db (.getItem js/localStorage "jwt")]))
|
||||
(pushy/start! p/history)
|
||||
(mount-root))
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||
(ns auto-ap.subs
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.utils :refer [by]]
|
||||
@@ -6,6 +7,7 @@
|
||||
[minisearch :as ms]))
|
||||
(set! *warn-on-infer* true)
|
||||
|
||||
#_{:clj-kondo/ignore [:unresolved-symbol]}
|
||||
(def MiniSearch (if ms (aget ms "default")
|
||||
nil))
|
||||
|
||||
@@ -211,7 +213,7 @@
|
||||
all-vendors
|
||||
|
||||
client
|
||||
(filter (fn [{:keys [hidden usage name] :as vendor}]
|
||||
(filter (fn [{:keys [hidden usage]}]
|
||||
(or (not hidden)
|
||||
(-> (first (filter #(= (:client-id %)
|
||||
(:id client))
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
[clojure.string :as str]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as r]
|
||||
[react-signature-canvas :as canvas]))
|
||||
[react-signature-canvas]))
|
||||
|
||||
(def signature-canvas (r/adapt-react-class (.-default canvas)))
|
||||
(def signature-canvas (r/adapt-react-class (.-default react-signature-canvas)))
|
||||
|
||||
(defn upload-replacement-button [{:keys [on-change]} text]
|
||||
(let [button (atom nil)]
|
||||
|
||||
@@ -2,21 +2,17 @@
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[reagent.dom :as rdom]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.entities.clients :as client]
|
||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||
[auto-ap.views.components.invoices.side-bar :refer [invoices-side-bar]]
|
||||
[auto-ap.views.utils :refer [dispatch-event bind-field with-user]]
|
||||
[auto-ap.views.utils :refer [dispatch-event with-user]]
|
||||
[auto-ap.utils :refer [by]]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.views.components.typeahead :refer [typeahead-v3]]
|
||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
||||
[cljs.reader :as edn]
|
||||
[clojure.string :as str]
|
||||
[vimsical.re-frame.cofx.inject :as inject]
|
||||
[auto-ap.status :as status]
|
||||
[vimsical.re-frame.fx.track :as track]
|
||||
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||
[dropzone :as dz]
|
||||
[auto-ap.views.pages.data-page :as data-page]
|
||||
[clojure.set :as set]
|
||||
@@ -37,7 +33,7 @@
|
||||
(fn []
|
||||
(re-frame/dispatch [::status/completed ::import])))
|
||||
|
||||
(.on t "success" (fn [_ files]
|
||||
(.on t "success" (fn [_ _]
|
||||
(re-frame/dispatch [::invalidated])))
|
||||
(.on t "error" (fn [_ error]
|
||||
(re-frame/dispatch [::status/error ::import [(edn/read-string error)]])))))
|
||||
@@ -49,7 +45,6 @@
|
||||
:previewsContainer "#dz-hidden"
|
||||
:previewTemplate "<div class='dz-hidden-preview'></div>"})))
|
||||
:reagent-render (fn []
|
||||
{:key batch}
|
||||
[:form.dz {:action "/api/invoices/upload"}
|
||||
[:div.field.has-addons
|
||||
[:p.control
|
||||
@@ -87,14 +82,14 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::invalidated
|
||||
(fn [{:keys [db]} [_ params]]
|
||||
(fn [{:keys [db]} _]
|
||||
{:dispatch-n [[::params-change @(re-frame/subscribe [::data-page/params :import-invoices])]
|
||||
[::data-page/reset-checked :import-invoices]]
|
||||
:db (update db ::batch inc)}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::mounted
|
||||
(fn [cofx [_ params]]
|
||||
(fn [_ _]
|
||||
{::track/register [{:id ::params
|
||||
:subscription [::data-page/params :import-invoices]
|
||||
:event-fn (fn [params]
|
||||
@@ -107,7 +102,7 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::unmounted
|
||||
(fn [cofx [_ params]]
|
||||
(fn [_ _]
|
||||
{::track/dispose {:id ::params}
|
||||
:dispatch [::data-page/dispose :import-invoices]}))
|
||||
|
||||
@@ -132,7 +127,7 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::reject-invoices-clicked
|
||||
(fn [{:keys [db]} [_ invoices on-success]]
|
||||
(fn [{:keys [db]} [_ invoices]]
|
||||
{:graphql
|
||||
{:token (-> db :user)
|
||||
:owns-state {:single ::reject}
|
||||
@@ -145,7 +140,7 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::approve-invoices-clicked
|
||||
(fn [{:keys [db]} [_ invoices on-success]]
|
||||
(fn [{:keys [db]} [_ invoices]]
|
||||
{:graphql
|
||||
{:token (-> db :user)
|
||||
:owns-state {:single ::approve}
|
||||
@@ -173,20 +168,18 @@
|
||||
:disabled (or (not (boolean (seq checked)))
|
||||
(status/disabled-for @(re-frame/subscribe [::status/single ::approve])))}
|
||||
"Approve "
|
||||
(when (> (count checked ))
|
||||
(str
|
||||
(count checked)
|
||||
" invoices"))
|
||||
(str
|
||||
(count checked)
|
||||
" invoices")
|
||||
[:span " "]]
|
||||
[:button.button.is-warning {:on-click (dispatch-event [::reject-invoices-clicked checked])
|
||||
:class (status/class-for @(re-frame/subscribe [::status/single ::reject]))
|
||||
:disabled (or (not (boolean (seq checked)))
|
||||
(status/disabled-for @(re-frame/subscribe [::status/single ::reject])))}
|
||||
"Reject "
|
||||
(when (> (count checked ))
|
||||
(str
|
||||
(count checked)
|
||||
" invoices"))
|
||||
(str
|
||||
(count checked)
|
||||
" invoices")
|
||||
[:span " "]]])
|
||||
|
||||
(def import-invoices-content
|
||||
|
||||
Reference in New Issue
Block a user