removing vestiges of http.

This commit is contained in:
Bryce Covert
2018-11-09 13:39:47 -08:00
parent 8ea4ea0c73
commit e15245690d
4 changed files with 33 additions and 66 deletions

View File

@@ -43,6 +43,12 @@
[:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
:on-success [::received-initial]}}))))
(def vendor-query
[:id :name :default-expense-account
[:primary-contact [:name :phone :email :id]]
[:secondary-contact [:id :name :phone :email]]
:print-as :invoice-reminder-schedule :code
[:address [:street1 :street2 :city :state :zip]]])
(re-frame/reg-event-db
::toggle-menu
@@ -182,26 +188,20 @@
::save-vendor
(fn [{:keys [db]} _]
(let [edited-vendor (get-in db [:user-editing-vendor])]
(if (:id edited-vendor)
{:http {:method :put
:token (:user db)
:body (pr-str edited-vendor)
:headers {"Content-Type" "application/edn"}
:uri (str "/api/vendors/" (:id edited-vendor))
:on-success [::save-complete]
:on-error [::save-error]}}
{:http {:method :post
:token (:user db)
:body (pr-str edited-vendor)
:headers {"Content-Type" "application/edn"}
:uri (str "/api/vendors")
:on-success [::save-complete]
:on-error [::save-error]}}))))
(assoc {} :graphql
{:token (-> db :user)
:query-obj {:venia/operation {:operation/type :mutation
:operation/name "UpsertVendor"}
:venia/queries [{:query/data [:upsert-vendor
{:vendor edited-vendor}
vendor-query]}]}
:on-success [::save-complete]
:on-error [::save-error]}))))
(re-frame/reg-event-fx
::save-complete
(fn [{:keys [db]} [_ vendor]]
{:dispatch [::modal-completed :auto-ap.views.main/user-editing-vendor ]
:db (-> db
(dissoc :user-editing-vendor)
(assoc-in [:vendors (:id vendor)] vendor))}))
(assoc-in [:vendors (:id vendor)] (:upsert-vendor vendor)))}))