This commit is contained in:
Bryce Covert
2019-10-10 20:17:42 -07:00
9 changed files with 75 additions and 6 deletions

View File

@@ -42,6 +42,7 @@
:code (:code new-client-data) ;; TODO add validation can't change
:email (:email new-client-data)
:locations (:locations new-client-data)
:location-matches (:location-matches new-client-data)
:address {:street1 (:street1 (:address new-client-data))
:street2 (:street2 (:address new-client-data)),
:city (:city (:address new-client-data))
@@ -86,7 +87,7 @@
:operation/name "EditClient"}
:venia/queries [{:query/data [:edit-client
{:edit-client new-client-req}
[:id :name :code :email :locations [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name :code :bank-code :bank-name :routing :type :visible :yodlee-account-id :sort-order :locations]]]]}]}
[:id :name :code :email :locations [:location-matches [:location :match]] [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name :code :bank-code :bank-name :routing :type :visible :yodlee-account-id :sort-order :locations]]]]}]}
:on-success [::save-complete]
:on-error [::forms/save-error ::new-client]}}
{:db new-client-form}))))
@@ -117,6 +118,14 @@
(update-in [:bank-accounts which-account :locations] #(conj (or % #{}) (get-in client [:bank-accounts which-account :location-select])))
(update-in [:bank-accounts which-account] dissoc :location-select))))
(re-frame/reg-event-db
::add-new-location-match
[(forms/in-form ::new-client) (re-frame/path [:data])]
(fn [client _]
(-> client
(update :location-matches conj (:location-match client))
(dissoc :location-match))))
(re-frame/reg-event-db
::add-new-bank-account
[(forms/in-form ::new-client) (re-frame/path [:data])]
@@ -440,6 +449,31 @@
(for [location (:locations new-client)]
^{:key location} [:li location ])]]]
[:div.field
[:p.help "Location matches"]
[:div.control
[:div.field.has-addons
[:p.control
[bind-field
[:input.input {:type "text"
:placeholder "San Jose"
:field [:location-match :match]
:event change-event
:subscription new-client}]]]
[:p.control
[bind-field
[:input.input {:type "text"
:placeholder "DT"
:field [:location-match :location]
:event change-event
:subscription new-client}]]]
[:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-new-location-match])} "Add"]]]
[:ul
(for [{:keys [location match]} (:location-matches new-client)]
^{:key location} [:li match "->" location ])]]]
[:div {:style {:padding-bottom "0.75em" :padding-top "0.75em"}}
[:h2.subtitle "Address"]
[address-field {:field [:address]