54 lines
1.6 KiB
Elm
54 lines
1.6 KiB
Elm
|
module Signup exposing (..)
|
||
|
|
||
|
import CommonElements exposing (..)
|
||
|
import Element exposing (..)
|
||
|
import Element.Input as Input
|
||
|
import Model exposing (..)
|
||
|
|
||
|
|
||
|
getPage : Model -> Element Msg
|
||
|
getPage model =
|
||
|
el [] (signupBox model)
|
||
|
|
||
|
|
||
|
signupBox : Model -> Element Msg
|
||
|
signupBox model =
|
||
|
column []
|
||
|
[ text "Sign up"
|
||
|
, Input.email
|
||
|
[ Input.focusedOnLoad
|
||
|
]
|
||
|
{ onChange = CredentialsChange "loginUsername"
|
||
|
, text = Maybe.withDefault "" model.storage.loginUsername
|
||
|
, placeholder = Just (Input.placeholder [] (text "email"))
|
||
|
, label = Input.labelHidden "email"
|
||
|
}
|
||
|
, Input.newPassword []
|
||
|
{ onChange = CredentialsChange "loginPassword"
|
||
|
, text = Maybe.withDefault "" model.storage.loginPassword
|
||
|
, placeholder = Just (Input.placeholder [] (text "password"))
|
||
|
, label = Input.labelHidden "password"
|
||
|
, show = False
|
||
|
}
|
||
|
, Input.newPassword []
|
||
|
{ onChange = CredentialsChange "confirmPassword"
|
||
|
, text = Maybe.withDefault "" model.storage.signupConfirmPassword
|
||
|
, placeholder = Just (Input.placeholder [] (text "confirm password"))
|
||
|
, label = Input.labelHidden "confirm password"
|
||
|
, show = False
|
||
|
}
|
||
|
, Input.button []
|
||
|
{ onPress = ensurePasswordMatch model
|
||
|
, label = text "Sign Up"
|
||
|
}
|
||
|
]
|
||
|
|
||
|
|
||
|
ensurePasswordMatch : Model -> Maybe Msg
|
||
|
ensurePasswordMatch model =
|
||
|
if model.storage.signupConfirmPassword == model.storage.loginPassword then
|
||
|
Just SubmitSignup
|
||
|
|
||
|
else
|
||
|
Just SignupPasswordMismatch
|