(ns auto-ap.views.components.address
  (:require [auto-ap.entities.address :as address]
            [auto-ap.views.utils :refer [dispatch-value-change dispatch-event bind-field horizontal-field]]))

(defn address-field [{:keys [event field subscription]}]
  [:span
   [horizontal-field
    nil
    [:div.control
     [:p.help "Address"]
     [bind-field
      [:input.input.is-expanded {:type "text"
                                 :placeholder "1700 Pennsylvania Ave"
                                 :field (conj field :street1)
                                 :spec ::address/street1
                                 :event event
                                 :subscription subscription}]]]]
   
   [horizontal-field
    nil
    [:div.control
     [bind-field
      [:input.input.is-expanded {:type "text"
                                 :placeholder "Suite 400"
                                 :field (conj field :street2) 
                                 :spec ::address/street2
                                 :event event 
                                 :subscription subscription}]]]]
   
   [horizontal-field
    nil
    [:div.control
     [:p.help "City"]
     [bind-field
      [:input.input.is-expanded {:type "text"
                                 :placeholder "Cupertino"
                                 :field (conj field :city)
                                 :spec ::address/city
                                 :event event
                                 :subscription subscription}]]]
    [:div.control
     [:p.help "State"]
     [bind-field
      [:input.input {:type "text"
                     :placeholder "CA"
                     :field (conj field :state)
                     :spec ::address/state
                     :size 2
                     :max-length "2"
                     :event event
                     :subscription subscription}]]]
    [:div.control
     [:p.help "Zip"]
     [bind-field
      [:input.input {:type "text"
                     :field (conj field :zip)
                     :spec ::address/zip
                     :event event
                     :subscription subscription
                     :placeholder "95014"}]]]]])
