Updates for users.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
::initialize-db
|
||||
(fn [{:keys [db]} [_ token]]
|
||||
(let [handler (:handler (bidi/match-route routes/routes (.. js/window -location -pathname)))]
|
||||
(prn (and token (jwt->data token)))
|
||||
(prn (and token (get (jwt->data token) "user/role")))
|
||||
(cond
|
||||
(and (not= :login handler) (not token))
|
||||
{:redirect "/login"
|
||||
@@ -26,7 +26,7 @@
|
||||
:active-page :login
|
||||
:user token)}
|
||||
|
||||
(and token (= "none" (get (jwt->data token) "role") ))
|
||||
(and token (= "none" (or (get (jwt->data token) "role") (get (jwt->data token) "user/role")) ))
|
||||
{:redirect "/needs-activation"
|
||||
:db (assoc db/default-db
|
||||
:active-page :needs-activation
|
||||
@@ -77,7 +77,8 @@
|
||||
(fn [db [_ {clients :client vendors :vendor :as x}]]
|
||||
(-> db
|
||||
(assoc :clients (by :id clients) )
|
||||
(assoc :vendors (by :id vendors) ))))
|
||||
(assoc :vendors (by :id vendors) )
|
||||
(assoc :client (when (= 1 (count clients)) (->> clients first :id ))))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::swap-client
|
||||
|
||||
@@ -52,23 +52,24 @@
|
||||
[:span]
|
||||
[:span]]
|
||||
[:div.navbar-end
|
||||
[:div { :class (str "navbar-item has-dropdown " (when (get-in @menu [:client :active?]) "is-active"))}
|
||||
[:a {:class "navbar-link login" :on-click (fn [] (re-frame/dispatch [::events/toggle-menu :client]))} "Client: " (if @client (:name @client)
|
||||
"All")]
|
||||
[:div {:class "navbar-dropdown"}
|
||||
[:a {:class "navbar-item"
|
||||
:on-click (fn []
|
||||
(re-frame/dispatch [::events/toggle-menu :client])
|
||||
(re-frame/dispatch [::events/swap-client nil]))
|
||||
} "All"]
|
||||
[:hr {:class "navbar-divider"}]
|
||||
(for [{:keys [name id] :as client} @clients]
|
||||
^{:key id }
|
||||
(when (> (count @clients) 1)
|
||||
[:div { :class (str "navbar-item has-dropdown " (when (get-in @menu [:client :active?]) "is-active"))}
|
||||
[:a {:class "navbar-link login" :on-click (fn [] (re-frame/dispatch [::events/toggle-menu :client]))} "Client: " (if @client (:name @client)
|
||||
"All")]
|
||||
[:div {:class "navbar-dropdown"}
|
||||
[:a {:class "navbar-item"
|
||||
:on-click (fn []
|
||||
(re-frame/dispatch [::events/toggle-menu :client])
|
||||
(re-frame/dispatch [::events/swap-client client]))
|
||||
} name])]]]]
|
||||
(re-frame/dispatch [::events/swap-client nil]))
|
||||
} "All"]
|
||||
[:hr {:class "navbar-divider"}]
|
||||
(for [{:keys [name id] :as client} @clients]
|
||||
^{:key id }
|
||||
[:a {:class "navbar-item"
|
||||
:on-click (fn []
|
||||
(re-frame/dispatch [::events/toggle-menu :client])
|
||||
(re-frame/dispatch [::events/swap-client client]))
|
||||
} name])]])]]
|
||||
[login-dropdown]]]))
|
||||
|
||||
(defn footer []
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
[auto-ap.views.pages.unpaid-invoices :refer [unpaid-invoices-page]]
|
||||
[auto-ap.views.pages.import-invoices :refer [import-invoices-page]]
|
||||
[auto-ap.views.pages.paid-invoices :refer [paid-invoices-page]]
|
||||
[auto-ap.views.pages.needs-activation :refer [needs-activation-page]]
|
||||
[auto-ap.views.pages.transactions :refer [transactions-page]]
|
||||
[auto-ap.views.pages.login :refer [login-page]]
|
||||
[auto-ap.views.pages.checks :refer [checks-page]]
|
||||
@@ -66,6 +67,10 @@
|
||||
(defmethod page :login [_]
|
||||
[login-page])
|
||||
|
||||
(defmethod page :needs-activation [_]
|
||||
[needs-activation-page])
|
||||
|
||||
|
||||
(defmethod page :admin-excel-import [_]
|
||||
[admin-excel-import-page])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user