district0x / ethlance

Ethlance is the first job market platform built entirely on the Ethereum blockchain. Free to use forever!

Home Page:http://ethlance.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix Sign Up Forms

madvas opened this issue · comments

image

Currently, when sending the form, the graphQL returns following error:

{"errors":[{"message":"Error: error: null value in column \"user_slash_name\" violates not-null constraint","locations":

The error indicated some problem with sent data.

Hints:
Code that sends the data:

(re/reg-event-fx
:page.sign-up/update-candidate
[interceptors]
(fn [{:keys [db]}]
(let [user-address (accounts-queries/active-account db)
{:keys [:user/email
:user/country
:user/name
:user/languages
:user/profile-image
:user/github-code
:user/linkedin-code
:user/linkedin-redirect-uri
:candidate/professional-title
:candidate/rate
:candidate/categories
:candidate/bio
:candidate/skills
]} (get-in db [state-key])]
{:dispatch [::graphql/query {:query
"mutation UpdateCandidate($candidateInput: CandidateInput!) {
updateCandidate(input: $candidateInput) {
user_address
user_dateUpdated
candidate_dateUpdated
}
}"
:variables {:candidateInput {:user_address user-address
:user_email email
:user_userName name
:user_country country
:candidate_bio bio
:candidate_professionalTitle professional-title
:candidate_categories categories
:candidate_skills skills
:candidate_rate (parsers/parse-int rate)
;; NOTE: hardcoded since UI does not allow for a different currency
:candidate_rateCurrencyId :USD}}}]})))

Code that receives data on server side:
(defn update-candidate-mutation [_ {:keys [input]} {:keys [timestamp]}]
(db/with-async-resolver-tx conn
(let [{:user/keys [address]} input
response {:user/address address
:user/date-updated timestamp
:candidate/date-updated timestamp}]
(log/debug "update-candidate-mutation" {:input input :response response})
(<? (ethlance-db/upsert-user! conn (-> input
(assoc :user/type :candidate)
(merge response))))
response)))

Additional things to implement

  • Field validation using spec on server side
  • Indication in UI that the request is being processed. Can be done as: Create button gets disabled and changes button text to "Creating..." and then switches back after receiving the response.
  • Submitting should work for all 3 user types: Candidate, Employer, Arbiter.

Bonus points:

You can give it a try, maybe you'll need some help doing those:

  • User profile page correctly displays submitted data.
  • When user is using form again, it prefills forms with his existing data.