basic partition by company.

This commit is contained in:
Bryce Covert
2017-12-12 12:40:07 -08:00
parent 198c1a39a3
commit 5b8d25bf8f
6 changed files with 112 additions and 51 deletions

View File

@@ -11,6 +11,16 @@
(assoc db/default-db
:active-page (:handler (bidi/match-route routes/routes (.. js/window -location -pathname))))))
(re-frame/reg-event-db
::toggle-company-menu
(fn [db [_ active-page]]
(update-in db [:menu :active?] #(not %))))
(re-frame/reg-event-db
::swap-company
(fn [db [_ company]]
(assoc db :company company)))
(re-frame/reg-event-db
::set-active-page
(fn [db [_ active-page]]
@@ -25,7 +35,9 @@
::approve-invoices
(fn [cofx [_]]
{:http {:method :post
:uri "/api/invoices/approve"
:uri (str "/api/invoices/approve"
(when-let [company-name (-> cofx :db :company :name)]
(str "?company=" company-name)))
:on-success [::received-invoices :pending]
}}))
@@ -34,7 +46,9 @@
(fn [cofx []]
{:db (assoc-in (:db cofx) [:status :loading] true)
:http {:method :get
:uri "/api/invoices/pending"
:uri (str "/api/invoices/pending"
(when-let [company-name (-> cofx :db :company :name)]
(str "?company=" company-name)))
:on-success [::received-invoices :pending]}}))
(re-frame/reg-event-fx
@@ -42,14 +56,18 @@
(fn [cofx []]
{:db (assoc-in (:db cofx) [:status :loading] true)
:http {:method :get
:uri "/api/invoices/unpaid"
:uri (str "/api/invoices/unpaid"
(when-let [company-name (-> cofx :db :company :name)]
(str "?company=" company-name)))
:on-success [::received-invoices :unpaid]}}))
(re-frame/reg-event-fx
::reject-invoices
(fn [cofx [_]]
{:http {:method :post
:uri "/api/invoices/reject"
:uri (str "/api/invoices/reject"
(when-let [company-name (-> cofx :db :company :name)]
(str "?company=" company-name)))
:on-success [::received-invoices :pending]
}}))
(re-frame/reg-event-db