more migrating onto v2

This commit is contained in:
2022-07-21 12:55:55 -07:00
parent 22a5f2a707
commit 1d0cdcaf88
6 changed files with 122 additions and 85 deletions

View File

@@ -34,6 +34,14 @@
(def location-schema (m/schema [:map
[:location schema/not-empty-string]]))
(def square-location-schema (m/schema [:map
[:square-location schema/reference]
[:client-location schema/not-empty-string]]))
(def ezcater-schema (m/schema [:map
[:caterer schema/reference]
[:client-location schema/not-empty-string]]))
(def name-match-schema (m/schema [:map
[:match schema/not-empty-string]]))
(def location-match-schema (m/schema [:map
@@ -52,7 +60,9 @@
[:matches {:optional true}
[:maybe [:sequential name-match-schema]]]
[:location-matches {:optional true}
[:maybe [:sequential location-match-schema]]]])
[:maybe [:sequential location-match-schema]]]
[:selected-square-locations {:optional true}
[:maybe [:sequential square-location-schema]]]])
(defn upload-replacement-button [{:keys [on-change]} text]
(let [button (atom nil)]
@@ -486,7 +496,7 @@
[:div.control
[:p.help "If this account is location-specific, add the valid locations"]
[form-builder/raw-field-v2 {:field :locations}
[com/multi-field-v2 {:template [[form-builder/raw-field {:key :location}
[com/multi-field-v2 {:template [[form-builder/raw-field-v2 {:field :location}
[com/select-field {:options (map (fn [l]
[(:location l) (:location l)])
(get-in new-client [:locations]))
@@ -650,45 +660,49 @@
(defn square-section []
(let [{new-client :data} @(re-frame/subscribe [::forms/form ::form])]
[form-builder/section {:title "Square Integration"}
[form-builder/field "Square Authentication Token"
[form-builder/field-v2 {:field :square-auth-token}
"Square Authentication Token"
[:input.input {:type "text"
:style {:width "40em"}
:field [:square-auth-token]}]]
[form-builder/field
:style {:width "40em"}}]]
[form-builder/field-v2 {:field :selected-square-locations}
"Square Locations"
[multi-field {:type "multi-field"
:field :selected-square-locations
:template [[typeahead-v3 {:entities (:square-locations new-client)
:entity->text :name
:type "typeahead-v3"
:style {:width "15em"}
:field [:square-location]}]
[:input.input {:type "text"
:style {:width "4em"}
:field [:client-location]
:step "0.01"}]]
:disable-remove? true}]]]))
[com/multi-field-v2 {:template [[form-builder/raw-field-v2 {:field :square-location}
[typeahead-v3 {:entities (:square-locations new-client)
:entity->text :name
:style {:width "15em"}}]]
[form-builder/raw-field-v2 {:field :client-location}
[com/select-field {:options (map (fn [l]
[(:location l) (:location l)])
(get-in new-client [:locations]))
:allow-nil? true
:style {:width "7em"}
}]]]
:disable-remove? true
:key-fn :id
:schema [:sequential square-location-schema]}]]]))
(defn ezcater-section []
[form-builder/section {:title "EZCater integration"}
(let [{new-client :data} @(re-frame/subscribe [::forms/form ::form])]
[form-builder/section {:title "EZCater integration"}
[form-builder/field
"EZCater Locations"
[multi-field {:type "multi-field"
:field :ezcater-locations
:template [[search-backed-typeahead {:search-query (fn [i]
[:search_ezcater_caterer
{:query i}
[:name :id]])
:entity->text :name
:type "typeahead-v3"
:field [:caterer]
:style {:width "20em"}}]
[:input.input {:type "text"
:style {:width "4em"}
:field [:location]
:step "0.01"}]]
:disable-remove? true}]]])
[form-builder/field-v2 {:field :ezcater-locations}
"EZCater Locations"
[com/multi-field-v2 {:template [[form-builder/raw-field-v2 {:field :caterer}
[search-backed-typeahead {:search-query (fn [i]
[:search_ezcater_caterer
{:query i}
[:name :id]])
:entity->text :name
:style {:width "20em"}}]]
[form-builder/raw-field-v2 {:field [:location]}
[com/select-field {:options (map (fn [l]
[(:location l) (:location l)])
(get-in new-client [:locations]))
:allow-nil? true
:style {:width "7em"}}]]]
:key-fn :id
:schema [:sequential ezcater-schema]
:disable-remove? true}]]]))
(defn form-content []