Skip to content

Instantly share code, notes, and snippets.

@escherize
Created April 1, 2016 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save escherize/744af627eafb9f4b9889aab1d80c7f48 to your computer and use it in GitHub Desktop.
Save escherize/744af627eafb9f4b9889aab1d80c7f48 to your computer and use it in GitHub Desktop.
(defn fake-signup-view []
(let [debug? (subscribe [:debug?])
loading? (subscribe [:loading?])
email-taken? (subscribe [:email-taken?])
signup-form-data (subscribe [:signup-form])
email (reaction (:email @signup-form-data))
first-name (reaction (:first-name @signup-form-data))
last-name (reaction (:last-name @signup-form-data))
password (reaction (:password @signup-form-data))]
(fn []
[:form#signup-form {:class (str "ui large form" (when @loading? " loading"))
:on-submit (fn [e] (.preventDefault e))}
[:input {:type "text"
:name "email"
:placeholder "Email"
:value @email
:on-change (fn [e]
(dispatch [:update-signup-form :email
(-> e .-target .-value)])
(dispatch [:check-email-taken
(-> e .-target .-value)])
true)}]
[:input {:type "text"
:name "first-name"
:placeholder "First Name"
:value @first-name
:on-change (fn [e]
(dispatch [:update-signup-form
:first-name
(-> e .-target .-value)])
true)}]
[:input {:type "text"
:name "last-name"
:placeholder "Last Name"
:value @last-name
:on-change (fn [e]
(dispatch [:update-signup-form :last-name
(-> e .-target .-value)])
true)}]
[:input {:type "password"
:name "password"
:placeholder "Password"
:value @password
:on-change (fn [e]
(dispatch [:update-signup-form :password
(-> e .-target .-value)])
true)}]
[:button {:class (str "ui button fluid large violet")
:on-click #(when (validate @signup-form-data)
(dispatch [:signup-request]))}
"Submit"]])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment