editing clients has started.

This commit is contained in:
Bryce Covert
2019-01-19 09:52:06 -08:00
parent 9e1999725c
commit de5ebe8108
7 changed files with 54 additions and 28 deletions

View File

@@ -10,6 +10,7 @@
(re-frame/reg-event-fx
::edit
(fn [{:keys [db]} [_ client-id]]
(println "EDITING")
{:dispatch [::events/modal-status :auto-ap.views.pages.admin.clients/edit {:visible? true}]
:db (assoc-in db [:admin :client]
(get (:clients db) client-id))}))
@@ -17,17 +18,20 @@
(re-frame/reg-event-fx
::save
(fn [{:keys [db]} _]
(println "saving")
(let [edited-client (-> (get-in db [:admin :clients])
(dissoc :location))]
{:db (assoc-in db [:admin :client :saving?] true)
:http {:method :put
:token (:user db)
:body (pr-str edited-client)
:headers {"Content-Type" "application/edn"}
:uri (str "/api/clients/" (:id edited-client))
:on-success [::save-complete]
:on-error [::save-error]}})))
:graphql
{:token (-> db :user)
:query-obj {:venia/operation {:operation/type :mutation
:operation/name "EditClient"}
:venia/queries [{:query/data [:upsert-client
{:client edited-client}
[:id :name]
]}]}
:on-success [::save-complete]
:on-error [::save-error]}})))
(re-frame/reg-event-fx
::save-complete