reject supported.
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
(defn approve []
|
||||
(map db->clj (j/update! conn :invoices {:imported true} [] )))
|
||||
|
||||
(defn reject []
|
||||
(j/delete! conn :invoices ["imported = false"]))
|
||||
|
||||
(defn get-unpaid []
|
||||
(map db->clj (j/query conn "SELECT * FROM invoices WHERE imported=true")))
|
||||
|
||||
|
||||
@@ -41,6 +41,12 @@
|
||||
{:status 200
|
||||
:body (pr-str (invoices/get-pending))
|
||||
:headers {"Content-Type" "application/edn"}})
|
||||
(POST "/api/invoices/reject" []
|
||||
(invoices/reject)
|
||||
(println (invoices/get-pending))
|
||||
{:status 200
|
||||
:body (pr-str (invoices/get-pending))
|
||||
:headers {"Content-Type" "application/edn"}})
|
||||
(POST "/pdf-upload"
|
||||
{{ files "file"} :params :as params}
|
||||
(let [{:keys [filename tempfile]} files]
|
||||
@@ -56,4 +62,4 @@
|
||||
(route/not-found "Not Found"))
|
||||
|
||||
(def app
|
||||
(wrap-edn-params (mp/wrap-multipart-params (wrap-reload app-routes))))
|
||||
(wrap-edn-params (mp/wrap-multipart-params (wrap-reload #'app-routes))))
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
(fn [db [_ new-invoices]]
|
||||
(assoc-in db [:invoices :pending] new-invoices)))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::invoices-rejected
|
||||
(fn [db [_ new-invoices]]
|
||||
(assoc-in db [:invoices :pending] new-invoices)))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::approve-invoices
|
||||
(fn [cofx [_]]
|
||||
@@ -34,6 +39,14 @@
|
||||
:on-success ::invoices-approved
|
||||
}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::reject-invoices
|
||||
(fn [cofx [_]]
|
||||
{:http {:method :post
|
||||
:uri "/api/invoices/reject"
|
||||
:on-success ::invoices-rejected
|
||||
}}))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::received-invoices
|
||||
(fn [db [_ type new-invoices]]
|
||||
|
||||
@@ -121,6 +121,9 @@
|
||||
(re-frame/dispatch [::events/approve-invoices]))}
|
||||
"Approve all"]
|
||||
[:a.card-footer-item
|
||||
{:on-click (fn [e]
|
||||
(.preventDefault e)
|
||||
(re-frame/dispatch [::events/reject-invoices]))}
|
||||
"Reject all"]
|
||||
]]]))
|
||||
{:component-did-mount (fn []
|
||||
|
||||
Reference in New Issue
Block a user