editing clients has started.
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
:graphql {:token token
|
||||
:query-obj {:venia/queries [[:client
|
||||
|
||||
[:id :name :locations [:bank-accounts [:id :number :check-number :name :type] ]
|
||||
[:id :name :email :locations [:bank-accounts [:id :number :check-number :name :type] ]
|
||||
[:address [:street1 :street2 :city :state :zip]]]]
|
||||
[:vendor
|
||||
[:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
|
||||
@@ -60,7 +60,7 @@
|
||||
(fn [{:keys [db]} [_ token user]]
|
||||
{:graphql {:token token
|
||||
:query-obj {:venia/queries [[:client
|
||||
[:id :name [:bank-accounts [:id :number :check-number :name :type]]]]
|
||||
[:id :name [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name :type]]]]
|
||||
[:vendor
|
||||
[:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,17 +23,18 @@
|
||||
::save
|
||||
(fn [{:keys [db]} _]
|
||||
(let [edited-client (-> (get-in db [:admin :client])
|
||||
(dissoc :location)
|
||||
(dissoc :new-account))]
|
||||
|
||||
(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 [:edit-client
|
||||
{:edit-client edited-client}
|
||||
[:id :name]
|
||||
]}]}
|
||||
:on-success [::save-complete]
|
||||
:on-error [::save-error]}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::save-complete
|
||||
@@ -151,6 +152,7 @@
|
||||
^{:key location} [:li location ])]]]
|
||||
[:h2.subtitle "Address"]
|
||||
|
||||
|
||||
[address-field {:field [:address]
|
||||
:event ::change
|
||||
:subscription editing-client}]
|
||||
|
||||
Reference in New Issue
Block a user