added ability to link yodlee directly in.
This commit is contained in:
74
src/cljs/auto_ap/views/pages/admin/yodlee.cljs
Normal file
74
src/cljs/auto_ap/views/pages/admin/yodlee.cljs
Normal file
@@ -0,0 +1,74 @@
|
||||
(ns auto-ap.views.pages.admin.yodlee
|
||||
(:require-macros [cljs.core.async.macros :refer [go]])
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events.admin.companies :as events]
|
||||
[auto-ap.entities.companies :as entity]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-event dispatch-value-change bind-field horizontal-field]]
|
||||
[auto-ap.views.components.modal :refer [action-modal]]
|
||||
[cljs.reader :as edn]
|
||||
[auto-ap.routes :as routes]
|
||||
[bidi.bidi :as bidi]))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::authenticate-with-yodlee
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (assoc-in db [::yodlee :loading?] true)
|
||||
:http {:token (:user db)
|
||||
:method :get
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/yodlee/fastlink")
|
||||
:on-success [::authenticated]
|
||||
:on-error [::save-error]}}))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::authentication
|
||||
(fn [db]
|
||||
(-> db ::yodlee :authentication)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::loading?
|
||||
(fn [db]
|
||||
(-> db ::yodlee :loading?)))
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::authenticated
|
||||
(fn [{:keys [db]} [_ authentication]]
|
||||
{:db (-> db
|
||||
(assoc-in [::yodlee :authentication] authentication)
|
||||
(assoc-in [::yodlee :loading?] false))}))
|
||||
|
||||
|
||||
|
||||
(defn admin-yodlee-page []
|
||||
[:div
|
||||
(let [authentication @(re-frame/subscribe [::authentication])
|
||||
loading? @(re-frame/subscribe [::loading?])]
|
||||
|
||||
[:div
|
||||
[:h1.title "Yodlee"]
|
||||
(if authentication
|
||||
[:div
|
||||
"Authentication successful!"
|
||||
[:form {:action (:url authentication) :method "POST"}
|
||||
[:input {:type "hidden"
|
||||
:name "rsession"
|
||||
:value (:session authentication)}]
|
||||
[:input {:type "hidden"
|
||||
:name "token"
|
||||
:value (:token authentication)}]
|
||||
[:input {:type "hidden"
|
||||
:name "app"
|
||||
:value (:app authentication)}]
|
||||
|
||||
[:input {:type "hidden"
|
||||
:name "redirectReq"
|
||||
:value "true"}]
|
||||
[:button.button.is-primary [:span [:span.icon [:i.fa.fa-external-link]] " Go to yodlee"]]]]
|
||||
|
||||
[:button.button.is-primary {:class (if loading? "is-loading" "") :on-click (dispatch-event [::authenticate-with-yodlee])} "Authenticate with Yodlee"])
|
||||
|
||||
])])
|
||||
Reference in New Issue
Block a user