tweaks.
This commit is contained in:
@@ -29,6 +29,14 @@
|
|||||||
:on-success [::received-invoices :pending]
|
:on-success [::received-invoices :pending]
|
||||||
}}))
|
}}))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::view-pending-invoices
|
||||||
|
(fn [cofx []]
|
||||||
|
{:db (assoc-in (:db cofx) [:status :loading] true)
|
||||||
|
:http {:method :get
|
||||||
|
:uri "/api/invoices/pending"
|
||||||
|
:on-success [::received-invoices :pending]}}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::view-unpaid-invoices
|
::view-unpaid-invoices
|
||||||
(fn [cofx []]
|
(fn [cofx []]
|
||||||
|
|||||||
@@ -88,48 +88,50 @@
|
|||||||
(defmethod active-page :import-invoices []
|
(defmethod active-page :import-invoices []
|
||||||
[(with-meta
|
[(with-meta
|
||||||
(fn []
|
(fn []
|
||||||
(let [invoices (re-frame/subscribe [::subs/pending-invoices])]
|
(let [invoices (re-frame/subscribe [::subs/pending-invoices])
|
||||||
|
status (re-frame/subscribe [::subs/status])]
|
||||||
[:div {:class "inbox-messages"}
|
[:div {:class "inbox-messages"}
|
||||||
[:h1.title "Upload invoices"]
|
[:h1.title "Upload invoices"]
|
||||||
[dropzone]
|
[dropzone]
|
||||||
|
|
||||||
[:div {:class "section"}]
|
[:div {:class "section"}]
|
||||||
[:div {:class "card found-invoices", :style {:display (if (seq @invoices) "block" "none")}}
|
[:div {:class "card found-invoices",}
|
||||||
[:div {:class "card-header"}
|
[:div {:class "card-header"}
|
||||||
[:span {:class "card-header-title"} "Found Invoices"]]
|
[:span {:class "card-header-title"} "Found Invoices"]]
|
||||||
[:div {:class "card-content"}
|
[:div {:class "card-content"}
|
||||||
[:table {:class "table", :style {:width "100%"}}
|
(if (:loading @status)
|
||||||
[:thead
|
[:h1.title
|
||||||
[:tr
|
[:i.fa.fa-spin.fa-spinner]]
|
||||||
[:th "Customer"]
|
(if (seq @invoices)
|
||||||
[:th "Invoice #"]
|
[:table {:class "table", :style {:width "100%"}}
|
||||||
[:th "Date"]
|
[:thead
|
||||||
[:th "Amount"]]]
|
[:tr
|
||||||
[:tbody (for [{:keys [customer-identifier invoice-number date total id] :as i} @invoices]
|
[:th "Customer"]
|
||||||
^{:key (str customer-identifier "-" invoice-number "-" date "-" total "-" id)}
|
[:th "Invoice #"]
|
||||||
[:tr
|
[:th "Date"]
|
||||||
[:td customer-identifier]
|
[:th "Amount"]]]
|
||||||
[:td invoice-number]
|
[:tbody (for [{:keys [customer-identifier invoice-number date total id] :as i} @invoices]
|
||||||
[:td date]
|
^{:key (str customer-identifier "-" invoice-number "-" date "-" total "-" id)}
|
||||||
[:td total]])]]]
|
[:tr
|
||||||
[:div.card-footer
|
[:td customer-identifier]
|
||||||
[:a.card-footer-item
|
[:td invoice-number]
|
||||||
{:on-click (fn [e]
|
[:td date]
|
||||||
(.preventDefault e)
|
[:td total]])]]
|
||||||
(re-frame/dispatch [::events/approve-invoices]))}
|
[:span "No pending invoices"]))]
|
||||||
"Approve all"]
|
(if (and (seq @invoices) (not (:loading @status)))
|
||||||
[:a.card-footer-item
|
[:div.card-footer
|
||||||
{:on-click (fn [e]
|
[:a.card-footer-item
|
||||||
(.preventDefault e)
|
{:on-click (fn [e]
|
||||||
(re-frame/dispatch [::events/reject-invoices]))}
|
(.preventDefault e)
|
||||||
"Reject all"]
|
(re-frame/dispatch [::events/approve-invoices]))}
|
||||||
]]]))
|
"Accept all"]
|
||||||
|
[:a.card-footer-item
|
||||||
|
{:on-click (fn [e]
|
||||||
|
(.preventDefault e)
|
||||||
|
(re-frame/dispatch [::events/reject-invoices]))}
|
||||||
|
"Reject all"]])]]))
|
||||||
{:component-will-mount (fn []
|
{:component-will-mount (fn []
|
||||||
(go
|
(re-frame/dispatch [::events/view-pending-invoices]))})])
|
||||||
(->> (<! (http/get "/api/invoices/pending"))
|
|
||||||
:body
|
|
||||||
(conj [::events/received-invoices :pending])
|
|
||||||
(re-frame/dispatch))))})])
|
|
||||||
|
|
||||||
(defn main-panel []
|
(defn main-panel []
|
||||||
(let [name (re-frame/subscribe [::subs/name])
|
(let [name (re-frame/subscribe [::subs/name])
|
||||||
|
|||||||
Reference in New Issue
Block a user