Tons of small fixes

This commit is contained in:
Bryce Covert
2020-07-27 21:28:02 -07:00
parent 3737cfa628
commit fdc1d3e9e4
26 changed files with 428 additions and 178 deletions

View File

@@ -22,6 +22,7 @@
(reagent/create-class
{:display-name "dropzone"
:component-did-mount (fn [this]
(println "HERE?")
(js/Dropzone. (rdom/dom-node this)
(clj->js {:init (fn []
(.on (js-this) "success" (fn [_ files]
@@ -36,6 +37,7 @@
:previewsContainer "#dz-hidden"
:previewTemplate "<div class='dz-hidden-preview'></div>"})))
:reagent-render (fn []
{:key batch}
[:form.dz {:action "/api/invoices/upload"}
[:div.field.has-addons
[:p.control
@@ -78,11 +80,24 @@
(fn [db]
(-> db (::params {}))))
(re-frame/reg-sub
::batch
(fn [db]
(-> db (::batch 0))))
(re-frame/reg-event-fx
::invalidated
(fn [cofx [_ params]]
{:dispatch [::params-change @(re-frame/subscribe [::params])]}))
(re-frame/reg-event-fx
::completed
(fn [cofx [_ params]]
(println (::batch (:db cofx)))
{:dispatch [::invalidated]
:db (-> (:db cofx)
(update ::batch inc))}))
(re-frame/reg-event-fx
::params-change
(fn [cofx [_ params]]
@@ -121,7 +136,7 @@
:venia/queries [[:reject-invoices
{:invoices (keys invoices)}
[]]]}
:on-success [::invalidated]}
:on-success [::completed]}
}))
(re-frame/reg-event-fx
@@ -135,7 +150,7 @@
:venia/queries [[:approve-invoices
{:invoices (keys invoices)}
[]]]}
:on-success [::invalidated]}
:on-success [::completed]}
}))
(re-frame/reg-event-fx
@@ -194,11 +209,13 @@
(let [invoice-page (re-frame/subscribe [::invoice-page])
status (re-frame/subscribe [::subs/status])
error (re-frame/subscribe [::error])
batch (re-frame/subscribe [::batch])
client (:id @(re-frame/subscribe [::subs/client]))]
^{:key client}
^{:key (str client "-" @batch)}
[:div
[:h1.title "Upload invoices"]
^{:key (str @batch)}
[dropzone]
[:div {:class "section"}