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