tons of bug fixes
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
[reagent.core :as reagent]
|
||||
[clojure.string :as str]
|
||||
[cljs-time.format :as f]
|
||||
[cljs-time.core :as time]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events.admin.clients :as events]
|
||||
[auto-ap.entities.clients :as entity]
|
||||
@@ -70,8 +71,9 @@
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (-> db
|
||||
(assoc ::yodlee {:provider-accounts-loading? true})
|
||||
#_(assoc ::provider-accounts [])
|
||||
#_(assoc ::provider-accounts-loading? true))
|
||||
(assoc ::save-error nil)
|
||||
(assoc ::provider-accounts [])
|
||||
(assoc ::provider-accounts-loading? true))
|
||||
:http {:token (:user db)
|
||||
:method :get
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
@@ -121,7 +123,7 @@
|
||||
(re-frame/reg-event-fx
|
||||
::save-error
|
||||
(fn [{:keys [db]} [_ authentication]]
|
||||
{:dispatch [::mounted]}))
|
||||
{:db (assoc :db ::load-error "error")}))
|
||||
|
||||
(defn yodlee-link-button []
|
||||
[:div
|
||||
@@ -149,6 +151,14 @@
|
||||
|
||||
[:button.button.is-primary {:class (if loading? "is-loading" "") :on-click (dispatch-event [::authenticate-with-yodlee])} "Authenticate with Yodlee"]))])
|
||||
|
||||
(defn yodlee-date->date [d]
|
||||
(try
|
||||
(some-> d
|
||||
(str->date (:date-time-no-ms f/formatters))
|
||||
)
|
||||
(catch js/Error e
|
||||
nil)))
|
||||
|
||||
(defn yodlee-date->str [d]
|
||||
(try
|
||||
(or (some-> d
|
||||
@@ -209,11 +219,16 @@
|
||||
:uri (str "/api/yodlee/reauthenticate/" provider-account-id )
|
||||
:body {"loginForm"
|
||||
{"row"
|
||||
[{"field"
|
||||
(mapv (fn [[k v]]
|
||||
{"id" k
|
||||
"value" v})
|
||||
(:data (get-in db [::forms/forms [::login-form provider-account-id]])))}]}}
|
||||
(->> (get-in db [::forms/forms [::login-form provider-account-id]])
|
||||
:data
|
||||
(sort-by (fn [[k v]] k))
|
||||
(map second)
|
||||
(map (fn [row]
|
||||
{"field"
|
||||
(mapv (fn [[k v]]
|
||||
{"id" k
|
||||
"value" v})
|
||||
row)})))}}
|
||||
|
||||
:on-success [::authenticated]
|
||||
:on-error [::forms/save-error [::login-form provider-account-id]]}}))
|
||||
@@ -233,57 +248,73 @@
|
||||
[:div.card-header-title "Provider account " (:id account)
|
||||
]]
|
||||
[:div.card-content
|
||||
[:div.notification.is-info.is-light
|
||||
[:div.level
|
||||
[:div.level-left
|
||||
[:div.level-item
|
||||
[:p
|
||||
"This account was last updated on "
|
||||
(yodlee-date->str (-> account :dataset first :lastUpdated))
|
||||
", and last attempted "
|
||||
(yodlee-date->str (-> account :dataset first :lastUpdateAttempt))
|
||||
"."]]]
|
||||
[:div.level-right [:button.button.is-success {:on-click (dispatch-event [::kick (:id account)] )} "Force refresh" ]]]
|
||||
|
||||
]
|
||||
[:div.notification.is-info.is-warning
|
||||
[:div.level
|
||||
[:div.level-left
|
||||
[:div.level-item
|
||||
"This provider account's status is '"
|
||||
(-> account :dataset first :additionalStatus)
|
||||
"'. If this is in error, it might help to try reauthenticating by filling out the form below."]]]]
|
||||
(if (> (some-> (-> account :dataset first :lastUpdated)
|
||||
(yodlee-date->date )
|
||||
(time/interval (time/now))
|
||||
(time/in-days ))
|
||||
1)
|
||||
[:div.notification.is-info.is-light
|
||||
[:div.level
|
||||
[:div.level-left
|
||||
[:div.level-item
|
||||
[:p
|
||||
"This account was last updated on "
|
||||
(yodlee-date->str (-> account :dataset first :lastUpdated))
|
||||
", and last attempted "
|
||||
(yodlee-date->str (-> account :dataset first :lastUpdateAttempt))
|
||||
"."]]]
|
||||
[:div.level-right [:button.button.is-success {:on-click (dispatch-event [::kick (:id account)] )} "Force refresh" ]]]
|
||||
|
||||
])
|
||||
|
||||
|
||||
[yodlee-accounts-table (:accounts account)]
|
||||
[:div
|
||||
(if (:field account)
|
||||
(for [f (:field account)]
|
||||
(let [{error :error account-data :data } @(re-frame/subscribe [::forms/form [::mfa-form (:id account)]])
|
||||
change-event [::forms/change [::mfa-form (:id account)]]
|
||||
{:keys [form field field-holder raw-field error-notification submit-button]} (forms/vertical-form {:can-submit [::can-submit]
|
||||
:change-event change-event
|
||||
:submit-event [::reauthenticate-mfa (:id account)]
|
||||
:id [::mfa-form (:id account)]} )]
|
||||
(form {:title "Reauthenticate (login)"}
|
||||
(if (not= (-> account :dataset first :additionalStatus)
|
||||
"AVAILABLE_DATA_RETRIEVED")
|
||||
[:div
|
||||
[:div.notification.is-info.is-warning
|
||||
[:div.level
|
||||
[:div.level-left
|
||||
[:div.level-item
|
||||
"This provider account's status is '"
|
||||
(-> account :dataset first :additionalStatus)
|
||||
"'. If this is in error, it might help to try reauthenticating by filling out the form below."]]]]
|
||||
(if (:field account)
|
||||
(for [f (:field account)]
|
||||
(let [{error :error account-data :data } @(re-frame/subscribe [::forms/form [::mfa-form (:id account)]])
|
||||
change-event [::forms/change [::mfa-form (:id account)]]
|
||||
{:keys [form-inline field field-holder raw-field error-notification submit-button]} (forms/vertical-form {:can-submit [::can-submit]
|
||||
:change-event change-event
|
||||
:submit-event [::reauthenticate-mfa (:id account)]
|
||||
:id [::mfa-form (:id account)]} )]
|
||||
(form-inline {:title "Reauthenticate (mfa)"}
|
||||
[:<>
|
||||
(error-notification)
|
||||
(doall
|
||||
(for [f (-> account :field)]
|
||||
^{:key (:id f)}
|
||||
(field (:label f)
|
||||
[:input.input {:type "text" :field [(:id f)] :value (-> f :field first :value)}])))
|
||||
(submit-button "Reauthenticate")])))
|
||||
(let [{error :error account-data :data } @(re-frame/subscribe [::forms/form [::login-form (:id account)]])
|
||||
change-event [::forms/change [::login-form (:id account)]]
|
||||
{:keys [form-inline field field-holder raw-field error-notification submit-button]} (forms/vertical-form {:can-submit [::can-submit]
|
||||
:change-event change-event
|
||||
:submit-event [::reauthenticate (:id account)]
|
||||
:id [::login-form (:id account)]} )]
|
||||
(form-inline {:title "Reauthenticate (login)"}
|
||||
[:<>
|
||||
|
||||
(error-notification)
|
||||
(for [f (-> account :field)]
|
||||
^{:key (:id f)}
|
||||
(field (:label f)
|
||||
[:input.input {:type "text" :field [(:id f)] :value (-> f :field first :value)}]))
|
||||
(submit-button "Reauthenticate"))))
|
||||
(let [{error :error account-data :data } @(re-frame/subscribe [::forms/form [::login-form (:id account)]])
|
||||
change-event [::forms/change [::login-form (:id account)]]
|
||||
{:keys [form field field-holder raw-field error-notification submit-button]} (forms/vertical-form {:can-submit [::can-submit]
|
||||
:change-event change-event
|
||||
:submit-event [::reauthenticate (:id account)]
|
||||
:id [::login-form (:id account)]} )]
|
||||
(form {:title "Reauthenticate (MFA)"}
|
||||
(error-notification)
|
||||
(for [f (-> account :loginForm first :row)]
|
||||
^{:key (:id f)}
|
||||
(field (:label f)
|
||||
[:input.input {:type "text" :field [(:id f)] :value (-> f :field first :value)}]))
|
||||
(submit-button "Reauthenticate"))))]]]))]]))
|
||||
(doall
|
||||
(for [[row i] (map vector (-> account :loginForm last :row) (range))
|
||||
f (:field row)]
|
||||
^{:key (:id f)}
|
||||
[:div
|
||||
(field (:label row)
|
||||
[:input.input {:type "text" :field [i (:id f)]}])]))
|
||||
(submit-button "Reauthenticate")])))])]]))]]))
|
||||
|
||||
|
||||
(defn admin-yodlee-content []
|
||||
|
||||
Reference in New Issue
Block a user