adds integration statuses to bank account pages.
This commit is contained in:
@@ -16,10 +16,12 @@
|
||||
|
||||
(defn client-query [token]
|
||||
(cond-> [:id :name :signature-file :code :email :matches :week-a-debits :week-a-credits :week-b-debits :week-b-credits :locations :locked-until :square-auth-token
|
||||
[:square-integration-status [:last-updated :last-attempt :message :state]]
|
||||
[:square-locations [:square-id :id :name :client-location]]
|
||||
[:emails [:id :email :description]]
|
||||
[:location-matches [:id :location :match]]
|
||||
[:bank-accounts [:id :start-date :numeric-code :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id
|
||||
[:integration-status [:last-updated :last-attempt :message :state]]
|
||||
[:yodlee-account [:name :id :number]]
|
||||
[:plaid-account [:name :id :number]]
|
||||
[:intuit-bank-account [:name :id :external-id]]
|
||||
@@ -88,7 +90,6 @@
|
||||
(re-frame/reg-event-fx
|
||||
::received-initial
|
||||
(fn [{:keys [db]} [_ {clients :client}]]
|
||||
|
||||
{:db (-> db
|
||||
(assoc :clients (by :id clients) )
|
||||
(assoc :is-initial-loading? false)
|
||||
|
||||
@@ -49,6 +49,32 @@
|
||||
(merge (select-keys query-params #{:start :sort}) specific-params )))
|
||||
|
||||
|
||||
(defn integration-status-badge [name status]
|
||||
(condp = (:state status)
|
||||
:success
|
||||
[:div.tag.has-tooltip-right.has-tooltip-arrow {:data-tooltip (str "Last updated:" (date->str (:last-updated status))
|
||||
"\n"
|
||||
"Last Attempted:" (date->str (:last-attempt status)))} [:span.icon [:i.has-text-success.fa.fa-check]] [:span name]]
|
||||
|
||||
:failed
|
||||
[:div.tag.is-danger.is-light.has-tooltip-right.has-tooltip-arrow {:data-tooltip (str "Last updated:" (date->str (:last-updated status))
|
||||
"\n"
|
||||
"Last Attempted:" (date->str (:last-attempt status))
|
||||
"\n"
|
||||
(:message status))
|
||||
} [:span.icon [:i.has-text-danger.fa.fa-warning]] [:span name]]
|
||||
|
||||
:unauthorized
|
||||
[:div.tag.is-danger.is-light.has-tooltip-right.has-tooltip-arrow {:data-tooltip (str "Last updated:" (date->str (:last-updated status))
|
||||
"\n"
|
||||
"Last Attempted:" (date->str (:last-attempt status))
|
||||
"\n"
|
||||
"Your user is unauthorized. Detail:\n"
|
||||
(:message status))
|
||||
} [:span.icon [:i.has-text-danger.fa.fa-warning]] [:span name]]
|
||||
nil
|
||||
))
|
||||
|
||||
(defn clients-table [{:keys [page status]}]
|
||||
(let [states @(re-frame/subscribe [::status/multi ::setup-sales-queries])]
|
||||
[grid/grid {:on-params-change (fn [p]
|
||||
@@ -63,21 +89,27 @@
|
||||
[grid/header-cell {} "Name"]
|
||||
[grid/header-cell {:style {:width "20em"}} "Code"]
|
||||
[grid/header-cell {} "Locations"]
|
||||
[grid/header-cell {} "Locked Until"]
|
||||
[grid/header-cell {} "Status"]
|
||||
[grid/header-cell {} "Email"]
|
||||
[grid/header-cell {:style {:width (action-cell-width 2)}}]]
|
||||
]
|
||||
[grid/body
|
||||
(for [{:keys [id name email locked-until code locations]} (:data page)]
|
||||
(for [{:keys [id name email square-integration-status locked-until code locations bank-accounts]} (:data page)]
|
||||
^{:key (str name "-" id )}
|
||||
[grid/row {:id id}
|
||||
[grid/cell {} name]
|
||||
[grid/cell {} code]
|
||||
[grid/cell {} (str/join ", " locations)]
|
||||
[grid/cell {} [:div.tag (or (some-> locked-until date->str)
|
||||
"Not locked"
|
||||
|
||||
)]]
|
||||
[grid/cell {} [:div.tags
|
||||
|
||||
[:div.tag (or (some-> locked-until date->str (#(str "Locked " %))) "Not locked")]
|
||||
[integration-status-badge "Square" square-integration-status]
|
||||
[:<>
|
||||
(for [bank-account bank-accounts
|
||||
:let [code (:code bank-account)
|
||||
integration-status (:integration-status bank-account)]
|
||||
:when integration-status]
|
||||
[integration-status-badge code integration-status])]]]
|
||||
[grid/cell {} email]
|
||||
[grid/cell {} [:div.buttons [buttons/fa-icon {:event [::setup-sales-queries id]
|
||||
:class (status/class-for (get states id))
|
||||
|
||||
Reference in New Issue
Block a user