More reliability with company dropdown

This commit is contained in:
Bryce
2024-04-10 09:30:33 -07:00
parent 162d24c470
commit 8da7eaaf46
6 changed files with 21 additions and 30 deletions

View File

@@ -18,7 +18,8 @@
[venia.core :as v]))
(defn maybe-add-x-clients [headers]
(if (mc/validate client-selection-schema (:selected-clients @re-frame.db/app-db))
(if (and (mc/validate client-selection-schema (:selected-clients @re-frame.db/app-db))
(not (get headers "x-clients")))
(assoc headers "x-clients" (.stringify js/JSON (clj->js (:selected-clients @re-frame.db/app-db))))
headers))

View File

@@ -64,10 +64,10 @@
(.getItem js/localStorage)
not-empty
(.parse js/JSON)
js->clj)
js->clj
( #(mc/decode client-selection-schema % client-selection-transformer)))
(catch js/Error e
:all))
last-selected-clients (mc/decode client-selection-schema last-selected-clients client-selection-transformer)
jwt-data (some-> token jwt->data)
selected-client-assignment (cond (and token
(= "admin" (get jwt-data "user/role"))
@@ -208,7 +208,6 @@
[with-user]
(fn [{:keys [db user]} [_ client]]
(let [client-identifier (or (:id client) client)]
{:http {:token user
:method :put
:uri (str (bidi/path-for ssr-routes/only-routes
@@ -216,6 +215,14 @@
:request-method :put)
"?"
(url/map->query {:search-client client-identifier}))
:headers {"x-clients"
(.stringify js/JSON
(clj->js (cond (= :all client-identifier)
"all"
(= :mine client-identifier)
"mine"
:else
{:selected [client-identifier]})))}
:on-success [::swapped-client client client-identifier]}})))
(re-frame/reg-event-fx

View File

@@ -21,6 +21,6 @@
[:img {:src "/img/logo-big.png"}]
[:div
[:a.button.is-large.is-primary {:href (doto (login-url (get (:query (url/url (.-location js/window))) "redirect-to")) println)} "Login with Google"]]]
[:a.button.is-large.is-primary {:href (login-url (get (:query (url/url (.-location js/window))) "redirect-to"))} "Login with Google"]]]
[:p.has-text-gray
"Copyright Integreat 2018"]]]]]])