tracking companies by id

This commit is contained in:
Bryce Covert
2018-04-06 07:08:17 -07:00
parent 0baf1e0e65
commit 68964e2e2c
7 changed files with 31 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
(ns auto-ap.events
(:require [re-frame.core :as re-frame]
[auto-ap.db :as db]
[auto-ap.subs :as subs]
[auto-ap.routes :as routes]
[auto-ap.effects :as effects]
[bidi.bidi :as bidi]))
@@ -48,7 +49,7 @@
(re-frame/reg-event-db
::swap-company
(fn [db [_ company]]
(assoc db :company company)))
(assoc db :company (:id company))))
(re-frame/reg-event-fx
::set-active-page
@@ -69,8 +70,8 @@
{:http {:method :post
:token (-> cofx :db :user)
:uri (str "/api/invoices/approve"
(when-let [company-name (-> cofx :db :company :name)]
(str "?company=" company-name)))
(when-let [company-id (:id @(re-frame/subscribe [::subs/company]))]
(str "?company=" company-id)))
:on-success [::received-invoices :pending]
}}))
@@ -81,8 +82,8 @@
:http {:method :get
:token (-> cofx :db :user)
:uri (str "/api/invoices/pending"
(when-let [company-name (-> cofx :db :company :name)]
(str "?company=" company-name)))
(when-let [company-id (:id @(re-frame/subscribe [::subs/company]))]
(str "?company=" company-id)))
:on-success [::received-invoices :pending]}}))
(re-frame/reg-event-fx
@@ -92,8 +93,8 @@
:http {:method :get
:token (-> cofx :db :user)
:uri (str "/api/invoices/unpaid"
(when-let [company-name (-> cofx :db :company :name)]
(str "?company=" company-name)))
(when-let [company-id (:id @(re-frame/subscribe [::subs/company]))]
(str "?company=" company-id)))
:on-success [::received-invoices :unpaid]}}))
(re-frame/reg-event-fx
@@ -102,8 +103,8 @@
{:http {:method :post
:token (-> cofx :db :user)
:uri (str "/api/invoices/reject"
(when-let [company-name (-> cofx :db :company :name)]
(str "?company=" company-name)))
(when-let [company-id (:id @(re-frame/subscribe [::subs/company]))]
(str "?company=" company-id)))
:on-success [::received-invoices :pending]
}}))
(re-frame/reg-event-db