merged.
This commit is contained in:
@@ -28,7 +28,9 @@
|
||||
(js/Dropzone. (reagent/dom-node this)
|
||||
(clj->js {:init (fn []
|
||||
(.on (js-this) "success" (fn [_ files]
|
||||
(re-frame/dispatch [::invalidated]))))
|
||||
(re-frame/dispatch [::invalidated])))
|
||||
(.on (js-this) "error" (fn [_ error]
|
||||
(re-frame/dispatch [::errored error]))))
|
||||
:paramName "file"
|
||||
:headers {"Authorization" (str "Token " @token)}
|
||||
:url (str "/api/invoices/upload"
|
||||
@@ -42,6 +44,11 @@
|
||||
(fn [db]
|
||||
(-> db ::invoice-page)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::error
|
||||
(fn [db]
|
||||
(-> db ::error)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::params
|
||||
(fn [db]
|
||||
@@ -57,6 +64,7 @@
|
||||
(fn [cofx [_ params]]
|
||||
|
||||
{:db (-> (:db cofx)
|
||||
(dissoc ::error)
|
||||
(assoc-in [:status :loading] true)
|
||||
(assoc-in [::params] params))
|
||||
:graphql {:token (-> cofx :db :user)
|
||||
@@ -72,6 +80,11 @@
|
||||
(assoc ip :checked (by :id (:invoices ip)))))
|
||||
(assoc-in [:status :loading] false))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::errored
|
||||
(fn [db [_ error]]
|
||||
(assoc db ::error (:message (edn/read-string error)))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::reject-invoices-clicked
|
||||
(fn [{:keys [db]} [_ invoices on-success]]
|
||||
@@ -154,12 +167,17 @@
|
||||
(with-meta
|
||||
(fn []
|
||||
(let [invoice-page (re-frame/subscribe [::invoice-page])
|
||||
status (re-frame/subscribe [::subs/status])]
|
||||
status (re-frame/subscribe [::subs/status])
|
||||
error (re-frame/subscribe [::error])]
|
||||
[:div
|
||||
[:h1.title "Upload invoices"]
|
||||
[dropzone]
|
||||
|
||||
|
||||
[:div {:class "section"}]
|
||||
[:div {:class "section"}
|
||||
(when @error
|
||||
|
||||
[:div.notification.is-warning @error])]
|
||||
[:div {:class "card found-invoices",}
|
||||
[:div {:class "card-header"}
|
||||
[:span {:class "card-header-title"} "Found Invoices"]]
|
||||
|
||||
Reference in New Issue
Block a user