Quality of life improvements with client login
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
::initialize-db
|
||||
(fn [{:keys [db]} [_ token]]
|
||||
(let [handler (:handler (bidi/match-route routes/routes (.. js/window -location -pathname)))]
|
||||
(prn (and token (get (jwt->data token) "user/role")))
|
||||
(cond
|
||||
(and (not= :login handler) (not token))
|
||||
{:redirect "/login"
|
||||
@@ -38,6 +37,7 @@
|
||||
:else
|
||||
{:db (assoc db/default-db
|
||||
:active-page handler
|
||||
:is-initial-loading? true
|
||||
:last-client-id (.getItem js/localStorage "last-client-id")
|
||||
:query-params (auto-ap.views.utils/query-params)
|
||||
:user token)
|
||||
@@ -84,7 +84,9 @@
|
||||
[:accounts [:numeric-code :name :location :type :account_set :applicability :id [:client-overrides [:name [:client [:name :id]]]]]]]}
|
||||
|
||||
:on-success [::received-initial]}
|
||||
:db (assoc db :user (assoc user :token token))}))
|
||||
:db (assoc db
|
||||
:user (assoc user :token token)
|
||||
:is-initial-loading? true)}))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::received-initial
|
||||
@@ -93,6 +95,7 @@
|
||||
(-> db
|
||||
(assoc :clients (by :id clients) )
|
||||
(assoc :vendors (by :id vendors) )
|
||||
(assoc :is-initial-loading? false)
|
||||
(assoc :accounts accounts )
|
||||
(assoc :client (or (when (= 1 (count clients)) (->> clients first :id ))
|
||||
(->> clients
|
||||
|
||||
Reference in New Issue
Block a user