diff --git a/Client/FormFields.hs b/Client/FormFields.hs index a611111..2e5fb15 100644 --- a/Client/FormFields.hs +++ b/Client/FormFields.hs @@ -21,7 +21,22 @@ emailField = Field , fieldView = \id name otherAttributes result isRequired -> let result' = either (\x -> x) renderEmail result in [whamlet| - + + |] + , fieldEnctype = UrlEncoded + } + +telephoneField :: Field Handler PhoneNumber +telephoneField = Field + { fieldParse = \rawValues _ -> + case rawValues of + [] -> pure $ Right Nothing + [x] -> pure $ maybe (Left "could not parse as a phone number") (Right . Just) $ toPhoneNumber x + _ -> pure $ Left $ "Expected one value" + , fieldView = \id name otherAttributes result isRequired -> + let result' = either (\x -> x) renderPhoneNumber result + in [whamlet| + |] , fieldEnctype = UrlEncoded } diff --git a/Client/Handlers/Applications.hs b/Client/Handlers/Applications.hs index 890970f..8708366 100644 --- a/Client/Handlers/Applications.hs +++ b/Client/Handlers/Applications.hs @@ -31,6 +31,7 @@ query Applications { name nickname email + phoneNumber homeplace birthdate application @@ -85,6 +86,9 @@ applicationsW applications = do