adds the ability to export vendors.
This commit is contained in:
@@ -30,7 +30,8 @@
|
||||
[auto-ap.views.pages.admin.users :refer [admin-users-page]]
|
||||
[auto-ap.views.pages.admin.import-batches :refer [import-batches-page]]
|
||||
[auto-ap.views.pages.company.yodlee2 :as yodlee2]
|
||||
[auto-ap.views.pages.company.plaid :as plaid]))
|
||||
[auto-ap.views.pages.company.plaid :as plaid]
|
||||
[auto-ap.views.pages.company.other :as company-other]))
|
||||
|
||||
(defmulti page (fn [active-page] active-page))
|
||||
(defmethod page :unpaid-invoices [_]
|
||||
@@ -121,6 +122,9 @@
|
||||
(defmethod page :yodlee2 [_]
|
||||
(yodlee2/admin-yodlee-provider-accounts-page))
|
||||
|
||||
(defmethod page :company-other [_]
|
||||
(company-other/company-other-page))
|
||||
|
||||
(defmethod page :plaid [_]
|
||||
(plaid/plaid-page))
|
||||
|
||||
|
||||
76
src/cljs/auto_ap/views/pages/company/other.cljs
Normal file
76
src/cljs/auto_ap/views/pages/company/other.cljs
Normal file
@@ -0,0 +1,76 @@
|
||||
(ns auto-ap.views.pages.company.other
|
||||
(:require
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.utils :refer [dispatch-event with-user]]
|
||||
[auto-ap.views.components.buttons :refer [fa-icon]]
|
||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||
[auto-ap.views.pages.company.side-bar :refer [company-side-bar]]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[vimsical.re-frame.cofx.inject :as inject]
|
||||
[auto-ap.status :as status]))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::ready
|
||||
(fn [{:keys [db] } [_ result]]
|
||||
{:db (assoc db ::export-result result)}))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::export-result
|
||||
(fn [db]
|
||||
(::export-result db)))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::export-vendors
|
||||
[(re-frame/inject-cofx ::inject/sub [::subs/client]) with-user]
|
||||
(fn [{:keys [db user] ::subs/keys [client]}]
|
||||
{:http {:token user
|
||||
:method :get
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/vendors/company/export?client=" (:code client))
|
||||
:owns-state {:single ::export-vendors}
|
||||
:on-success [::ready]}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::unmounted
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (dissoc db ::export-result)}))
|
||||
|
||||
(defn company-other-content []
|
||||
(let [client @(re-frame/subscribe [::subs/client])
|
||||
state @(re-frame/subscribe [::status/single ::export-vendors])
|
||||
export-result @(re-frame/subscribe [::export-result])]
|
||||
(if client
|
||||
[:div
|
||||
[:h1.title "Other"]
|
||||
[status/status-notification [::status/single ::export-vendors]]
|
||||
|
||||
|
||||
[fa-icon {:icon "fa-external-link"
|
||||
:class (into (status/class-for state) ["is-primary" ])
|
||||
:disabled (status/disabled-for state)
|
||||
:event [::export-vendors]
|
||||
}
|
||||
[:div
|
||||
(str " Export " (:name client) " Vendors")
|
||||
]]
|
||||
(when export-result
|
||||
[:<>
|
||||
[:div
|
||||
"Ready! Click "
|
||||
[:a {:href (str "data:attachment/csv;charset=utf-8," (js/encodeURI export-result))
|
||||
:target "_blank"
|
||||
:download (str "vendors-" (:code client) ".csv")}
|
||||
"here"]
|
||||
" to download"]])
|
||||
]
|
||||
[:div "Please select a company."])))
|
||||
|
||||
|
||||
(defn company-other-page []
|
||||
(reagent/create-class
|
||||
{:reagent-render (fn []
|
||||
[side-bar-layout {:side-bar [company-side-bar {}]
|
||||
:main [company-other-content]}])
|
||||
:component-will-unmount #(re-frame/dispatch [::unmounted])}))
|
||||
|
||||
@@ -22,4 +22,8 @@
|
||||
[:li.menu-item
|
||||
[:a {:href (bidi/path-for routes/routes :yodlee2), :class (str "item" (active-when ap = :yodlee2))}
|
||||
[:span {:class "icon icon-saving-bank-1" :style {:font-size "25px"}}]
|
||||
[:span {:class "name"} "Yodlee Link"]]]]))
|
||||
[:span {:class "name"} "Yodlee Link"]]]
|
||||
[:li.menu-item
|
||||
[:a {:href (bidi/path-for routes/routes :company-other), :class (str "item" (active-when ap = :company-other))}
|
||||
[:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}]
|
||||
[:span {:class "name"} "Other"]]]]))
|
||||
|
||||
Reference in New Issue
Block a user