many more fields.

This commit is contained in:
Bryce Covert
2018-04-09 08:47:46 -07:00
parent 934e7c7bf6
commit 87b94f0f3f
4 changed files with 218 additions and 38 deletions

View File

@@ -21,17 +21,18 @@
::save
(fn [{:keys [db]} _]
(let [edited-vendor (get-in db [:admin :vendor])
fx {:db (assoc-in db [:admin :vendor :saving?] true)}]
fx {:db (assoc-in db [:admin :vendor :saving?] true)}
all-fields [:name :email :data :invoice-reminder-schedule :primary-contact :primary-email :primary-phone :secondary-contact :secondary-email :secondary-phone :code :address1 :address2 :city :state :zip]]
(if (:id edited-vendor)
(assoc fx :http {:method :put
:token (:user db)
:body (pr-str (select-keys edited-vendor [:name :email :data :invoice-reminder-schedule :code]))
:body (pr-str (select-keys edited-vendor all-fields))
:headers {"Content-Type" "application/edn"}
:uri (str "/api/vendors/" (:id edited-vendor))
:on-success [::save-complete]})
(assoc fx :http {:method :post
:token (:user db)
:body (pr-str (select-keys edited-vendor [:name :email :data :invoice-reminder-schedule :code]))
:body (pr-str (select-keys edited-vendor all-fields))
:headers {"Content-Type" "application/edn"}
:uri (str "/api/vendors")
:on-success [::save-complete]})))))