Yodlee is manually refreshable

This commit is contained in:
Bryce Covert
2020-12-22 13:59:50 -08:00
parent 6930a8c7c2
commit bbdb9602aa
6 changed files with 114 additions and 92 deletions

View File

@@ -1,11 +1,32 @@
(ns auto-ap.views.pages.admin.yodlee2.table
(:require
[clojure.string :as str]
[re-frame.core :as re-frame]
[auto-ap.views.utils :refer [action-cell-width date->str]]
[auto-ap.views.pages.admin.users.form :as form]
[auto-ap.views.components.buttons :as buttons]
[auto-ap.views.components.grid :as grid]))
(:require [auto-ap.status :as status]
[auto-ap.subs :as subs]
[auto-ap.views.components.buttons :as buttons]
[auto-ap.views.components.grid :as grid]
[auto-ap.views.pages.admin.users.form :as form]
[auto-ap.views.utils :refer [action-cell-width date->str with-user ->$]]
[re-frame.core :as re-frame]))
(re-frame/reg-event-fx
::refreshed
[with-user ]
(fn [{:keys [user db]} [_ provider-account ]]
;; this is tracked in yodlee main, for refreshing
{}))
(re-frame/reg-event-fx
::request-refresh
[with-user ]
(fn [{:keys [user db]} [_ provider-account ]]
{:http {:token user
:method :post
:headers {"Content-Type" "application/edn"}
:uri (str "/api/yodlee2/provider-accounts/refresh/")
:owns-state {:multi ::refresh
:which provider-account}
:body {:client-id (:id @(re-frame/subscribe [::subs/client]))
:provider-account-id provider-account}
:on-success [::refreshed provider-account]}}))
(re-frame/reg-event-fx
::params-changed
@@ -18,7 +39,8 @@
(-> db ::params)))
(defn table [{:keys [status page]}]
(let [params @(re-frame/subscribe [::params])]
(let [params @(re-frame/subscribe [::params])
statuses @(re-frame/subscribe [::status/multi ::refresh])]
[grid/grid {:status status
:on-params-change (fn [p]
(re-frame/dispatch [::params-changed p]))
@@ -28,12 +50,12 @@
[grid/table {:fullwidth true}
[grid/header
[grid/row {}
[grid/header-cell {} "Provider Account"]
[grid/header-cell {} "Status"]
[grid/header-cell {} "Detailed Status"]
[grid/header-cell {} "Last Updated"]
[grid/header-cell {:style {:width "18em"}} "Provider Account"]
[grid/header-cell {:style {:width "20em"}} "Status"]
[grid/header-cell {:style {:width "20em"}} "Detailed Status"]
[grid/header-cell {:style {:width "12em"}} "Last Updated"]
[grid/header-cell {} "Accounts"]
[grid/header-cell {:style {:width (action-cell-width 1)}} ]]]
[grid/header-cell {:style {:width (action-cell-width 3)}} ]]]
[grid/body
(for [{:keys [id name accounts status detailed-status last-updated clients] :as c} (:data page)]
^{:key (str name "-" id )}
@@ -46,7 +68,11 @@
[:ul
(for [a accounts]
^{:key (:id a)}
[:li (:name a) " - " (:number a)])]]
[:li (:name a) " - " (:number a) [:div.tag (->$ (:available-balance a))]])]]
[grid/cell {}
[buttons/fa-icon {:event [::form/editing c]
:icon "fa-pencil"}]]])]]]))
[:div.buttons
[buttons/fa-icon {:event [::form/editing c]
:icon "fa-pencil"}]
[buttons/fa-icon {:event [::request-refresh (:id c)]
:class (status/class-for (get statuses (:id c)))
:icon "fa-refresh"}]]]])]]]))