some visual feedback that it worked
This commit is contained in:
@@ -89,14 +89,10 @@
|
||||
(map #(str/split % #"\t"))
|
||||
(map #(into {} (filter identity (map (fn [c k] [k c] ) % columns))))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(map (parse-or-error :amount parse-amount))
|
||||
(map (parse-or-error :account-id parse-account-id))
|
||||
(map (parse-or-error :date parse-date)))
|
||||
error-rows (filter :errors rows)
|
||||
|
||||
raw-transactions (vec (->> rows
|
||||
(filter #(not (seq (:errors %))) )
|
||||
@@ -110,7 +106,8 @@
|
||||
(manual-import raw-transactions company-id 1)
|
||||
|
||||
{:status 200
|
||||
:body (pr-str {:status "success"})
|
||||
:body (pr-str {:imported (count raw-transactions)
|
||||
:errors (map #(dissoc % :date) error-rows)})
|
||||
:headers {"Content-Type" "application/edn"}}))
|
||||
)
|
||||
(context "/invoices" []
|
||||
|
||||
@@ -150,8 +150,12 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::manual-yodlee-import-completed
|
||||
(fn [{:keys [db]} _]
|
||||
{:dispatch [::events/modal-completed ::manual-yodlee-import]}))
|
||||
(fn [{:keys [db]} [_ {:keys [imported errors]}]]
|
||||
(re-frame/dispatch [::params-change {}])
|
||||
{:dispatch [::events/modal-completed ::manual-yodlee-import]
|
||||
:db (-> db
|
||||
(assoc-in [::notification :message] (str "Successfully imported " imported " transactions"))
|
||||
(assoc-in [::notification :errors] errors))}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::manual-yodlee-import-started
|
||||
@@ -182,27 +186,51 @@
|
||||
:event change-event
|
||||
:subscription data}]]]]]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::notification
|
||||
(fn [db]
|
||||
(-> db ::notification)))
|
||||
|
||||
(def transactions-page
|
||||
|
||||
(with-meta
|
||||
(fn []
|
||||
(let [current-company @(re-frame/subscribe [::subs/company])
|
||||
(let [notification (re-frame/subscribe [::notification])
|
||||
current-company @(re-frame/subscribe [::subs/company])
|
||||
user @(re-frame/subscribe [::subs/user])]
|
||||
|
||||
[:div
|
||||
[:h1.title "Transactions"]
|
||||
(when (= "admin" (:role user))
|
||||
[:div.is-pulled-right
|
||||
[:button.button.is-danger {:disabled (if current-company
|
||||
""
|
||||
"disabled")
|
||||
:on-click (dispatch-event [::manual-yodlee-import])}
|
||||
"Manual Yodlee Import"]])
|
||||
(list
|
||||
(when (:message @notification)
|
||||
|
||||
(list
|
||||
[:div.notification
|
||||
(:message @notification)
|
||||
]
|
||||
(when (seq (:errors @notification))
|
||||
[:div.notification.is-danger
|
||||
[:h3 (count (:errors @notification)) " errors:"]
|
||||
|
||||
[:ul
|
||||
(for [transaction (:errors @notification)
|
||||
error (:errors transaction)]
|
||||
[:li (:description-original transaction) "-" (:details error)])
|
||||
]])))
|
||||
|
||||
[:div.is-pulled-right
|
||||
[:button.button.is-danger {:disabled (if current-company
|
||||
""
|
||||
"disabled")
|
||||
:on-click (dispatch-event [::manual-yodlee-import])}
|
||||
"Manual Yodlee Import"]]))
|
||||
[transaction-table {:id :transactions
|
||||
:params (re-frame/subscribe [::params])
|
||||
:transaction-page (re-frame/subscribe [::transaction-page])
|
||||
:status (re-frame/subscribe [::subs/status])
|
||||
:on-params-change (fn [params]
|
||||
(re-frame/dispatch [::params-change params]))}]
|
||||
:params (re-frame/subscribe [::params])
|
||||
:transaction-page (re-frame/subscribe [::transaction-page])
|
||||
:status (re-frame/subscribe [::subs/status])
|
||||
:on-params-change (fn [params]
|
||||
(re-frame/dispatch [::params-change params]))}]
|
||||
[manual-yodlee-import-modal]]))
|
||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {}]) }))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user