From 5a0bcc7ca4a6ebfa2a6281253bd9febd05a55ff1 Mon Sep 17 00:00:00 2001 From: BC Date: Thu, 25 Oct 2018 21:18:31 -0700 Subject: [PATCH] fixing kick. --- src/cljs/auto_ap/views/pages/admin/yodlee.cljs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/cljs/auto_ap/views/pages/admin/yodlee.cljs b/src/cljs/auto_ap/views/pages/admin/yodlee.cljs index 361859f2..0c778c12 100644 --- a/src/cljs/auto_ap/views/pages/admin/yodlee.cljs +++ b/src/cljs/auto_ap/views/pages/admin/yodlee.cljs @@ -72,11 +72,18 @@ (re-frame/reg-event-fx ::kick (fn [{:keys [db]} [_ id]] - {:http {:token (:user db) + {:db (update-in db [::yodlee :accounts] + (fn [as] + (map (fn [a] + (if (= (:id a) id) + (assoc a :status :kicking) + a)) + as))) + :http {:token (:user db) :method :post :headers {"Content-Type" "application/edn"} :uri (str "/api/yodlee/accounts/" id) - :on-success [::kicked id :kicking] + :on-success [::kicked id :kicked] :on-error [::kicked id :errored]}})) (re-frame/reg-event-fx @@ -138,7 +145,7 @@ [:tr [:td {:col-span "6"} "Loading..."] ] (for [account @(re-frame/subscribe [::accounts])] - [:tr + ^{:key (:id account)} [:tr [:td (:accountName account)] [:td (:accountNumber account)] [:td (:id account)] @@ -148,8 +155,11 @@ (cond (= (:status account) :kicking) [:button.button.is-success.is-loading {:disabled "disabled"} "Kick."] + (= (:status account) :kicked) + [:button.button.is-success {:disabled "disabled"} "..."] + (= (:status account) :error) - [:button.button.is-error.is-loading {:disabled "disabled"} "Error."] + [:button.button.is-error {:disabled "disabled"} "Error."] :else [:button.button.is-success {:on-click (dispatch-event [::kick (:id account)] )} "Kick." ])]]))]])