adding new invoices.

This commit is contained in:
Bryce Covert
2017-12-10 08:20:59 -08:00
parent 87b89b3528
commit 59a0c40beb
7 changed files with 94 additions and 5 deletions

View File

@@ -52,6 +52,21 @@
:uri "/api/invoices/reject"
:on-success [::received-invoices :pending]
}}))
(re-frame/reg-event-db
::submitted-new-invoice
(fn [db [_ invoice]]
(assoc db :new-invoice {})))
(re-frame/reg-event-fx
::submit-new-invoice
(fn [{:keys [db]} [_ invoice]]
{:http {:method :post
:uri "/api/invoices"
:body (pr-str {:rows [(assoc invoice :imported true)]})
:headers {"Content-Type" "application/edn"}
:on-success [::submitted-new-invoice]}
:db (assoc-in db [:new-invoice :loading?] true)}))
(re-frame/reg-event-db
::received-invoices
@@ -60,3 +75,8 @@
(assoc-in [:invoices type] new-invoices)
(assoc-in [:status :loading] false)
)))
(re-frame/reg-event-db
::change-form-state
(fn [db [_ target value]]
(assoc-in db target value)))